travis 1.11.1 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -3
  3. data/Rakefile +22 -20
  4. data/bin/travis +5 -3
  5. data/examples/org_overview.rb +2 -0
  6. data/examples/pro_auth.rb +3 -1
  7. data/examples/stream.rb +5 -3
  8. data/lib/travis/auto_login.rb +2 -0
  9. data/lib/travis/cli/accounts.rb +12 -9
  10. data/lib/travis/cli/api_command.rb +85 -81
  11. data/lib/travis/cli/branches.rb +8 -6
  12. data/lib/travis/cli/cache.rb +48 -44
  13. data/lib/travis/cli/cancel.rb +4 -2
  14. data/lib/travis/cli/command.rb +170 -142
  15. data/lib/travis/cli/console.rb +5 -5
  16. data/lib/travis/cli/disable.rb +4 -2
  17. data/lib/travis/cli/enable.rb +14 -12
  18. data/lib/travis/cli/encrypt.rb +57 -57
  19. data/lib/travis/cli/encrypt_file.rb +29 -18
  20. data/lib/travis/cli/endpoint.rb +9 -7
  21. data/lib/travis/cli/env.rb +13 -8
  22. data/lib/travis/cli/help.rb +10 -8
  23. data/lib/travis/cli/history.rb +19 -15
  24. data/lib/travis/cli/init.rb +27 -24
  25. data/lib/travis/cli/lint.rb +10 -8
  26. data/lib/travis/cli/login.rb +17 -11
  27. data/lib/travis/cli/logout.rb +4 -2
  28. data/lib/travis/cli/logs.rb +28 -19
  29. data/lib/travis/cli/monitor.rb +11 -8
  30. data/lib/travis/cli/open.rb +17 -14
  31. data/lib/travis/cli/parser.rb +2 -0
  32. data/lib/travis/cli/pubkey.rb +13 -11
  33. data/lib/travis/cli/raw.rb +4 -3
  34. data/lib/travis/cli/repo_command.rb +123 -112
  35. data/lib/travis/cli/report.rb +40 -33
  36. data/lib/travis/cli/repos.rb +14 -9
  37. data/lib/travis/cli/requests.rb +13 -12
  38. data/lib/travis/cli/restart.rb +4 -2
  39. data/lib/travis/cli/settings.rb +41 -35
  40. data/lib/travis/cli/setup/anynines.rb +7 -6
  41. data/lib/travis/cli/setup/appfog.rb +6 -4
  42. data/lib/travis/cli/setup/artifacts.rb +7 -5
  43. data/lib/travis/cli/setup/biicode.rb +6 -4
  44. data/lib/travis/cli/setup/cloud_66.rb +6 -4
  45. data/lib/travis/cli/setup/cloud_control.rb +8 -6
  46. data/lib/travis/cli/setup/cloud_files.rb +7 -5
  47. data/lib/travis/cli/setup/cloud_foundry.rb +9 -7
  48. data/lib/travis/cli/setup/code_deploy.rb +33 -29
  49. data/lib/travis/cli/setup/deis.rb +8 -6
  50. data/lib/travis/cli/setup/divshot.rb +20 -18
  51. data/lib/travis/cli/setup/elastic_beanstalk.rb +10 -8
  52. data/lib/travis/cli/setup/engine_yard.rb +9 -7
  53. data/lib/travis/cli/setup/gcs.rb +9 -7
  54. data/lib/travis/cli/setup/hackage.rb +6 -4
  55. data/lib/travis/cli/setup/heroku.rb +10 -4
  56. data/lib/travis/cli/setup/modulus.rb +5 -3
  57. data/lib/travis/cli/setup/ninefold.rb +7 -5
  58. data/lib/travis/cli/setup/nodejitsu.rb +6 -4
  59. data/lib/travis/cli/setup/npm.rb +6 -4
  60. data/lib/travis/cli/setup/open_shift.rb +8 -6
  61. data/lib/travis/cli/setup/opsworks.rb +24 -22
  62. data/lib/travis/cli/setup/pypi.rb +7 -5
  63. data/lib/travis/cli/setup/releases.rb +6 -6
  64. data/lib/travis/cli/setup/ruby_gems.rb +7 -5
  65. data/lib/travis/cli/setup/s3.rb +12 -8
  66. data/lib/travis/cli/setup/sauce_connect.rb +7 -5
  67. data/lib/travis/cli/setup/service.rb +36 -25
  68. data/lib/travis/cli/setup.rb +7 -3
  69. data/lib/travis/cli/show.rb +10 -8
  70. data/lib/travis/cli/sshkey.rb +31 -27
  71. data/lib/travis/cli/status.rb +5 -3
  72. data/lib/travis/cli/sync.rb +9 -7
  73. data/lib/travis/cli/token.rb +4 -2
  74. data/lib/travis/cli/version.rb +4 -3
  75. data/lib/travis/cli/whatsup.rb +10 -8
  76. data/lib/travis/cli/whoami.rb +2 -2
  77. data/lib/travis/cli.rb +39 -36
  78. data/lib/travis/client/account.rb +8 -6
  79. data/lib/travis/client/artifact.rb +16 -12
  80. data/lib/travis/client/auto_login.rb +7 -4
  81. data/lib/travis/client/broadcast.rb +2 -0
  82. data/lib/travis/client/build.rb +7 -3
  83. data/lib/travis/client/cache.rb +4 -2
  84. data/lib/travis/client/commit.rb +5 -2
  85. data/lib/travis/client/entity.rb +50 -46
  86. data/lib/travis/client/env_var.rb +13 -8
  87. data/lib/travis/client/error.rb +5 -3
  88. data/lib/travis/client/has_uuid.rb +3 -1
  89. data/lib/travis/client/job.rb +8 -3
  90. data/lib/travis/client/lint_result.rb +2 -0
  91. data/lib/travis/client/listener.rb +70 -55
  92. data/lib/travis/client/methods.rb +10 -5
  93. data/lib/travis/client/namespace.rb +20 -16
  94. data/lib/travis/client/not_loadable.rb +3 -1
  95. data/lib/travis/client/repository.rb +34 -22
  96. data/lib/travis/client/request.rb +5 -2
  97. data/lib/travis/client/restartable.rb +2 -0
  98. data/lib/travis/client/session.rb +118 -88
  99. data/lib/travis/client/settings.rb +8 -3
  100. data/lib/travis/client/singleton_setting.rb +2 -0
  101. data/lib/travis/client/ssh_key.rb +2 -0
  102. data/lib/travis/client/states.rb +8 -6
  103. data/lib/travis/client/user.rb +2 -0
  104. data/lib/travis/client/weak_entity.rb +6 -3
  105. data/lib/travis/client.rb +4 -1
  106. data/lib/travis/pro/auto_login.rb +2 -0
  107. data/lib/travis/pro.rb +2 -0
  108. data/lib/travis/tools/assets.rb +6 -3
  109. data/lib/travis/tools/completion.rb +10 -6
  110. data/lib/travis/tools/formatter.rb +20 -14
  111. data/lib/travis/tools/github.rb +59 -49
  112. data/lib/travis/tools/notification.rb +18 -13
  113. data/lib/travis/tools/safe_string.rb +4 -1
  114. data/lib/travis/tools/ssl_key.rb +5 -2
  115. data/lib/travis/tools/system.rb +11 -6
  116. data/lib/travis/version.rb +3 -1
  117. data/lib/travis.rb +3 -1
  118. data/spec/cli/api_command_spec.rb +11 -8
  119. data/spec/cli/cancel_spec.rb +2 -4
  120. data/spec/cli/encrypt_file_spec.rb +9 -7
  121. data/spec/cli/encrypt_spec.rb +19 -17
  122. data/spec/cli/endpoint_spec.rb +12 -10
  123. data/spec/cli/help_spec.rb +14 -12
  124. data/spec/cli/history_spec.rb +2 -0
  125. data/spec/cli/init_spec.rb +35 -33
  126. data/spec/cli/logs_spec.rb +2 -0
  127. data/spec/cli/open_spec.rb +6 -4
  128. data/spec/cli/repo_command_spec.rb +8 -4
  129. data/spec/cli/restart_spec.rb +2 -4
  130. data/spec/cli/setup/service_spec.rb +17 -18
  131. data/spec/cli/setup_spec.rb +2 -4
  132. data/spec/cli/show_spec.rb +4 -2
  133. data/spec/cli/status_spec.rb +7 -5
  134. data/spec/cli/token_spec.rb +7 -5
  135. data/spec/cli/version_spec.rb +2 -0
  136. data/spec/cli/whoami_spec.rb +9 -7
  137. data/spec/client/account_spec.rb +28 -20
  138. data/spec/client/auto_login_spec.rb +12 -9
  139. data/spec/client/broadcast_spec.rb +5 -3
  140. data/spec/client/build_spec.rb +28 -24
  141. data/spec/client/commit_spec.rb +17 -14
  142. data/spec/client/job_spec.rb +27 -23
  143. data/spec/client/methods_spec.rb +8 -4
  144. data/spec/client/namespace_spec.rb +8 -4
  145. data/spec/client/repository_spec.rb +33 -30
  146. data/spec/client/session_spec.rb +71 -67
  147. data/spec/client/user_spec.rb +13 -10
  148. data/spec/client_spec.rb +6 -4
  149. data/spec/pro_spec.rb +5 -3
  150. data/spec/spec_helper.rb +3 -1
  151. data/spec/support/fake_api.rb +662 -662
  152. data/spec/support/fake_github.rb +6 -3
  153. data/spec/support/helpers.rb +13 -8
  154. data/spec/travis_spec.rb +5 -3
  155. data/travis.gemspec +400 -399
  156. metadata +30 -50
@@ -1,38 +1,39 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'travis/cli'
3
4
 
4
5
  module Travis
5
6
  module CLI
6
7
  class Encrypt < RepoCommand
7
- description "encrypts values for the .travis.yml"
8
+ description 'encrypts values for the .travis.yml'
8
9
  attr_accessor :config_key
9
10
 
10
11
  on('-a', '--add [KEY]', 'adds it to .travis.yml under KEY (default: env.global)') do |c, value|
11
12
  c.config_key = value || 'env.global'
12
13
  end
13
14
 
14
- on('-s', '--[no-]split', "treat each line as a separate input")
15
+ on('-s', '--[no-]split', 'treat each line as a separate input')
15
16
  on('-p', '--append', "don't override existing values, instead treat as list")
16
- on('-x', '--override', "override existing value")
17
+ on('-x', '--override', 'override existing value')
17
18
 
18
19
  def run(*args)
19
20
  confirm = force_interactive.nil? || force_interactive
20
- error "cannot combine --override and --append" if append? and override?
21
- error "--append without --add makes no sense" if append? and not add?
22
- error "--override without --add makes no sense" if override? and not add?
23
- self.override |= !config_key.start_with?('env.') if add? and not append?
21
+ error 'cannot combine --override and --append' if append? && override?
22
+ error '--append without --add makes no sense' if append? && !add?
23
+ error '--override without --add makes no sense' if override? && !add?
24
+ self.override |= !config_key.start_with?('env.') if add? && !append?
24
25
 
25
- if args.first =~ %r{\w+/\w+} && !args.first.include?("=")
26
- warn "WARNING: The name of the repository is now passed to the command with the -r option:"
26
+ if args.first =~ %r{\w+/\w+} && !args.first.include?('=')
27
+ warn 'WARNING: The name of the repository is now passed to the command with the -r option:'
27
28
  warn " #{command("encrypt [...] -r #{args.first}")}"
28
- warn " If you tried to pass the name of the repository as the first argument, you"
29
+ warn ' If you tried to pass the name of the repository as the first argument, you'
29
30
  warn " probably won't get the results you wanted.\n"
30
31
  end
31
32
 
32
- data = args.join(" ")
33
+ data = args.join(' ')
33
34
 
34
35
  if data.empty?
35
- say color("Reading from stdin, press Ctrl+D when done", :info) if $stdin.tty?
36
+ say color('Reading from stdin, press Ctrl+D when done', :info) if $stdin.tty?
36
37
  data = $stdin.read
37
38
  end
38
39
 
@@ -41,69 +42,68 @@ module Travis
41
42
  encrypted = data.map { |data| repository.encrypt(data) }
42
43
 
43
44
  if config_key
44
- set_config encrypted.map { |e| { 'secure' => e } }
45
+ set_config(encrypted.map { |e| { 'secure' => e } })
45
46
  confirm_and_save_travis_config confirm
46
47
  else
47
- list = encrypted.map { |data| format(data.inspect, " secure: %s") }
48
+ list = encrypted.map { |data| format(data.inspect, ' secure: %s') }
48
49
  say(list.join("\n"), template(__FILE__), :none)
49
50
  end
50
- rescue OpenSSL::PKey::RSAError => error
51
- error "#{error.message.sub(" for key size", "")} - consider using " <<
52
- color("travis encrypt-file", [:red, :bold]) <<
53
- color(" or ", :red) <<
54
- color("travis env set", [:red, :bold])
51
+ rescue OpenSSL::PKey::RSAError => e
52
+ error "#{e.message.sub(' for key size', '')} - consider using " <<
53
+ color('travis encrypt-file', %i[red bold]) <<
54
+ color(' or ', :red) <<
55
+ color('travis env set', %i[red bold])
55
56
  end
56
57
 
57
58
  private
58
59
 
59
- def add?
60
- !!config_key
61
- end
60
+ def add?
61
+ !!config_key
62
+ end
62
63
 
63
- def set_config(result)
64
- parent_config[last_key] = merge_config(result)
65
- end
64
+ def set_config(result)
65
+ parent_config[last_key] = merge_config(result)
66
+ end
66
67
 
67
- def merge_config(result)
68
- case subconfig = (parent_config[last_key] unless override?)
69
- when nil then result.size == 1 ? result.first : result
70
- when Array then subconfig + result
71
- else result.unshift(subconfig)
72
- end
68
+ def merge_config(result)
69
+ case subconfig = (parent_config[last_key] unless override?)
70
+ when nil then result.size == 1 ? result.first : result
71
+ when Array then subconfig + result
72
+ else result.unshift(subconfig)
73
73
  end
74
+ end
74
75
 
75
- def subconfig
76
- end
76
+ def subconfig; end
77
77
 
78
- def key_chain
79
- @key_chain ||= config_key.split('.')
80
- end
78
+ def key_chain
79
+ @key_chain ||= config_key.split('.')
80
+ end
81
81
 
82
- def last_key
83
- key_chain.last
84
- end
82
+ def last_key
83
+ key_chain.last
84
+ end
85
85
 
86
- def parent_config
87
- @parent_config ||= traverse_config(travis_config, *key_chain[0..-2])
88
- end
86
+ def parent_config
87
+ @parent_config ||= traverse_config(travis_config, *key_chain[0..-2])
88
+ end
89
89
 
90
- def traverse_config(hash, key = nil, *rest)
91
- return hash unless key
90
+ def traverse_config(hash, key = nil, *rest)
91
+ return hash unless key
92
92
 
93
- hash[key] = case value = hash[key]
94
- when nil then {}
95
- when Hash then value
96
- else { 'matrix' => Array(value) }
97
- end
93
+ hash[key] = case value = hash[key]
94
+ when nil then {}
95
+ when Hash then value
96
+ else { 'matrix' => Array(value) }
97
+ end
98
98
 
99
- traverse_config(hash[key], *rest)
100
- end
99
+ traverse_config(hash[key], *rest)
100
+ end
101
101
 
102
- def warn_env_assignments(data)
103
- if /env/.match(config_key) && data.find { |d| /=/.match(d).nil? }
104
- warn "Environment variables in #{config_key} should be formatted as FOO=bar"
105
- end
106
- end
102
+ def warn_env_assignments(data)
103
+ return unless /env/.match(config_key) && data.find { |d| /=/.match(d).nil? }
104
+
105
+ warn "Environment variables in #{config_key} should be formatted as FOO=bar"
106
+ end
107
107
  end
108
108
  end
109
109
  end
@@ -1,4 +1,5 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'travis/cli'
3
4
  require 'travis/tools/system'
4
5
 
@@ -11,6 +12,7 @@ module Travis
11
12
  module CLI
12
13
  class EncryptFile < RepoCommand
13
14
  attr_accessor :stage
15
+
14
16
  description 'encrypts a file and adds decryption steps to .travis.yml'
15
17
  on '-K', '--key KEY', 'encryption key to be used (randomly generated otherwise)'
16
18
  on '--iv IV', 'encryption IV to be used (randomly generated otherwise)'
@@ -18,7 +20,8 @@ module Travis
18
20
  on '-f', '--force', 'override output file if it exists'
19
21
  on '-p', '--print-key', 'print (possibly generated) key and iv'
20
22
  on '-w', '--decrypt-to PATH', 'where to write the decrypted file to on the Travis CI VM'
21
- on '-a', '--add [STAGE]', 'automatically add command to .travis.yml (default stage is before_install)' do |c, stage|
23
+ on '-a', '--add [STAGE]',
24
+ 'automatically add command to .travis.yml (default stage is before_install)' do |c, stage|
22
25
  c.stage = stage || 'before_install'
23
26
  end
24
27
 
@@ -37,7 +40,7 @@ module Travis
37
40
  write_file(output_path, result, force)
38
41
  return if decrypt?
39
42
 
40
- error "requires --decrypt-to option when reading from stdin" unless decrypt_to?
43
+ error 'requires --decrypt-to option when reading from stdin' unless decrypt_to?
41
44
 
42
45
  set_env_vars(input_path)
43
46
 
@@ -52,8 +55,8 @@ module Travis
52
55
  super
53
56
  self.key ||= SecureRandom.hex(32) unless decrypt?
54
57
  self.iv ||= SecureRandom.hex(16) unless decrypt?
55
- error "key must be 64 characters long and a valid hex number" unless key =~ /^[a-f0-9]{64}$/
56
- error "iv must be 32 characters long and a valid hex number" unless iv =~ /^[a-f0-9]{32}$/
58
+ error 'key must be 64 characters long and a valid hex number' unless key =~ /^[a-f0-9]{64}$/
59
+ error 'iv must be 32 characters long and a valid hex number' unless iv =~ /^[a-f0-9]{32}$/
57
60
  end
58
61
 
59
62
  def print_command(command)
@@ -69,13 +72,15 @@ module Travis
69
72
  end
70
73
 
71
74
  def decrypt_command(path)
72
- "openssl aes-256-cbc -K $#{env_name(path, :key)} -iv $#{env_name(path, :iv)} -in #{escape_path(path)} -out #{escape_path(decrypt_to)} -d"
75
+ "openssl aes-256-cbc -K $#{env_name(path,
76
+ :key)} -iv $#{env_name(path,
77
+ :iv)} -in #{escape_path(path)} -out #{escape_path(decrypt_to)} -d"
73
78
  end
74
79
 
75
80
  def set_env_vars(input_path)
76
- say "storing secure env variables for decryption"
77
- repository.env_vars.upsert env_name(input_path, :key), key, :public => false
78
- repository.env_vars.upsert env_name(input_path, :iv), iv, :public => false
81
+ say 'storing secure env variables for decryption'
82
+ repository.env_vars.upsert env_name(input_path, :key), key, public: false
83
+ repository.env_vars.upsert env_name(input_path, :iv), iv, public: false
79
84
  end
80
85
 
81
86
  def env_name(input_path, name)
@@ -84,20 +89,24 @@ module Travis
84
89
  end
85
90
 
86
91
  def notes(input_path, output_path)
87
- say "\nkey: #{color(key, :info)}\niv: #{color(iv, :info)}" if print_key?
92
+ say "\nkey: #{color(key, :info)}\niv: #{color(iv, :info)}" if print_key?
88
93
  empty_line
89
94
  say "Make sure to add #{color(output_path, :info)} to the git repository."
90
- say "Make sure #{color("not", :underline)} to add #{color(input_path, :info)} to the git repository." if input_path != '-'
95
+ if input_path != '-'
96
+ say "Make sure #{color('not',
97
+ :underline)} to add #{color(input_path,
98
+ :info)} to the git repository."
99
+ end
91
100
  say "Commit all changes to your #{color('.travis.yml', :info)}."
92
101
  end
93
102
 
94
103
  def transcode(input_path)
95
104
  description = "stdin#{' (waiting for input)' if $stdin.tty?}" if input_path == '-'
96
- say "#{decrypt ? "de" : "en"}crypting #{color(description || input_path, :info)} for #{color(slug, :info)}"
105
+ say "#{decrypt ? 'de' : 'en'}crypting #{color(description || input_path, :info)} for #{color(slug, :info)}"
97
106
 
98
107
  data = input_path == '-' ? $stdin.read : File.binread(input_path)
99
108
  aes = OpenSSL::Cipher.new('AES-256-CBC')
100
- decrypt ? aes.decrypt : aes.encrypt
109
+ decrypt ? aes.decrypt : aes.encrypt
101
110
  aes.key = [key].pack('H*')
102
111
  aes.iv = [iv].pack('H*')
103
112
 
@@ -106,6 +115,7 @@ module Travis
106
115
 
107
116
  def decrypt_to_for(input_path)
108
117
  return if input_path == '-'
118
+
109
119
  if input_path.start_with? Dir.home
110
120
  input_path.sub(Dir.home, '~')
111
121
  else
@@ -114,18 +124,19 @@ module Travis
114
124
  end
115
125
 
116
126
  def escape_path(path)
117
- Shellwords.escape(path).sub(/^\\~\//, '~\/')
127
+ Shellwords.escape(path).sub(%r{^\\~/}, '~\/')
118
128
  end
119
129
 
120
130
  def output_path_for(input_path)
121
131
  case input_path
122
132
  when '-' then return '-'
123
- when /^(.+)\.enc$/ then return $1 if decrypt?
124
- when /^(.+)\.dec$/ then return $1 unless decrypt?
133
+ when /^(.+)\.enc$/ then return ::Regexp.last_match(1) if decrypt?
134
+ when /^(.+)\.dec$/ then return ::Regexp.last_match(1) unless decrypt?
125
135
  end
126
136
 
127
- if interactive? and input_path =~ /(\.enc|\.dec)$/
128
- exit 1 unless danger_zone? "File extension of input file is #{color($1, :info)}, are you sure that is correct?"
137
+ if interactive? && input_path =~ /(\.enc|\.dec)$/ && !(danger_zone? "File extension of input file is #{color(::Regexp.last_match(1),
138
+ :info)}, are you sure that is correct?")
139
+ exit 1
129
140
  end
130
141
 
131
142
  "#{input_path}.#{decrypt ? 'dec' : 'enc'}"
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'travis/cli'
2
4
 
3
5
  module Travis
4
6
  module CLI
5
7
  class Endpoint < ApiCommand
6
- description "displays or changes the API endpoint"
8
+ description 'displays or changes the API endpoint'
7
9
 
8
10
  skip :authenticate
9
11
  on '--drop-default', 'delete stored default endpoint'
@@ -11,19 +13,19 @@ module Travis
11
13
  on '--github', 'display github endpoint'
12
14
 
13
15
  def run_github
14
- error "--github cannot be combined with --drop-default" if drop_default?
15
- error "--github cannot be combined with --set-default" if set_default?
16
+ error '--github cannot be combined with --drop-default' if drop_default?
17
+ error '--github cannot be combined with --set-default' if set_default?
16
18
  load_gh
17
- say github_endpoint.to_s, "GitHub endpoint: %s"
19
+ say github_endpoint.to_s, 'GitHub endpoint: %s'
18
20
  end
19
21
 
20
22
  def run_travis
21
- if drop_default? and was = config['default_endpoint']
23
+ if drop_default? && (was = config['default_endpoint'])
22
24
  config.delete('default_endpoint')
23
- say was, "default API endpoint dropped (was %s)"
25
+ say was, 'default API endpoint dropped (was %s)'
24
26
  else
25
27
  config['default_endpoint'] = api_endpoint if set_default?
26
- say api_endpoint, "API endpoint: %s#{" (stored as default)" if set_default?}"
28
+ say api_endpoint, "API endpoint: %s#{' (stored as default)' if set_default?}"
27
29
  end
28
30
  end
29
31
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'travis/cli'
2
4
  require 'shellwords'
3
5
 
@@ -5,11 +7,11 @@ module Travis
5
7
  module CLI
6
8
  class Env < RepoCommand
7
9
  on('-P', '--[no-]public', 'make new values public')
8
- on('-p', '--[no-]private', 'make new values private') { |c,v| c.public = !v }
10
+ on('-p', '--[no-]private', 'make new values private') { |c, v| c.public = !v }
9
11
  on('-u', '--[no-]unescape', 'do not escape values')
10
12
  on('-f', '--force', 'do not ask for confirmation when clearing out all variables')
11
13
 
12
- description "show or modify build environment variables"
14
+ description 'show or modify build environment variables'
13
15
  subcommands :list, :set, :unset, :copy, :clear
14
16
 
15
17
  def setup
@@ -19,8 +21,8 @@ module Travis
19
21
  end
20
22
 
21
23
  def set(name, value)
22
- options ||= { :public => public } if public != nil
23
- say color('[+] ', [:green, :bold]) + "setting environment variable #{color "$#{name}", :info}"
24
+ options ||= { public: } unless public.nil?
25
+ say color('[+] ', %i[green bold]) + "setting environment variable #{color "$#{name}", :info}"
24
26
  value = Shellwords.escape(value) unless unescape?
25
27
  env_vars.upsert(name, value, options || {})
26
28
  end
@@ -41,21 +43,24 @@ module Travis
41
43
 
42
44
  def clear
43
45
  exit if env_vars.empty?
44
- exit 1 if interactive? and not force? and not danger_zone? "Clear out all env variables for #{color(repository.slug, :bold)}?"
46
+ exit 1 if interactive? && !force? && !danger_zone?("Clear out all env variables for #{color(
47
+ repository.slug, :bold
48
+ )}?")
45
49
  remove_vars
46
50
  end
47
51
 
48
52
  def remove_vars
49
53
  env_vars.each do |var|
50
- next if block_given? and not yield(var)
51
- say color('[x] ', [:red, :bold]) + "removing environment variable #{color "$#{var.name}", :info}"
54
+ next if block_given? && !yield(var)
55
+
56
+ say color('[x] ', %i[red bold]) + "removing environment variable #{color "$#{var.name}", :info}"
52
57
  var.delete
53
58
  end
54
59
  end
55
60
 
56
61
  def list
57
62
  say color("# environment variables for #{color repository.slug, :bold}", :info)
58
- env_vars.each { |v| say "#{v.name}=" << color(v.value || "[secure]", :bold) }
63
+ env_vars.each { |v| say "#{v.name}=" << color(v.value || '[secure]', :bold) }
59
64
  end
60
65
 
61
66
  def env_vars
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'travis/cli'
2
4
 
3
5
  module Travis
4
6
  module CLI
5
7
  class Help < Command
6
- description "helps you out when in dire need of information"
8
+ description 'helps you out when in dire need of information'
7
9
 
8
10
  CommandGroup = Struct.new(:cmds, :header)
9
11
 
@@ -22,7 +24,7 @@ module Travis
22
24
  say " #{color(cmd.command_name, :command).ljust(22)} #{color(cmd.description, :info)}"
23
25
  end
24
26
  end
25
- say "\nrun `#$0 help COMMAND` for more info"
27
+ say "\nrun `#{$PROGRAM_NAME} help COMMAND` for more info"
26
28
  end
27
29
  end
28
30
 
@@ -33,20 +35,20 @@ module Travis
33
35
  def api_commands
34
36
  CLI.commands.select do |cmd|
35
37
  cmd.ancestors.include?(CLI::ApiCommand) &&
36
- !cmd.ancestors.include?(CLI::RepoCommand)
37
- end.sort_by {|c| c.command_name}
38
+ !cmd.ancestors.include?(CLI::RepoCommand)
39
+ end.sort_by { |c| c.command_name }
38
40
  end
39
41
 
40
42
  def repo_commands
41
43
  CLI.commands.select do |cmd|
42
44
  cmd.ancestors.include? CLI::RepoCommand
43
- end.sort_by {|c| c.command_name}
45
+ end.sort_by { |c| c.command_name }
44
46
  end
45
47
 
46
48
  def other_commands
47
- CLI.commands.select do |cmd|
48
- !cmd.ancestors.include? CLI::ApiCommand
49
- end.sort_by {|c| c.command_name}
49
+ CLI.commands.reject do |cmd|
50
+ cmd.ancestors.include? CLI::ApiCommand
51
+ end.sort_by { |c| c.command_name }
50
52
  end
51
53
  end
52
54
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'travis/cli'
2
4
 
3
5
  module Travis
@@ -15,9 +17,10 @@ module Travis
15
17
 
16
18
  def run
17
19
  countdown = Integer(limit || 10) unless all?
18
- params = { :after_number => after } if after
20
+ params = { after_number: after } if after
19
21
  repository.each_build(params) do |build|
20
22
  next unless display? build
23
+
21
24
  display(build)
22
25
 
23
26
  if countdown
@@ -29,21 +32,22 @@ module Travis
29
32
 
30
33
  private
31
34
 
32
- def display?(build)
33
- return build.pr_number == pull_request.to_i if pull_request
34
- return build.branch_info == branch if branch
35
- true
36
- end
35
+ def display?(build)
36
+ return build.pr_number == pull_request.to_i if pull_request
37
+ return build.branch_info == branch if branch
37
38
 
38
- def display(build)
39
- say [
40
- date? && color(formatter.time(build.finished_at || build.started_at), build.color),
41
- color("##{build.number} #{build.state}:".ljust(16), [build.color, :bold]),
42
- color("#{build.branch_info}", :info),
43
- committer? && build.commit.author_name.ljust(25),
44
- build.commit.subject
45
- ].compact.join(" ").strip + "\n"
46
- end
39
+ true
40
+ end
41
+
42
+ def display(build)
43
+ say [
44
+ date? && color(formatter.time(build.finished_at || build.started_at), build.color),
45
+ color("##{build.number} #{build.state}:".ljust(16), [build.color, :bold]),
46
+ color(build.branch_info.to_s, :info),
47
+ committer? && build.commit.author_name.ljust(25),
48
+ build.commit.subject
49
+ ].compact.join(' ').strip + "\n"
50
+ end
47
51
  end
48
52
  end
49
53
  end
@@ -1,18 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'travis/cli'
2
4
 
3
5
  module Travis
4
6
  module CLI
5
7
  class Init < Enable
6
8
  LANGUAGE_MAPPING = {
7
- "node" => "node_js",
8
- "node.js" => "node_js",
9
- "javascript" => "node_js",
10
- "coffeescript" => "node_js",
11
- "c++" => "cpp",
12
- "obj-c" => "objective-c"
13
- }
9
+ 'node' => 'node_js',
10
+ 'node.js' => 'node_js',
11
+ 'javascript' => 'node_js',
12
+ 'coffeescript' => 'node_js',
13
+ 'c++' => 'cpp',
14
+ 'obj-c' => 'objective-c'
15
+ }.freeze
14
16
 
15
- description "generates a .travis.yml and enables the project"
17
+ description 'generates a .travis.yml and enables the project'
16
18
 
17
19
  on('-f', '--force', 'override .travis.yml if it already exists')
18
20
  on('-k', '--skip-enable', 'do not enable project, only add .travis.yml')
@@ -25,7 +27,8 @@ module Travis
25
27
  ]
26
28
 
27
29
  options.each do |option|
28
- on "--#{option.gsub('_', '-')} VALUE", "sets #{option} option in .travis.yml (can be used more than once)" do |c, value|
30
+ on "--#{option.gsub('_', '-')} VALUE",
31
+ "sets #{option} option in .travis.yml (can be used more than once)" do |c, value|
29
32
  c.custom_config[option] &&= Array(c.custom_config[option]) << value
30
33
  c.custom_config[option] ||= value
31
34
  end
@@ -39,11 +42,11 @@ module Travis
39
42
  end
40
43
 
41
44
  def help
42
- super("Available languages: #{self.class.languages.join(", ")}\n\n")
45
+ super("Available languages: #{self.class.languages.join(', ')}\n\n")
43
46
  end
44
47
 
45
48
  def run(language = nil, file = '.travis.yml')
46
- error "#{file} already exists, use --force to override" if File.exist?(file) and not force? and not print_conf?
49
+ error "#{file} already exists, use --force to override" if File.exist?(file) && !force? && !print_conf?
47
50
  language ||= ask('Main programming language used: ') { |q| q.default = detect_language }
48
51
  self.travis_config = template(language).merge(custom_config)
49
52
 
@@ -63,21 +66,21 @@ module Travis
63
66
 
64
67
  private
65
68
 
66
- def template_name(language)
67
- asset_path("init/#{language}.yml")
68
- end
69
+ def template_name(language)
70
+ asset_path("init/#{language}.yml")
71
+ end
69
72
 
70
- def template(language)
71
- language = language.to_s.downcase
72
- language = LANGUAGE_MAPPING[language] || language
73
- file = template_name(language)
74
- error "unknown language #{language}" unless File.exist? file
75
- YAML.load_file(file)
76
- end
73
+ def template(language)
74
+ language = language.to_s.downcase
75
+ language = LANGUAGE_MAPPING[language] || language
76
+ file = template_name(language)
77
+ error "unknown language #{language}" unless File.exist? file
78
+ YAML.load_file(file)
79
+ end
77
80
 
78
- def detect_language
79
- repository.github_language || "Ruby"
80
- end
81
+ def detect_language
82
+ repository.github_language || 'Ruby'
83
+ end
81
84
  end
82
85
  end
83
86
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'travis/cli'
2
4
  require 'yaml'
3
5
 
@@ -9,15 +11,15 @@ module Travis
9
11
  on '-x', '--[no-]exit-code', 'sets the exit code to 1 if there are warning'
10
12
 
11
13
  def run(file = nil)
12
- file ||= '.travis.yml' if $stdin.tty? or $stdin.eof?
14
+ file ||= '.travis.yml' if $stdin.tty? || $stdin.eof?
13
15
 
14
- if file and file != '-'
16
+ if file && (file != '-')
15
17
  debug "reading #{file}"
16
18
  error "file does not exist: #{color(file, :bold)}" unless File.exist? file
17
19
  error "cannot read #{color(file, :bold)}" unless File.readable? file
18
20
  content = File.read(file)
19
21
  else
20
- debug "reading stdin"
22
+ debug 'reading stdin'
21
23
  file = 'STDIN'
22
24
  content = $stdin.read
23
25
  end
@@ -32,24 +34,24 @@ module Travis
32
34
 
33
35
  unless quiet?
34
36
  if lint.ok?
35
- say "valid", color("Hooray, #{file} looks %s :)", :success)
37
+ say 'valid', color("Hooray, #{file} looks %s :)", :success)
36
38
  else
37
39
  say "Warnings for #{color(file, :info)}:"
38
40
  lint.warnings.each do |warning|
39
- say color('[x]', [:red, :bold]) + " "
41
+ say "#{color('[x]', %i[red bold])} "
40
42
  if warning.key.any?
41
43
  say [
42
44
  color('in ', :info),
43
- color(warning.key.join('.'), [:info, :bold, :underline]),
45
+ color(warning.key.join('.'), %i[info bold underline]),
44
46
  color(' section:', :info), ' '
45
47
  ].join
46
48
  end
47
- say warning.message.gsub(/"(.*?)"/) { color($1, [:info, :important]) }
49
+ say warning.message.gsub(/"(.*?)"/) { color(::Regexp.last_match(1), %i[info important]) }
48
50
  end
49
51
  end
50
52
  end
51
53
 
52
- exit 1 if lint.warnings? and exit_code?
54
+ exit 1 if lint.warnings? && exit_code?
53
55
  end
54
56
  end
55
57
  end