1- # encoding: utf-8
2- $LOAD_PATH. unshift File . expand_path ( '../lib' , __FILE__ )
1+ # frozen_string_literal: true
2+
3+ $LOAD_PATH. unshift File . expand_path ( 'lib' , __dir__ )
34windows = RUBY_PLATFORM =~ /mswin|mingw/
45
56require 'bundler/gem_tasks'
67
7- desc " run specs"
8- task ( :spec ) { ruby "-S rspec spec#{ " -c" unless windows } " }
8+ desc ' run specs'
9+ task ( :spec ) { ruby "-S rspec spec#{ ' -c' unless windows } " }
910
10- desc " generate gemspec, update readme"
11- task : update => :completion do
11+ desc ' generate gemspec, update readme'
12+ task update : :completion do
1213 require 'travis/version'
1314 content = File . read ( 'travis.gemspec' )
1415
1516 # fetch data
1617 fields = {
17- : authors => sort_by_commits_alpha ( `git shortlog -sn` . b , /[^\d \s ].*/ ) . uniq ,
18- : email => sort_by_commits_alpha ( `git shortlog -sne` . b , /[^<]+@[^>]+/ ) . uniq ,
19- : files => `git ls-files` . b . split ( "\n " ) . reject { |f | f =~ /^(\. |Gemfile)/ }
18+ authors : sort_by_commits_alpha ( `git shortlog -sn` . b , /[^\d \s ].*/ ) . uniq ,
19+ email : sort_by_commits_alpha ( `git shortlog -sne` . b , /[^<]+@[^>]+/ ) . uniq ,
20+ files : `git ls-files` . b . split ( "\n " ) . reject { |f | f =~ /^(\. |Gemfile)/ }
2021 }
2122
2223 # :(
23- fields [ :email ] . delete ( " [email protected] " ) 24+ fields [ :email ] . delete ( ' [email protected] ' ) 2425
2526 # insert data
2627 fields . each do |field , values |
@@ -31,20 +32,21 @@ task :update => :completion do
3132 end
3233
3334 # set version
34- content . sub! /(s\. version.*=\s +).*/ , "\\ 1\" #{ Travis ::VERSION } \" "
35+ content . sub! ( /(s\. version.*=\s +).*/ , "\\ 1\" #{ Travis ::VERSION } \" " )
3536
3637 # escape unicode
3738 content . gsub! ( /./ ) { |c | c . bytesize > 1 ? "\\ u{#{ c . codepoints . first . to_s ( 16 ) } }" : c }
3839
3940 File . open ( 'travis.gemspec' , 'w' ) { |f | f << content }
4041
4142 readme = File . read ( 'README.md' ) . b
42- readme . gsub! /^(\s +\$ travis version\n \s +).*$/ , "\\ 1#{ Travis ::VERSION } "
43- readme . gsub! /(gem install travis -v )\S +/ , "\\ 1#{ Travis ::VERSION } "
44- readme . gsub! /^\* \* #{ Regexp . escape ( Travis ::VERSION ) } \* \* \( not yet released?\) \n /i , "**#{ Travis ::VERSION } ** (#{ Time . now . strftime ( "%B %-d, %Y" ) } )\n "
43+ readme . gsub! ( /^(\s +\$ travis version\n \s +).*$/ , "\\ 1#{ Travis ::VERSION } " )
44+ readme . gsub! ( /(gem install travis -v )\S +/ , "\\ 1#{ Travis ::VERSION } " )
45+ readme . gsub! ( /^\* \* #{ Regexp . escape ( Travis ::VERSION ) } \* \* \( not yet released?\) \n /i ,
46+ "**#{ Travis ::VERSION } ** (#{ Time . now . strftime ( '%B %-d, %Y' ) } )\n " )
4547
4648 Travis ::CLI . commands . each do |c |
47- readme . sub! /^( \* \[ \ `#{ c . command_name } \ `\] \( ##{ c . command_name } \) ).*$/ , "\\ 1 - #{ c . description } "
49+ readme . sub! ( /^( \* \[ `#{ c . command_name } `\] \( ##{ c . command_name } \) ).*$/ , "\\ 1 - #{ c . description } " )
4850 end
4951
5052 File . write ( 'README.md' , readme )
5860task 'travis.gemspec' => :update
5961task 'README.md' => :update
6062
61- task : gemspec => :update
62- task : default => :spec
63- task : default => :gemspec unless windows or RUBY_VERSION < '2.0'
64- task : test => :spec
63+ task gemspec : :update
64+ task default : :spec
65+ task default : :gemspec unless windows || ( RUBY_VERSION < '2.0' )
66+ task test : :spec
6567
6668def sort_by_commits_alpha ( shortlog_output , patt )
67- shortlog_output . split ( "\n " ) . sort do |a , b |
69+ shortlog_output . split ( "\n " ) . sort do |a , b |
6870 a_comm , a_name = a . strip . split ( /\t / )
6971 b_comm , b_name = b . strip . split ( /\t / )
7072
0 commit comments