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__ )
3
4
windows = RUBY_PLATFORM =~ /mswin|mingw/
4
5
5
6
require 'bundler/gem_tasks'
6
7
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 } " }
9
10
10
- desc " generate gemspec, update readme"
11
- task : update => :completion do
11
+ desc ' generate gemspec, update readme'
12
+ task update : :completion do
12
13
require 'travis/version'
13
14
content = File . read ( 'travis.gemspec' )
14
15
15
16
# fetch data
16
17
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)/ }
20
21
}
21
22
22
23
# :(
23
- fields [ :email ] . delete ( " [email protected] " )
24
+ fields [ :email ] . delete ( ' [email protected] ' )
24
25
25
26
# insert data
26
27
fields . each do |field , values |
@@ -31,20 +32,21 @@ task :update => :completion do
31
32
end
32
33
33
34
# set version
34
- content . sub! /(s\. version.*=\s +).*/ , "\\ 1\" #{ Travis ::VERSION } \" "
35
+ content . sub! ( /(s\. version.*=\s +).*/ , "\\ 1\" #{ Travis ::VERSION } \" " )
35
36
36
37
# escape unicode
37
38
content . gsub! ( /./ ) { |c | c . bytesize > 1 ? "\\ u{#{ c . codepoints . first . to_s ( 16 ) } }" : c }
38
39
39
40
File . open ( 'travis.gemspec' , 'w' ) { |f | f << content }
40
41
41
42
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 " )
45
47
46
48
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 } " )
48
50
end
49
51
50
52
File . write ( 'README.md' , readme )
58
60
task 'travis.gemspec' => :update
59
61
task 'README.md' => :update
60
62
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
65
67
66
68
def 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 |
68
70
a_comm , a_name = a . strip . split ( /\t / )
69
71
b_comm , b_name = b . strip . split ( /\t / )
70
72
0 commit comments