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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23b3dc0540b49670c431ffd568978ef91fa3b35183d6ef538e6221997156f1c3
4
- data.tar.gz: 8567e7548e471e46db65b1d2a4cbef54077ac4a7564c2cf54f67e0df79a3d299
3
+ metadata.gz: d0b5c4a5f4cbdfb25775698bedbd1cd824829126ef517f1f5b46dfe87269eb55
4
+ data.tar.gz: 49ef3fdf23e50443114305980b451502613322ae67b118cc21512a755b55aae3
5
5
  SHA512:
6
- metadata.gz: 0f770678a593532d320783fb156685d980e81471c7d9d7327b89f181a881c1dc294fa40c3bd0632b38cbda0561688ae5365b312ab0b5a85623f32eb258fb469a
7
- data.tar.gz: 20ced0690a572d0e8cab783661836422eae1a14c47641bb70317920bd015bbdb63cfe6ec2880e82c25e856ea3eea89bbe7ab9cf17fc6bf31cb2bfbf9f7ca2fb4
6
+ metadata.gz: c3d2c85a4a706274f514e593bb56adf3a25f95ba732030c9a47c49c2c0fdc1fbef46bbea4006d2efe555d48c70a80d057fe03d4536da5f713f443c9d5a770d3f
7
+ data.tar.gz: 28f140f38fbfa6f479ff816c4174480d408c90ed4b4f79229c3a4449bdba3abd492acea894d951f679a91be1583b192650109fb36c6efd1f7978a4be1f551d75
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # The Travis Client [![Build Status](https://travis-ci.com/travis-ci/travis.rb.svg?branch=master)](https://travis-ci.com/travis-ci/travis.rb)
1
+ # The Travis Client [![Build Status](https://app.travis-ci.com/travis-ci/travis.rb.svg?branch=master)](https://app.travis-ci.com/github/travis-ci/travis.rb)
2
2
 
3
3
  ![The Travis Mascot](https://about.travis-ci.org/images/travis-mascot-200px.png)
4
4
 
5
- The [travis gem](https://rubygems.org/gems/travis) includes both a [command line client](#command-line-client) and a [Ruby library](#ruby-library) to interface with a Travis CI service. Both work with [travis-ci.org](https://travis-ci.org), [travis-ci.com](https://travis-ci.com) or any custom Travis CI setup you might have. Check out the [installation instructions](#installation) to get it running in no time.
5
+ The [travis gem](https://rubygems.org/gems/travis) includes both a [command line client](#command-line-client) and a [Ruby library](#ruby-library) to interface with a Travis CI service using GitHub account. Both work with [travis-ci.com](https://travis-ci.com) or any custom Travis CI setup you might have. Check out the [installation instructions](#installation) to get it running in no time.
6
6
 
7
7
  ## Table of Contents
8
8
 
@@ -81,7 +81,7 @@ The [travis gem](https://rubygems.org/gems/travis) includes both a [command line
81
81
 
82
82
  ## Command Line Client
83
83
 
84
- ![](http://about.travis-ci.org/images/new-tricks.png)
84
+ ![](https://docs.travis-ci.com/images/new-tricks.png)
85
85
 
86
86
  There are three types of commands: [Non-API Commands](#non-api-commands), [General API Commands](#general-api-commands) and [Repository Commands](#repository-commands). All commands take the form of `travis COMMAND [ARGUMENTS] [OPTIONS]`. You can get a list of commands by running [`help`](#help).
87
87
 
@@ -2066,6 +2066,12 @@ See https://github.com/travis-ci/travis.rb/issues/768#issuecomment-700220351 for
2066
2066
 
2067
2067
  ## Version History
2068
2068
 
2069
+ ### 1.12.0
2070
+
2071
+ * Upgraded ruby version to 3.2 https://github.com/travis-ci/travis.rb/pull/848
2072
+ * Added API Key Reset Capabilities https://github.com/travis-ci/travis.rb/pull/842
2073
+ * Fix travis lint issues https://github.com/travis-ci/travis.rb/pull/840
2074
+
2069
2075
  ### 1.11.1
2070
2076
 
2071
2077
  * Fix `travis sshkey --generate` https://github.com/travis-ci/travis.rb/pull/820
data/Rakefile CHANGED
@@ -1,26 +1,27 @@
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("konstantin.haase@gmail.com")
24
+ fields[:email].delete('konstantin.haase@gmail.com')
24
25
 
25
26
  # insert data
26
27
  fields.each do |field, values|
@@ -31,7 +32,7 @@ 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 }
@@ -39,12 +40,13 @@ task :update => :completion do
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,13 +60,13 @@ end
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
 
data/bin/travis CHANGED
@@ -1,16 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  # :(
3
5
  Encoding.default_external = Encoding::UTF_8 if defined? Encoding
4
6
 
5
7
  # load travis library
6
- require 'bundler/setup' if File.exist? File.expand_path('../../Gemfile', __FILE__)
8
+ require 'bundler/setup' if File.exist? File.expand_path('../Gemfile', __dir__)
7
9
  require 'travis/cli'
8
10
 
9
11
  # load plugins
10
- TRAVIS_PLUGINS = []
12
+ TRAVIS_PLUGINS = [].freeze
11
13
  config_path = ENV.fetch('TRAVIS_CONFIG_PATH') { File.expand_path('.travis', Dir.home) }
12
14
  Dir.glob(File.expand_path('*/init.rb', config_path)) do |file|
13
- TRAVIS_PLUGINS << file.sub(config_path + '/', '').sub(/\/init\.rb$/, '')
15
+ TRAVIS_PLUGINS << file.sub("#{config_path}/", '').sub(%r{/init\.rb$}, '')
14
16
  load(file)
15
17
  end
16
18
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'travis'
2
4
  repos = Travis::Repository.find_all(owner_name: 'travis-ci')
3
5
  repos.each { |repo| puts "#{repo.slug} #{repo.last_build_state}" }
data/examples/pro_auth.rb CHANGED
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'travis/pro'
2
4
  require 'travis/tools/github'
3
5
  require 'highline/import' # so we can hide the password
4
6
 
5
- github_token = ask("GitHub token: ")
7
+ github_token = ask('GitHub token: ')
6
8
 
7
9
  # Set up GitHub tool for doing the login handshake.
8
10
  github = Travis::Tools::Github.new(drop_token: true) do |g|
data/examples/stream.rb CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'travis'
2
4
 
3
5
  Travis.listen do |listener|
4
- listener.on("job:started") { |e| puts "job started for #{e.repository.slug}" }
5
- listener.on("job:finished") { |e| puts "job finished for #{e.repository.slug}" }
6
- end
6
+ listener.on('job:started') { |e| puts "job started for #{e.repository.slug}" }
7
+ listener.on('job:finished') { |e| puts "job finished for #{e.repository.slug}" }
8
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'travis'
2
4
  require 'travis/client/auto_login'
3
5
  Travis::Client::AutoLogin.new(Travis).authenticate
@@ -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 Accounts < ApiCommand
6
- description "displays accounts and their subscription status"
8
+ description 'displays accounts and their subscription status'
7
9
 
8
10
  def run
9
11
  authenticate
@@ -13,18 +15,19 @@ module Travis
13
15
  color(account.login, [color, :bold]),
14
16
  color("(#{account.name || account.login.capitalize}):", color),
15
17
  "#{description(account)},",
16
- account.repos_count == 1 ? "1 repository" : "#{account.repos_count} repositories"
17
- ].join(" ")
18
- end
19
- unless accounts.none?(&:on_trial?) or session.config['host'].nil?
20
- say session.config['host'], "To set up a subscription, please visit %s."
18
+ account.repos_count == 1 ? '1 repository' : "#{account.repos_count} repositories"
19
+ ].join(' ')
21
20
  end
21
+ return if accounts.none?(&:on_trial?) || session.config['host'].nil?
22
+
23
+ say session.config['host'], 'To set up a subscription, please visit %s.'
22
24
  end
23
25
 
24
26
  def description(account)
25
- return "subscribed" if account.subscribed?
26
- return "educational account" if account.educational?
27
- "not subscribed"
27
+ return 'subscribed' if account.subscribed?
28
+ return 'educational account' if account.educational?
29
+
30
+ 'not subscribed'
28
31
  end
29
32
  end
30
33
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'travis/cli'
2
4
  require 'travis/tools/github'
3
5
 
@@ -7,24 +9,25 @@ module Travis
7
9
  include Travis::Client::Methods
8
10
  attr_accessor :enterprise_name
9
11
  attr_reader :session
12
+
10
13
  abstract
11
14
 
12
15
  on('-e', '--api-endpoint URL', 'Travis API server to talk to')
13
16
  on('-I', '--[no-]insecure', 'do not verify SSL certificate of API endpoint')
14
- on('--pro', "short-cut for --api-endpoint '#{Travis::Client::COM_URI}'") { |c,_| c.api_endpoint = Travis::Client::COM_URI }
15
- on('--com', "short-cut for --api-endpoint '#{Travis::Client::COM_URI}'") { |c,_| c.api_endpoint = Travis::Client::COM_URI }
16
- on('--org', "short-cut for --api-endpoint '#{Travis::Client::ORG_URI}'") { |c,_| c.api_endpoint = Travis::Client::ORG_URI }
17
- on('--staging', 'talks to staging system') { |c,_| c.api_endpoint = c.api_endpoint.gsub(/api/, 'api-staging') }
17
+ on('--pro', "short-cut for --api-endpoint '#{Travis::Client::COM_URI}'") { |c, _| c.api_endpoint = Travis::Client::COM_URI }
18
+ on('--com', "short-cut for --api-endpoint '#{Travis::Client::COM_URI}'") { |c, _| c.api_endpoint = Travis::Client::COM_URI }
19
+ on('--org', "short-cut for --api-endpoint '#{Travis::Client::ORG_URI}'") { |c, _| c.api_endpoint = Travis::Client::ORG_URI }
20
+ on('--staging', 'talks to staging system') { |c, _| c.api_endpoint = c.api_endpoint.gsub(/api/, 'api-staging') }
18
21
  on('-t', '--token [ACCESS_TOKEN]', 'access token to use') { |c, t| c.access_token = t }
19
22
 
20
- on('--debug', 'show API requests') do |c,_|
23
+ on('--debug', 'show API requests') do |c, _|
21
24
  c.debug = true
22
25
  c.session.instrument do |info, request|
23
26
  c.time(info, request)
24
27
  end
25
28
  end
26
29
 
27
- on('--debug-http', 'show HTTP(S) exchange') do |c,_|
30
+ on('--debug-http', 'show HTTP(S) exchange') do |c, _|
28
31
  c.session.debug_http = true
29
32
  end
30
33
 
@@ -34,19 +37,17 @@ module Travis
34
37
 
35
38
  on('--adapter ADAPTER', 'Faraday adapter to use for HTTP requests. If omitted, use Typhoeus if it is installed, ' \
36
39
  'and Net::HTTP otherwise. See https://lostisland.github.io/faraday/adapters/ for more info') do |c, adapter|
37
- begin
38
- adapter.gsub! '-', '_'
39
- require "faraday/adapter/#{adapter}"
40
- require 'typhoeus/adapters/faraday' if adapter == 'typhoeus'
41
- c.session.faraday_adapter = adapter.to_sym
42
- rescue LoadError => e
43
- warn "\`--adapter #{adapter}\` is given, but it is not installed. Run \`gem install #{adapter}\` and try again"
44
- exit 1
45
- end
40
+ adapter.gsub! '-', '_'
41
+ require "faraday/adapter/#{adapter}"
42
+ require 'typhoeus/adapters/faraday' if adapter == 'typhoeus'
43
+ c.session.faraday_adapter = adapter.to_sym
44
+ rescue LoadError
45
+ warn "\`--adapter #{adapter}\` is given, but it is not installed. Run \`gem install #{adapter}\` and try again"
46
+ exit 1
46
47
  end
47
48
 
48
49
  def initialize(*)
49
- @session = Travis::Client.new(:agent_info => "command #{command_name}")
50
+ @session = Travis::Client.new(agent_info: "command #{command_name}")
50
51
  super
51
52
  end
52
53
 
@@ -62,8 +63,8 @@ module Travis
62
63
  endpoint_config['access_token'] ||= access_token
63
64
  endpoint_config['insecure'] = insecure unless insecure.nil?
64
65
  self.insecure = endpoint_config['insecure']
65
- session.ssl = { :verify => false } if insecure?
66
- authenticate if pro? or enterprise?
66
+ session.ssl = { verify: false } if insecure?
67
+ authenticate if pro? || enterprise?
67
68
  end
68
69
 
69
70
  def enterprise?
@@ -90,12 +91,12 @@ module Travis
90
91
  user.sync
91
92
 
92
93
  steps = count = 1
93
- while block and user.reload.syncing?
94
+ while block && user.reload.syncing?
94
95
  count += 1
95
96
  sleep(1)
96
97
 
97
- if count % steps == 0
98
- steps = count/10 + 1
98
+ if (count % steps).zero?
99
+ steps = count / 10 + 1
99
100
  output.print dot
100
101
  end
101
102
  end
@@ -103,84 +104,87 @@ module Travis
103
104
 
104
105
  private
105
106
 
106
- def setup_enterprise
107
- return unless setup_enterprise?
108
- c = config['enterprise'] ||= {}
109
- c[enterprise_name] = api_endpoint if explicit_api_endpoint?
110
- c[enterprise_name] ||= write_to($stderr) do
111
- error "enterprise setup not configured" unless interactive?
112
- user_input = ask(color("Enterprise domain: ", :bold)).to_s
113
- domain = user_input[%r{^(?:https?://)?(.*?)/?(?:/api/?)?$}, 1]
114
- endpoint = "https://#{domain}/api"
115
- config['default_endpoint'] = endpoint if agree("Use #{color domain, :bold} as default endpoint? ") { |q| q.default = 'yes' }
116
- endpoint
117
- end
118
- self.api_endpoint = c[enterprise_name]
119
- self.insecure = insecure unless insecure.nil?
120
- self.session.ssl.delete :ca_file
121
- endpoint_config['enterprise'] = true
122
- @setup_ennterpise = true
123
- end
124
-
125
- def setup_enterprise?
126
- @setup_ennterpise ||= false
127
- !!enterprise_name and not @setup_ennterpise
107
+ def setup_enterprise
108
+ return unless setup_enterprise?
109
+
110
+ c = config['enterprise'] ||= {}
111
+ c[enterprise_name] = api_endpoint if explicit_api_endpoint?
112
+ c[enterprise_name] ||= write_to($stderr) do
113
+ error 'enterprise setup not configured' unless interactive?
114
+ user_input = ask(color('Enterprise domain: ', :bold)).to_s
115
+ domain = user_input[%r{^(?:https?://)?(.*?)/?(?:/api/?)?$}, 1]
116
+ endpoint = "https://#{domain}/api"
117
+ config['default_endpoint'] = endpoint if agree("Use #{color domain, :bold} as default endpoint? ") { |q| q.default = 'yes' }
118
+ endpoint
128
119
  end
120
+ self.api_endpoint = c[enterprise_name]
121
+ self.insecure = insecure unless insecure.nil?
122
+ session.ssl.delete :ca_file
123
+ endpoint_config['enterprise'] = true
124
+ @setup_ennterpise = true
125
+ end
129
126
 
130
- def load_gh
127
+ def setup_enterprise?
128
+ @setup_ennterpise ||= false
129
+ !!enterprise_name and not @setup_ennterpise
130
+ end
131
131
 
132
- gh_config = session.config['github']
133
- gh_config &&= gh_config.inject({}) { |h,(k,v)| h.update(k.to_sym => v) }
134
- gh_config ||= {}
135
- gh_config[:ssl] = Travis::Client::Session::SSL_OPTIONS
136
- gh_config[:ssl] = { :verify => false } if gh_config[:api_url] and gh_config[:api_url] != "https://api.github.com"
137
- gh_config.delete :scopes
132
+ def load_gh
133
+ gh_config = session.config['github']
134
+ gh_config &&= gh_config.inject({}) { |h, (k, v)| h.update(k.to_sym => v) }
135
+ gh_config ||= {}
136
+ gh_config[:ssl] = Travis::Client::Session::SSL_OPTIONS
137
+ gh_config[:ssl] = { verify: false } if gh_config[:api_url] && gh_config[:api_url] != 'https://api.github.com'
138
+ gh_config.delete :scopes
138
139
 
140
+ if debug?
139
141
  gh_config[:instrumenter] = proc do |type, payload, &block|
140
142
  next block.call unless type == 'http.gh'
141
- time("GitHub API: #{payload[:verb].to_s.upcase} #{payload[:url]}", block)
142
- end if debug?
143
143
 
144
- GH.set(gh_config)
144
+ time("GitHub API: #{payload[:verb].to_s.upcase} #{payload[:url]}", block)
145
+ end
145
146
  end
146
147
 
147
- def github_endpoint
148
- load_gh
149
- GH.with({}).api_host
150
- end
148
+ GH.set(gh_config)
149
+ end
151
150
 
152
- def listen(*args)
153
- super(*args) do |listener|
154
- on_signal { listener.disconnect }
155
- yield listener
156
- end
157
- end
151
+ def github_endpoint
152
+ load_gh
153
+ GH.with({}).api_host
154
+ end
158
155
 
159
- def default_endpoint
160
- ENV['TRAVIS_ENDPOINT'] || config['default_endpoint']
156
+ def listen(*args)
157
+ super(*args) do |listener|
158
+ on_signal { listener.disconnect }
159
+ yield listener
161
160
  end
161
+ end
162
162
 
163
- def detected_endpoint
164
- default_endpoint || Travis::Client::ORG_URI
165
- end
163
+ def default_endpoint
164
+ ENV['TRAVIS_ENDPOINT'] || config['default_endpoint']
165
+ end
166
166
 
167
- def endpoint_option
168
- return "" if org? and detected_endpoint?
169
- return " --org" if org?
170
- return " --pro" if pro?
167
+ def detected_endpoint
168
+ default_endpoint || Travis::Client::COM_URI
169
+ end
171
170
 
172
- if config['enterprise']
173
- key, _ = config['enterprise'].detect { |k,v| v.start_with? api_endpoint }
174
- return " -X" if key == "default"
175
- return " -X #{key}" if key
176
- end
171
+ def endpoint_option
172
+ return "" if pro? and detected_endpoint?
173
+ return " --org" if org?
174
+ return " --pro" if pro?
177
175
 
178
- " -e %p" % api_endpoint
176
+ if config['enterprise']
177
+ key, _ = config['enterprise'].detect { |k,v| v.start_with? api_endpoint }
178
+ return " -X" if key == "default"
179
+ return " -X #{key}" if key
179
180
  end
180
181
 
181
- def fetch_token
182
- ENV['TRAVIS_TOKEN'] || endpoint_config['access_token']
183
- end
182
+ " -e %p" % api_endpoint
183
+ end
184
+
185
+ def fetch_token
186
+ ENV['TRAVIS_TOKEN'] || endpoint_config['access_token']
187
+ end
184
188
  end
185
189
  end
186
190
  end
@@ -1,25 +1,27 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'travis/cli'
2
4
 
3
5
  module Travis
4
6
  module CLI
5
7
  class Branches < RepoCommand
6
- description "displays the most recent build for each branch"
8
+ description 'displays the most recent build for each branch'
7
9
 
8
10
  def run
9
11
  repository.last_on_branch.each do |build|
10
12
  say [
11
- color("#{build.branch_info}:".ljust(longest + 2), [:info, :bold]),
13
+ color("#{build.branch_info}:".ljust(longest + 2), %i[info bold]),
12
14
  color("##{build.number.to_s.ljust(4)} #{build.state}".ljust(16), build.color),
13
15
  build.commit.subject
14
- ].join(" ").strip + "\n"
16
+ ].join(' ').strip + "\n"
15
17
  end
16
18
  end
17
19
 
18
20
  private
19
21
 
20
- def longest
21
- repository.branches.keys.map { |b| b.size }.max
22
- end
22
+ def longest
23
+ repository.branches.keys.map { |b| b.size }.max
24
+ end
23
25
  end
24
26
  end
25
27
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'travis/cli'
2
4
 
3
5
  module Travis
@@ -16,61 +18,63 @@ module Travis
16
18
 
17
19
  warn "Deleted the following caches:\n" if delete?
18
20
  branches.each { |name, list| display_branch(name, list) }
19
- size = caches.inject(0) { |s,c| s + c.size }
20
- say "Overall size of above caches: " << formatter.file_size(size)
21
+ size = caches.inject(0) { |s, c| s + c.size }
22
+ say 'Overall size of above caches: ' << formatter.file_size(size)
21
23
  end
22
24
 
23
25
  private
24
26
 
25
- def check_caches
26
- return if caches.any?
27
- say "no caches found"
28
- exit
29
- end
27
+ def check_caches
28
+ return if caches.any?
30
29
 
31
- def display_branch(name, list)
32
- say color(name ? "On branch #{name}:" : "Global:", :important)
33
- list.each { |c| display_cache(c) }
34
- puts
35
- end
30
+ say 'no caches found'
31
+ exit
32
+ end
36
33
 
37
- def display_cache(cache)
38
- say [
39
- color(cache.slug.ljust(space), :bold),
40
- "last modified: " << formatter.time(cache.last_modified),
41
- "size: " << formatter.file_size(cache.size)
42
- ].join(" ") << "\n"
43
- end
34
+ def display_branch(name, list)
35
+ say color(name ? "On branch #{name}:" : 'Global:', :important)
36
+ list.each { |c| display_cache(c) }
37
+ puts
38
+ end
44
39
 
45
- def params
46
- params = {}
47
- params[:branch] = branch if branch?
48
- params[:match] = match if match?
49
- params
50
- end
40
+ def display_cache(cache)
41
+ say [
42
+ color(cache.slug.ljust(space), :bold),
43
+ 'last modified: ' << formatter.time(cache.last_modified),
44
+ 'size: ' << formatter.file_size(cache.size)
45
+ ].join(' ') << "\n"
46
+ end
51
47
 
52
- def caches
53
- @caches ||= drop? ? repository.delete_caches(params) : repository.caches(params)
54
- end
48
+ def params
49
+ params = {}
50
+ params[:branch] = branch if branch?
51
+ params[:match] = match if match?
52
+ params
53
+ end
55
54
 
56
- def space
57
- @space ||= caches.map(&:slug).map(&:size).max
58
- end
55
+ def caches
56
+ @caches ||= drop? ? repository.delete_caches(params) : repository.caches(params)
57
+ end
59
58
 
60
- def drop?
61
- return false unless delete?
62
- return true if force?
63
- error "not deleting caches without --force" unless interactive?
64
- error "aborted" unless danger_zone? "Do you really want to delete #{description}?"
65
- true
66
- end
59
+ def space
60
+ @space ||= caches.map(&:slug).map(&:size).max
61
+ end
62
+
63
+ def drop?
64
+ return false unless delete?
65
+ return true if force?
67
66
 
68
- def description
69
- description = color("all caches", :important)
70
- description << " on branch #{color(branch, :important)}" if branch?
71
- description << " that match #{color(match, :important)}" if match?
72
- description
73
- end
67
+ error 'not deleting caches without --force' unless interactive?
68
+ error 'aborted' unless danger_zone? "Do you really want to delete #{description}?"
69
+ true
70
+ end
71
+
72
+ def description
73
+ description = color('all caches', :important)
74
+ description << " on branch #{color(branch, :important)}" if branch?
75
+ description << " that match #{color(match, :important)}" if match?
76
+ description
77
+ end
74
78
  end
75
79
  end
76
80
  end
@@ -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 Cancel < RepoCommand
6
- description "cancels a job or build"
8
+ description 'cancels a job or build'
7
9
 
8
10
  def run(number = last_build.number)
9
11
  authenticate
@@ -11,7 +13,7 @@ module Travis
11
13
  error "could not find job or build #{repository.slug}##{number}" unless entity
12
14
  entity.cancel
13
15
 
14
- say "canceled", "#{entity.class.one} ##{entity.number} has been %s"
16
+ say 'canceled', "#{entity.class.one} ##{entity.number} has been %s"
15
17
  end
16
18
  end
17
19
  end