travis 1.11.1 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +34 -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 +11 -9
  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/regenerate_token.rb +15 -0
  35. data/lib/travis/cli/remove_token.rb +15 -0
  36. data/lib/travis/cli/repo_command.rb +123 -112
  37. data/lib/travis/cli/report.rb +40 -33
  38. data/lib/travis/cli/repos.rb +14 -9
  39. data/lib/travis/cli/requests.rb +13 -12
  40. data/lib/travis/cli/restart.rb +4 -2
  41. data/lib/travis/cli/settings.rb +41 -35
  42. data/lib/travis/cli/setup/anynines.rb +7 -6
  43. data/lib/travis/cli/setup/appfog.rb +6 -4
  44. data/lib/travis/cli/setup/artifacts.rb +7 -5
  45. data/lib/travis/cli/setup/biicode.rb +6 -4
  46. data/lib/travis/cli/setup/cloud_66.rb +6 -4
  47. data/lib/travis/cli/setup/cloud_control.rb +8 -6
  48. data/lib/travis/cli/setup/cloud_files.rb +7 -5
  49. data/lib/travis/cli/setup/cloud_foundry.rb +9 -7
  50. data/lib/travis/cli/setup/code_deploy.rb +33 -29
  51. data/lib/travis/cli/setup/deis.rb +8 -6
  52. data/lib/travis/cli/setup/divshot.rb +20 -18
  53. data/lib/travis/cli/setup/elastic_beanstalk.rb +10 -8
  54. data/lib/travis/cli/setup/engine_yard.rb +9 -7
  55. data/lib/travis/cli/setup/gcs.rb +9 -7
  56. data/lib/travis/cli/setup/hackage.rb +6 -4
  57. data/lib/travis/cli/setup/heroku.rb +10 -4
  58. data/lib/travis/cli/setup/modulus.rb +5 -3
  59. data/lib/travis/cli/setup/ninefold.rb +7 -5
  60. data/lib/travis/cli/setup/nodejitsu.rb +6 -4
  61. data/lib/travis/cli/setup/npm.rb +6 -4
  62. data/lib/travis/cli/setup/open_shift.rb +8 -6
  63. data/lib/travis/cli/setup/opsworks.rb +24 -22
  64. data/lib/travis/cli/setup/pypi.rb +7 -5
  65. data/lib/travis/cli/setup/releases.rb +6 -6
  66. data/lib/travis/cli/setup/ruby_gems.rb +7 -5
  67. data/lib/travis/cli/setup/s3.rb +12 -8
  68. data/lib/travis/cli/setup/sauce_connect.rb +7 -5
  69. data/lib/travis/cli/setup/service.rb +36 -25
  70. data/lib/travis/cli/setup.rb +7 -3
  71. data/lib/travis/cli/show.rb +10 -8
  72. data/lib/travis/cli/sshkey.rb +31 -27
  73. data/lib/travis/cli/status.rb +5 -3
  74. data/lib/travis/cli/sync.rb +9 -7
  75. data/lib/travis/cli/token.rb +4 -2
  76. data/lib/travis/cli/version.rb +4 -3
  77. data/lib/travis/cli/whatsup.rb +10 -8
  78. data/lib/travis/cli/whoami.rb +2 -2
  79. data/lib/travis/cli.rb +81 -76
  80. data/lib/travis/client/account.rb +8 -6
  81. data/lib/travis/client/artifact.rb +16 -12
  82. data/lib/travis/client/auto_login.rb +7 -4
  83. data/lib/travis/client/broadcast.rb +2 -0
  84. data/lib/travis/client/build.rb +7 -3
  85. data/lib/travis/client/cache.rb +4 -2
  86. data/lib/travis/client/commit.rb +5 -2
  87. data/lib/travis/client/entity.rb +50 -46
  88. data/lib/travis/client/env_var.rb +13 -8
  89. data/lib/travis/client/error.rb +5 -3
  90. data/lib/travis/client/has_uuid.rb +3 -1
  91. data/lib/travis/client/job.rb +8 -3
  92. data/lib/travis/client/lint_result.rb +2 -0
  93. data/lib/travis/client/listener.rb +70 -55
  94. data/lib/travis/client/methods.rb +26 -5
  95. data/lib/travis/client/namespace.rb +20 -16
  96. data/lib/travis/client/not_loadable.rb +3 -1
  97. data/lib/travis/client/repository.rb +34 -22
  98. data/lib/travis/client/request.rb +5 -2
  99. data/lib/travis/client/restartable.rb +2 -0
  100. data/lib/travis/client/session.rb +118 -88
  101. data/lib/travis/client/settings.rb +8 -3
  102. data/lib/travis/client/singleton_setting.rb +2 -0
  103. data/lib/travis/client/ssh_key.rb +2 -0
  104. data/lib/travis/client/states.rb +8 -6
  105. data/lib/travis/client/user.rb +2 -0
  106. data/lib/travis/client/weak_entity.rb +6 -3
  107. data/lib/travis/client.rb +4 -1
  108. data/lib/travis/pro/auto_login.rb +2 -0
  109. data/lib/travis/pro.rb +2 -0
  110. data/lib/travis/tools/assets.rb +6 -3
  111. data/lib/travis/tools/completion.rb +10 -6
  112. data/lib/travis/tools/formatter.rb +20 -14
  113. data/lib/travis/tools/github.rb +59 -49
  114. data/lib/travis/tools/notification.rb +18 -13
  115. data/lib/travis/tools/safe_string.rb +4 -1
  116. data/lib/travis/tools/ssl_key.rb +5 -2
  117. data/lib/travis/tools/system.rb +11 -6
  118. data/lib/travis/version.rb +3 -1
  119. data/lib/travis.rb +3 -1
  120. data/spec/cli/api_command_spec.rb +11 -8
  121. data/spec/cli/cancel_spec.rb +2 -4
  122. data/spec/cli/encrypt_file_spec.rb +9 -7
  123. data/spec/cli/encrypt_spec.rb +19 -17
  124. data/spec/cli/endpoint_spec.rb +12 -10
  125. data/spec/cli/help_spec.rb +14 -12
  126. data/spec/cli/history_spec.rb +2 -0
  127. data/spec/cli/init_spec.rb +35 -33
  128. data/spec/cli/logs_spec.rb +2 -0
  129. data/spec/cli/open_spec.rb +6 -4
  130. data/spec/cli/repo_command_spec.rb +8 -4
  131. data/spec/cli/restart_spec.rb +2 -4
  132. data/spec/cli/setup/service_spec.rb +17 -18
  133. data/spec/cli/setup_spec.rb +2 -4
  134. data/spec/cli/show_spec.rb +4 -2
  135. data/spec/cli/status_spec.rb +7 -5
  136. data/spec/cli/token_spec.rb +7 -5
  137. data/spec/cli/version_spec.rb +2 -0
  138. data/spec/cli/whoami_spec.rb +9 -7
  139. data/spec/client/account_spec.rb +28 -20
  140. data/spec/client/auto_login_spec.rb +12 -9
  141. data/spec/client/broadcast_spec.rb +5 -3
  142. data/spec/client/build_spec.rb +28 -24
  143. data/spec/client/commit_spec.rb +17 -14
  144. data/spec/client/job_spec.rb +27 -23
  145. data/spec/client/methods_spec.rb +8 -4
  146. data/spec/client/namespace_spec.rb +8 -4
  147. data/spec/client/repository_spec.rb +33 -30
  148. data/spec/client/session_spec.rb +71 -67
  149. data/spec/client/user_spec.rb +13 -10
  150. data/spec/client_spec.rb +6 -4
  151. data/spec/pro_spec.rb +5 -3
  152. data/spec/spec_helper.rb +3 -1
  153. data/spec/support/fake_api.rb +662 -662
  154. data/spec/support/fake_github.rb +6 -3
  155. data/spec/support/helpers.rb +13 -8
  156. data/spec/travis_spec.rb +5 -3
  157. data/travis.gemspec +402 -399
  158. metadata +31 -49
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23b3dc0540b49670c431ffd568978ef91fa3b35183d6ef538e6221997156f1c3
4
- data.tar.gz: 8567e7548e471e46db65b1d2a4cbef54077ac4a7564c2cf54f67e0df79a3d299
3
+ metadata.gz: 998fcdcdfd03492820c29d028608bd6ad94a18017577afa5b7900ca43b8ec007
4
+ data.tar.gz: b189770e1539200697d0e57f8b100fffda04d11990e089bcd89a568e80b233bb
5
5
  SHA512:
6
- metadata.gz: 0f770678a593532d320783fb156685d980e81471c7d9d7327b89f181a881c1dc294fa40c3bd0632b38cbda0561688ae5365b312ab0b5a85623f32eb258fb469a
7
- data.tar.gz: 20ced0690a572d0e8cab783661836422eae1a14c47641bb70317920bd015bbdb63cfe6ec2880e82c25e856ea3eea89bbe7ab9cf17fc6bf31cb2bfbf9f7ca2fb4
6
+ metadata.gz: ad73d2de98f9998c273daff53ac40491db37044fff1ca395aac795a61cce1f3d6bf981936556483d3a933334f14d428e50a7504991516fe55ed5f0b06ef97593
7
+ data.tar.gz: fba8991abd529d94c1977232727b61015d10744a9c0b617508702a53ad7e30dd4e44b0c1607ccfeb779a0e20d7a41b89642d80398ddfd5463ff3447aa0af8681
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
 
@@ -17,6 +17,8 @@ The [travis gem](https://rubygems.org/gems/travis) includes both a [command line
17
17
  * [`login`](#login) - authenticates against the API and stores the token
18
18
  * [`monitor`](#monitor) - live monitor for what's going on
19
19
  * [`raw`](#raw) - makes an (authenticated) API call and prints out the result
20
+ * [`regenerate-token`](#regenerate-token) - regenerates the stored API token
21
+ * [`remove-token`](#remove-token) - deletes the stored API token
20
22
  * [`report`](#report) - generates a report useful for filing issues
21
23
  * [`repos`](#repos) - lists repositories the user has certain permissions on
22
24
  * [`sync`](#sync) - triggers a new sync with GitHub
@@ -81,7 +83,7 @@ The [travis gem](https://rubygems.org/gems/travis) includes both a [command line
81
83
 
82
84
  ## Command Line Client
83
85
 
84
- ![](http://about.travis-ci.org/images/new-tricks.png)
86
+ ![](https://docs.travis-ci.com/images/new-tricks.png)
85
87
 
86
88
  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
89
 
@@ -329,6 +331,24 @@ $ travis raw /repos/travis-ci/travis.rb
329
331
 
330
332
  Use `--json` if you'd rather prefer the output to be JSON.
331
333
 
334
+ #### `regenerate-token`
335
+
336
+ This command is used to regenerate the stored API token. New token will be stored in the config.
337
+
338
+ ``` console
339
+ $ travis regenerate-token
340
+ Successfully regenerated the token!
341
+ ```
342
+
343
+ #### `remove-token`
344
+
345
+ This command is used to remove the access token from the config, log out the user and disable the token.
346
+
347
+ ``` console
348
+ $ travis remove-token
349
+ Successfully removed the access token!
350
+ ```
351
+
332
352
  #### `report`
333
353
 
334
354
  When inspecting a bug or reporting an issue, it can be handy to include a report about the system and configuration used for running a command.
@@ -2066,6 +2086,17 @@ See https://github.com/travis-ci/travis.rb/issues/768#issuecomment-700220351 for
2066
2086
 
2067
2087
  ## Version History
2068
2088
 
2089
+ ### 1.13.0
2090
+
2091
+ * Default API endpoint switched https://github.com/travis-ci/travis.rb/pull/840
2092
+ * Api key regenerate https://github.com/travis-ci/travis.rb/pull/842
2093
+
2094
+ ### 1.12.0
2095
+
2096
+ * Upgraded ruby version to 3.2 https://github.com/travis-ci/travis.rb/pull/848
2097
+ * Added API Key Reset Capabilities https://github.com/travis-ci/travis.rb/pull/842
2098
+ * Fix travis lint issues https://github.com/travis-ci/travis.rb/pull/840
2099
+
2069
2100
  ### 1.11.1
2070
2101
 
2071
2102
  * 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