travis 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -14,6 +14,7 @@ The [travis gem](https://rubygems.org/gems/travis) includes both a command line
14
14
  * [`login`](#login)
15
15
  * [`raw`](#raw)
16
16
  * [`sync`](#sync)
17
+ * [`token`](#token)
17
18
  * [`whatsup`](#whatsup)
18
19
  * [`whoami`](#whoami)
19
20
  * [Repository Commands](#repository-commands)
@@ -191,6 +192,22 @@ If you just want to know if your account is being synchronized right now, use `-
191
192
  $ travis sync --check
192
193
  rkh is currently syncing
193
194
 
195
+
196
+
197
+ #### `token`
198
+
199
+ The use the Ruby library you will need to obtain an access token first. To do this simply run the `travis login` command. Once logged in you can check your token with `travis token`:
200
+
201
+ $ travis token
202
+ Your access token is super-secret
203
+
204
+ You can use that token for instance with curl:
205
+
206
+ $ curl -H "Authorization: token $(travis token)" https://api.travis-ci.org/users/
207
+ {"login":"rkh","name":"Konstantin Haase","email":"konstantin.haase@gmail.com","gravatar_id":"5c2b452f6eea4a6d84c105ebd971d2a4","locale":"en","is_syncing":false,"synced_at":"2013-01-21T20:31:06Z"}
208
+
209
+ Note that if you just need it for looking at API payloads, that we also have the [`raw`][#raw] command.
210
+
194
211
  #### `whatsup`
195
212
 
196
213
  It's just a tiny feature, but it allows you to take a look at repositories that have recently seen some action (ie the left hand sidebar on [travis-ci.org](https://travis-ci.org)):
@@ -530,6 +547,8 @@ client = Travis::Client.new
530
547
  puts "Hello #{client.user.name}"
531
548
  ```
532
549
 
550
+ See [the token command](#token) for obtaining the access token used by the CLI.
551
+
533
552
  If you don't have an access token for Travis CI, you can use a GitHub access token to get one:
534
553
 
535
554
  ``` ruby
@@ -845,6 +864,12 @@ If you have the old `travis-cli` gem installed, you should `gem uninstall travis
845
864
 
846
865
  ## Version History
847
866
 
867
+ **v1.1.2** (January 24, 2013)
868
+
869
+ * `token` command
870
+ * no longer wrap $stdin in delegator (caused bug on some Linux systems)
871
+ * correctly detect when running on Windows, even on JRuby
872
+
848
873
  **v1.1.1** (January 22, 2013)
849
874
 
850
875
  * Make pry a runtime dependency rather than a development dependency.
@@ -3,7 +3,6 @@ require 'travis/tools/formatter'
3
3
 
4
4
  require 'highline'
5
5
  require 'forwardable'
6
- require 'delegate'
7
6
  require 'yaml'
8
7
 
9
8
  module Travis
@@ -52,33 +51,31 @@ module Travis
52
51
  define_method(name) {}
53
52
  end
54
53
 
55
- attr_accessor :arguments, :config, :terminal, :force_interactive, :formatter
54
+ attr_accessor :arguments, :config, :force_interactive, :formatter
55
+ attr_reader :input, :output
56
56
 
57
57
  def initialize(options = {})
58
- @formatter = Travis::Tools::Formatter.new
59
- @output = SimpleDelegator.new($stdout)
60
- @input = SimpleDelegator.new($stdin)
61
- @terminal = HighLine.new(@input, @output)
58
+ @formatter = Travis::Tools::Formatter.new
59
+ self.output = $stdout
60
+ self.input = $stdin
62
61
  options.each do |key, value|
63
62
  public_send("#{key}=", value) if respond_to? "#{key}="
64
63
  end
65
64
  @arguments ||= []
66
65
  end
67
66
 
68
- def input
69
- @input.__getobj__
67
+ def terminal
68
+ @terminal ||= HighLine.new(input, output)
70
69
  end
71
70
 
72
71
  def input=(io)
73
- @input.__setobj__(io)
74
- end
75
-
76
- def output
77
- @output.__getobj__
72
+ @terminal = nil
73
+ @input = io
78
74
  end
79
75
 
80
76
  def output=(io)
81
- @output.__setobj__(io)
77
+ @terminal = nil
78
+ @output = io
82
79
  end
83
80
 
84
81
  def write_to(io)
@@ -0,0 +1,12 @@
1
+ require 'travis/cli'
2
+
3
+ module Travis
4
+ module CLI
5
+ class Token < ApiCommand
6
+ def run
7
+ error "not logged in, please run #{command("login#{endpoint_option}")}" if access_token.nil?
8
+ say access_token, "Your access token is %s"
9
+ end
10
+ end
11
+ end
12
+ end
data/lib/travis/cli.rb CHANGED
@@ -14,6 +14,7 @@ GH.set(:ssl => Travis::Client::Session::SSL_OPTIONS)
14
14
 
15
15
  module Travis
16
16
  module CLI
17
+ autoload :Token, 'travis/cli/token'
17
18
  autoload :ApiCommand, 'travis/cli/api_command'
18
19
  autoload :Command, 'travis/cli/command'
19
20
  autoload :Console, 'travis/cli/console'
@@ -40,7 +41,7 @@ module Travis
40
41
  extend self
41
42
 
42
43
  def windows?
43
- RUBY_PLATFORM =~ /mswin|mingw/
44
+ File::ALT_SEPARATOR == "\\"
44
45
  end
45
46
 
46
47
  def run(*args)
@@ -1,3 +1,3 @@
1
1
  module Travis
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Travis::CLI::Token do
4
+ example "travis token (access token set)" do
5
+ run_cli('token', '-t', 'super-secret').should be_success
6
+ stdout.should == "super-secret\n"
7
+ stderr.should be_empty
8
+ end
9
+
10
+ example "travis token -i (access token set)" do
11
+ run_cli('token', '-it', 'super-secret').should be_success
12
+ stdout.should == "Your access token is super-secret\n"
13
+ stderr.should be_empty
14
+ end
15
+
16
+ example 'travis token (no access token set)' do
17
+ run_cli('token').should_not be_success
18
+
19
+ stdout.should be_empty
20
+ stderr.should == "not logged in, please run #$0 login\n"
21
+ end
22
+ end
data/travis.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
  Gem::Specification.new do |s|
3
3
  # general infos
4
4
  s.name = "travis"
5
- s.version = "1.1.1"
5
+ s.version = "1.1.2"
6
6
  s.description = "CLI and Ruby client library for Travis CI"
7
7
  s.homepage = "https://github.com/travis-ci/travis"
8
8
  s.summary = "Travis CI client"
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
14
14
  "Konstantin Haase",
15
15
  "Henrik Hodne",
16
16
  "Adrien Brault",
17
+ "Mario Visic",
17
18
  "Piotr Sarnacki"
18
19
  ]
19
20
 
@@ -22,6 +23,7 @@ Gem::Specification.new do |s|
22
23
  "konstantin.mailinglists@googlemail.com",
23
24
  "me@henrikhodne.com",
24
25
  "adrien.brault@gmail.com",
26
+ "mario@mariovisic.com",
25
27
  "drogus@gmail.com"
26
28
  ]
27
29
 
@@ -54,6 +56,7 @@ Gem::Specification.new do |s|
54
56
  "lib/travis/cli/show.rb",
55
57
  "lib/travis/cli/status.rb",
56
58
  "lib/travis/cli/sync.rb",
59
+ "lib/travis/cli/token.rb",
57
60
  "lib/travis/cli/version.rb",
58
61
  "lib/travis/cli/whatsup.rb",
59
62
  "lib/travis/cli/whoami.rb",
@@ -84,6 +87,7 @@ Gem::Specification.new do |s|
84
87
  "spec/cli/restart_spec.rb",
85
88
  "spec/cli/show_spec.rb",
86
89
  "spec/cli/status_spec.rb",
90
+ "spec/cli/token_spec.rb",
87
91
  "spec/cli/version_spec.rb",
88
92
  "spec/cli/whoami_spec.rb",
89
93
  "spec/client/build_spec.rb",
metadata CHANGED
@@ -1,18 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Konstantin Haase
9
9
  - Henrik Hodne
10
10
  - Adrien Brault
11
+ - Mario Visic
11
12
  - Piotr Sarnacki
12
13
  autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
- date: 2013-01-22 00:00:00.000000000 Z
16
+ date: 2013-01-24 00:00:00.000000000 Z
16
17
  dependencies:
17
18
  - !ruby/object:Gem::Dependency
18
19
  name: faraday
@@ -195,6 +196,7 @@ email:
195
196
  - konstantin.mailinglists@googlemail.com
196
197
  - me@henrikhodne.com
197
198
  - adrien.brault@gmail.com
199
+ - mario@mariovisic.com
198
200
  - drogus@gmail.com
199
201
  executables:
200
202
  - travis
@@ -228,6 +230,7 @@ files:
228
230
  - lib/travis/cli/show.rb
229
231
  - lib/travis/cli/status.rb
230
232
  - lib/travis/cli/sync.rb
233
+ - lib/travis/cli/token.rb
231
234
  - lib/travis/cli/version.rb
232
235
  - lib/travis/cli/whatsup.rb
233
236
  - lib/travis/cli/whoami.rb
@@ -258,6 +261,7 @@ files:
258
261
  - spec/cli/restart_spec.rb
259
262
  - spec/cli/show_spec.rb
260
263
  - spec/cli/status_spec.rb
264
+ - spec/cli/token_spec.rb
261
265
  - spec/cli/version_spec.rb
262
266
  - spec/cli/whoami_spec.rb
263
267
  - spec/client/build_spec.rb