travis 1.6.18.travis.606.5 → 1.6.18.travis.607.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTRhNDEzODVmZWZjYjhmMDBiZmY2ZjIyYzY3MDJhZTI5MDdjOTAzOQ==
4
+ ZjI0YmE3ZTI5NDJjMWYwMjE2ZWE2YjdlNjNjYzcyMDYxYTA0Yzg4YQ==
5
5
  data.tar.gz: !binary |-
6
- MDQxNjM1YWU3NWRiNzVkMWFiY2Q0ODdjMmNmZTYzNzVlZmQ1ZDhhMg==
6
+ YzVmYjU5M2YyYzFjZWVlNDgxNTgwMzg1ZjA5MDAzOTA5NGQzNWUwZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Zjk4Nzk0NDRhMDVlOWQ4YTI0Y2U5NmExOTQyN2FhZGViYjZhNGIyZDg3M2Iy
10
- MjViMzZmMzBmODBkOGM0NmFjZjAzYmVmMjc0MzdmNWE2ZmI1NzRkNDYzNzAz
11
- MTYwNzg2NzNlMDAxOTdhMzlkY2ZmYTI0MDNlNTM2NTI5ZmQ4YTY=
9
+ MzM4YTUyMzViZjJhZWNiODQzYzNlOTg0ZDI5YWVmYzJmMTZjZmFjNWEzZTNi
10
+ M2NmMGEyN2JjOTc2NTI3YjQ5MWQwODc1OTMwZGFmZmViODk2YmU4MzQxMGE4
11
+ MzIyMjk1YzMyODJlZDU5ODY2YWZjODgzMDNkZDYzNzI4NzQwOTc=
12
12
  data.tar.gz: !binary |-
13
- YTVjY2U1YThmMTdjY2RmYzYxOGVmZDEzYjI4ZDViOGY1NjY0NTMwMmE4OTkw
14
- ZjVhYTg0NTc2NTdlOWMyMDJmYjJhMTlkMzQwZmYwYWQ4ZWVhNjJjZWQ0ZjBm
15
- NWVkMzUwMDhkNTI1ODQ2YTEwM2JiNWMzN2RlNDAyYzMzMmYxNjg=
13
+ OTc1YTJhZjE3Nzg4NDM0YjllNjcyOTE2OGJjMGJjN2Q5NjBiZTE1MzI0NjA1
14
+ ZDE0ZjczNzEyNTM5MDE4ZjJkNzgxOWU5YmZlZmNlMDZjMjRmZGFjZTUyY2Iw
15
+ NTY3ZDZkZjgwNjI4ZDExNTEwMWRjODAwMmU3NWY1ZjlhN2FhNjY=
@@ -0,0 +1,3 @@
1
+ require 'travis'
2
+ require 'travis/client/auto_login'
3
+ Travis::Client::AutoLogin.new(Travis).authenticate
@@ -0,0 +1,45 @@
1
+ require 'travis/client'
2
+ require 'travis/tools/github'
3
+ require 'yaml'
4
+
5
+ module Travis
6
+ module Client
7
+ class AutoLogin
8
+ NoTokenError = Class.new(RuntimeError)
9
+ attr_reader :session
10
+
11
+ def initialize(session, options = {})
12
+ @session = session.session
13
+ config_path = ENV.fetch('TRAVIS_CONFIG_PATH') { File.expand_path('.travis', Dir.home) }
14
+ @config_file = options.fetch(:config_file) { File.expand_path('config.yml', config_path) }
15
+ @auto_token = options.fetch(:auto_token) { true }
16
+ @raise = options.fetch(:raise) { true }
17
+ end
18
+
19
+ def authenticate
20
+ return unless session.access_token = cli_token
21
+ github.with_token { |t| session.github_auth(t) }
22
+ end
23
+
24
+ def github
25
+ @github ||= Tools::Github.new(session.config['github']) do |g|
26
+ g.explode = true
27
+ g.manual_login = false
28
+ g.auto_token = @auto_token
29
+ g.after_tokens = proc { raise NoTokenError, "no suitable github token found" } if @raise
30
+ end
31
+ end
32
+
33
+ def cli_token
34
+ result = cli_config
35
+ result &&= result['endpoints']
36
+ result &&= result[session.uri]
37
+ result && result['access_token']
38
+ end
39
+
40
+ def cli_config
41
+ @cli_config ||= YAML.load_file(@config_file) if File.exist? @config_file
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,3 @@
1
+ require 'travis/pro'
2
+ require 'travis/client/auto_login'
3
+ Travis::Client::AutoLogin.new(Travis::Pro).authenticate
data/travis.gemspec CHANGED
@@ -121,6 +121,7 @@ Gem::Specification.new do |s|
121
121
  "examples/pro_auth.rb",
122
122
  "examples/stream.rb",
123
123
  "lib/travis.rb",
124
+ "lib/travis/auto_login.rb",
124
125
  "lib/travis/cli.rb",
125
126
  "lib/travis/cli/accounts.rb",
126
127
  "lib/travis/cli/api_command.rb",
@@ -190,6 +191,7 @@ Gem::Specification.new do |s|
190
191
  "lib/travis/client/account.rb",
191
192
  "lib/travis/client/annotation.rb",
192
193
  "lib/travis/client/artifact.rb",
194
+ "lib/travis/client/auto_login.rb",
193
195
  "lib/travis/client/broadcast.rb",
194
196
  "lib/travis/client/build.rb",
195
197
  "lib/travis/client/cache.rb",
@@ -215,6 +217,7 @@ Gem::Specification.new do |s|
215
217
  "lib/travis/client/user.rb",
216
218
  "lib/travis/client/weak_entity.rb",
217
219
  "lib/travis/pro.rb",
220
+ "lib/travis/pro/auto_login.rb",
218
221
  "lib/travis/tools/assets.rb",
219
222
  "lib/travis/tools/completion.rb",
220
223
  "lib/travis/tools/formatter.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.18.travis.606.5
4
+ version: 1.6.18.travis.607.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
@@ -318,6 +318,7 @@ files:
318
318
  - examples/pro_auth.rb
319
319
  - examples/stream.rb
320
320
  - lib/travis.rb
321
+ - lib/travis/auto_login.rb
321
322
  - lib/travis/cli.rb
322
323
  - lib/travis/cli/accounts.rb
323
324
  - lib/travis/cli/api_command.rb
@@ -387,6 +388,7 @@ files:
387
388
  - lib/travis/client/account.rb
388
389
  - lib/travis/client/annotation.rb
389
390
  - lib/travis/client/artifact.rb
391
+ - lib/travis/client/auto_login.rb
390
392
  - lib/travis/client/broadcast.rb
391
393
  - lib/travis/client/build.rb
392
394
  - lib/travis/client/cache.rb
@@ -412,6 +414,7 @@ files:
412
414
  - lib/travis/client/user.rb
413
415
  - lib/travis/client/weak_entity.rb
414
416
  - lib/travis/pro.rb
417
+ - lib/travis/pro/auto_login.rb
415
418
  - lib/travis/tools/assets.rb
416
419
  - lib/travis/tools/completion.rb
417
420
  - lib/travis/tools/formatter.rb