travis 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -67,12 +67,22 @@ module Travis
67
67
  session.find_many(Account)
68
68
  end
69
69
 
70
+ def broadcasts
71
+ session.find_many(Broadcast)
72
+ end
73
+
70
74
  def restart(entity)
71
75
  # btw, internally we call this reset, not restart, as it resets the state machine
72
76
  # but we thought that would be too confusing
73
77
  session.post_raw('/requests', "#{entity.class.one}_id" => entity.id)
74
78
  entity.reload
75
79
  end
80
+
81
+ def listen(*entities, &block)
82
+ listener = Listener.new(session)
83
+ listener.subscribe(*entities, &block)
84
+ listener.listen
85
+ end
76
86
  end
77
87
  end
78
88
  end
@@ -55,7 +55,7 @@ module Travis
55
55
 
56
56
  one :repo
57
57
  many :repos
58
- aka :repository
58
+ aka :repository, :permissions
59
59
 
60
60
  def public_key
61
61
  attributes["public_key"] ||= begin
@@ -154,6 +154,14 @@ module Travis
154
154
  set_hook(true)
155
155
  end
156
156
 
157
+ def pusher_channels
158
+ attributes['pusher_channels'] ||= if session.private_channels?
159
+ ["user-#{session.user.id}", "repo-#{id}"]
160
+ else
161
+ ["common"]
162
+ end
163
+ end
164
+
157
165
  private
158
166
 
159
167
  def state
@@ -170,6 +170,10 @@ module Travis
170
170
  instruments << block
171
171
  end
172
172
 
173
+ def private_channels?
174
+ access_token and user.channels != ['common']
175
+ end
176
+
173
177
  private
174
178
 
175
179
  def instrumented(name, *args)
@@ -182,6 +186,7 @@ module Travis
182
186
  end
183
187
 
184
188
  def create_entity(type, data)
189
+ data = { "id" => data } if Integer === data or String === data
185
190
  id = type.cast_id(data.fetch('id'))
186
191
  entity = cached(type, :id, id) { type.new(self, id) }
187
192
  entity.update_attributes(data)
@@ -4,7 +4,7 @@ module Travis
4
4
  module Client
5
5
  class User < Entity
6
6
  # @!parse attr_reader :login, :name, :email, :gravatar_id, :locale, :is_syncing, :synced_at, :correct_scopes
7
- attributes :login, :name, :email, :gravatar_id, :locale, :is_syncing, :synced_at, :correct_scopes
7
+ attributes :login, :name, :email, :gravatar_id, :locale, :is_syncing, :synced_at, :correct_scopes, :channels
8
8
  inspect_info :login
9
9
 
10
10
  one :user
@@ -19,6 +19,15 @@ module Travis
19
19
  reload
20
20
  end
21
21
 
22
+ def channels
23
+ load_attribute(:is_syncing) # dummy to trigger load, as channels might not be included
24
+ attributes['channels'] ||= ['common']
25
+ end
26
+
27
+ def repositories
28
+ attributes['repositories'] ||= session.get('/users/permissions')['permissions']
29
+ end
30
+
22
31
  alias syncing? is_syncing
23
32
  alias correct_scopes? correct_scopes
24
33
  end
@@ -0,0 +1,20 @@
1
+ module Travis
2
+ module Tools
3
+ module SafeString
4
+ extend self
5
+
6
+ def encoded(string)
7
+ return string unless string.respond_to? :encode
8
+ string.encode 'utf-8'
9
+ end
10
+
11
+ def colorized(string)
12
+ encoded(string).gsub(/[^[:print:]\e\n]/, '')
13
+ end
14
+
15
+ def clean(string)
16
+ colorized(string).gsub(/\e[^m]+m/, '')
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,3 +1,3 @@
1
1
  module Travis
2
- VERSION = '1.4.0'
2
+ VERSION = '1.5.0'
3
3
  end
@@ -35,4 +35,9 @@ describe Travis::CLI::Endpoint do
35
35
  run_cli('encrypt', 'rails/rails', 'foo').should be_success
36
36
  stderr.should match(/WARNING/)
37
37
  end
38
+
39
+ example "travis encrypt foo=foo/bar" do
40
+ run_cli("encrypt", "foo=foo/bar").should be_success
41
+ stderr.should_not match(/WARNING/)
42
+ end
38
43
  end
@@ -2,13 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  describe Travis::CLI::Open do
4
4
  example 'travis restart' do
5
- run_cli('restart').should be_success
5
+ run_cli('restart', '-t', 'token').should be_success
6
6
  $params['build_id'].should be == "4125095"
7
7
  $params['job_id'].should be_nil
8
8
  end
9
9
 
10
10
  example 'travis restart 6180.1' do
11
- run_cli('restart', '6180.1').should be_success
11
+ run_cli('restart', '6180.1', '-t', 'token').should be_success
12
12
  $params['build_id'].should be_nil
13
13
  $params['job_id'].should be == "4125096"
14
14
  end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe Travis::Client::Broadcast do
4
+ let(:session) { Travis::Client.new }
5
+ subject { session.broadcasts.first }
6
+
7
+ its(:id) { should be == 1 }
8
+ its(:message) { should be == "Hello!" }
9
+
10
+ end
@@ -715,6 +715,13 @@ module Travis
715
715
  }]}.to_json
716
716
  end
717
717
 
718
+ get '/broadcasts/' do
719
+ {"broadcasts"=>
720
+ [{'id' => 1,
721
+ 'message' => 'Hello!'
722
+ }]}.to_json
723
+ end
724
+
718
725
  post '/requests' do
719
726
  $params = params
720
727
  "{}"
@@ -2,12 +2,13 @@
2
2
  Gem::Specification.new do |s|
3
3
  # general infos
4
4
  s.name = "travis"
5
- s.version = "1.4.0"
5
+ s.version = "1.5.0"
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"
9
9
  s.license = "MIT"
10
10
  s.executables = ["travis"]
11
+ s.extensions = ["completion/extconf.rb"]
11
12
 
12
13
  # generated from git shortlog -sn
13
14
  s.authors = [
@@ -15,13 +16,15 @@ Gem::Specification.new do |s|
15
16
  "Henrik Hodne",
16
17
  "Peter Souter",
17
18
  "Max Barnash",
18
- "Mario Visic",
19
+ "Aaron Hill",
20
+ "Justin Lambert",
21
+ "Adrien Brault",
22
+ "Laurent Petit",
23
+ "Daniel Chatfield",
19
24
  "Piotr Sarnacki",
20
25
  "Rapha\xC3\xABl Pinson",
21
- "Laurent Petit",
22
- "Adrien Brault",
23
- "Justin Lambert",
24
- "Aaron Hill"
26
+ "Mario Visic",
27
+ "Benjamin Manns"
25
28
  ]
26
29
 
27
30
  # generated from git shortlog -sne
@@ -30,13 +33,15 @@ Gem::Specification.new do |s|
30
33
  "me@henrikhodne.com",
31
34
  "p.morsou@gmail.com",
32
35
  "i.am@anhero.ru",
36
+ "aa1ronham@gmail.com",
37
+ "benmanns@gmail.com",
38
+ "adrien.brault@gmail.com",
39
+ "laurent.petit@gmail.com",
40
+ "chatfielddaniel@gmail.com",
33
41
  "drogus@gmail.com",
34
42
  "raphael.pinson@camptocamp.com",
35
- "laurent.petit@gmail.com",
36
- "adrien.brault@gmail.com",
37
- "jlambert@eml.cc",
38
- "aa1ronham@gmail.com",
39
- "mario@mariovisic.com"
43
+ "mario@mariovisic.com",
44
+ "jlambert@eml.cc"
40
45
  ]
41
46
 
42
47
  # generated from git ls-files
@@ -45,10 +50,13 @@ Gem::Specification.new do |s|
45
50
  "README.md",
46
51
  "Rakefile",
47
52
  "bin/travis",
53
+ "completion/extconf.rb",
54
+ "completion/travis.sh",
48
55
  "example/org_overview.rb",
49
56
  "lib/travis.rb",
50
57
  "lib/travis/cacert.pem",
51
58
  "lib/travis/cli.rb",
59
+ "lib/travis/cli/accounts.rb",
52
60
  "lib/travis/cli/api_command.rb",
53
61
  "lib/travis/cli/branches.rb",
54
62
  "lib/travis/cli/command.rb",
@@ -77,6 +85,7 @@ Gem::Specification.new do |s|
77
85
  "lib/travis/cli/init/scala.yml",
78
86
  "lib/travis/cli/login.rb",
79
87
  "lib/travis/cli/logs.rb",
88
+ "lib/travis/cli/monitor.rb",
80
89
  "lib/travis/cli/open.rb",
81
90
  "lib/travis/cli/parser.rb",
82
91
  "lib/travis/cli/pubkey.rb",
@@ -94,11 +103,13 @@ Gem::Specification.new do |s|
94
103
  "lib/travis/client.rb",
95
104
  "lib/travis/client/account.rb",
96
105
  "lib/travis/client/artifact.rb",
106
+ "lib/travis/client/broadcast.rb",
97
107
  "lib/travis/client/build.rb",
98
108
  "lib/travis/client/commit.rb",
99
109
  "lib/travis/client/entity.rb",
100
110
  "lib/travis/client/error.rb",
101
111
  "lib/travis/client/job.rb",
112
+ "lib/travis/client/listener.rb",
102
113
  "lib/travis/client/methods.rb",
103
114
  "lib/travis/client/namespace.rb",
104
115
  "lib/travis/client/repository.rb",
@@ -108,6 +119,7 @@ Gem::Specification.new do |s|
108
119
  "lib/travis/client/worker.rb",
109
120
  "lib/travis/pro.rb",
110
121
  "lib/travis/tools/formatter.rb",
122
+ "lib/travis/tools/safe_string.rb",
111
123
  "lib/travis/tools/token_finder.rb",
112
124
  "lib/travis/version.rb",
113
125
  "spec/cli/encrypt_spec.rb",
@@ -125,6 +137,7 @@ Gem::Specification.new do |s|
125
137
  "spec/cli/version_spec.rb",
126
138
  "spec/cli/whoami_spec.rb",
127
139
  "spec/client/account_spec.rb",
140
+ "spec/client/broadcast_spec.rb",
128
141
  "spec/client/build_spec.rb",
129
142
  "spec/client/commit_spec.rb",
130
143
  "spec/client/job_spec.rb",
@@ -153,7 +166,9 @@ Gem::Specification.new do |s|
153
166
  s.add_dependency "gh"
154
167
  s.add_dependency "launchy", "~> 2.1"
155
168
  s.add_dependency "pry", "~> 0.9"
156
- s.add_dependency "typhoeus"
169
+ s.add_dependency "typhoeus", "~> 0.5"
170
+ s.add_dependency "pusher-client", "~> 0.3", ">= 0.3.1"
171
+ s.add_dependency "websocket-native", "~> 1.0"
157
172
  s.add_development_dependency "rspec", "~> 2.12"
158
173
  s.add_development_dependency "sinatra", "~> 1.3"
159
174
  s.add_development_dependency "rack-test", "~> 0.6"
metadata CHANGED
@@ -1,24 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
8
8
  - Henrik Hodne
9
9
  - Peter Souter
10
10
  - Max Barnash
11
- - Mario Visic
11
+ - Aaron Hill
12
+ - Justin Lambert
13
+ - Adrien Brault
14
+ - Laurent Petit
15
+ - Daniel Chatfield
12
16
  - Piotr Sarnacki
13
17
  - Raphaël Pinson
14
- - Laurent Petit
15
- - Adrien Brault
16
- - Justin Lambert
17
- - Aaron Hill
18
+ - Mario Visic
19
+ - Benjamin Manns
18
20
  autorequire:
19
21
  bindir: bin
20
22
  cert_chain: []
21
- date: 2013-07-26 00:00:00.000000000 Z
23
+ date: 2013-08-07 00:00:00.000000000 Z
22
24
  dependencies:
23
25
  - !ruby/object:Gem::Dependency
24
26
  name: faraday
@@ -136,16 +138,50 @@ dependencies:
136
138
  name: typhoeus
137
139
  requirement: !ruby/object:Gem::Requirement
138
140
  requirements:
141
+ - - ~>
142
+ - !ruby/object:Gem::Version
143
+ version: '0.5'
144
+ type: :runtime
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ~>
149
+ - !ruby/object:Gem::Version
150
+ version: '0.5'
151
+ - !ruby/object:Gem::Dependency
152
+ name: pusher-client
153
+ requirement: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: '0.3'
139
158
  - - '>='
140
159
  - !ruby/object:Gem::Version
141
- version: '0'
160
+ version: 0.3.1
142
161
  type: :runtime
143
162
  prerelease: false
144
163
  version_requirements: !ruby/object:Gem::Requirement
145
164
  requirements:
165
+ - - ~>
166
+ - !ruby/object:Gem::Version
167
+ version: '0.3'
146
168
  - - '>='
147
169
  - !ruby/object:Gem::Version
148
- version: '0'
170
+ version: 0.3.1
171
+ - !ruby/object:Gem::Dependency
172
+ name: websocket-native
173
+ requirement: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ~>
176
+ - !ruby/object:Gem::Version
177
+ version: '1.0'
178
+ type: :runtime
179
+ prerelease: false
180
+ version_requirements: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ~>
183
+ - !ruby/object:Gem::Version
184
+ version: '1.0'
149
185
  - !ruby/object:Gem::Dependency
150
186
  name: rspec
151
187
  requirement: !ruby/object:Gem::Requirement
@@ -194,26 +230,32 @@ email:
194
230
  - me@henrikhodne.com
195
231
  - p.morsou@gmail.com
196
232
  - i.am@anhero.ru
233
+ - aa1ronham@gmail.com
234
+ - benmanns@gmail.com
235
+ - adrien.brault@gmail.com
236
+ - laurent.petit@gmail.com
237
+ - chatfielddaniel@gmail.com
197
238
  - drogus@gmail.com
198
239
  - raphael.pinson@camptocamp.com
199
- - laurent.petit@gmail.com
200
- - adrien.brault@gmail.com
201
- - jlambert@eml.cc
202
- - aa1ronham@gmail.com
203
240
  - mario@mariovisic.com
241
+ - jlambert@eml.cc
204
242
  executables:
205
243
  - travis
206
- extensions: []
244
+ extensions:
245
+ - completion/extconf.rb
207
246
  extra_rdoc_files: []
208
247
  files:
209
248
  - LICENSE
210
249
  - README.md
211
250
  - Rakefile
212
251
  - bin/travis
252
+ - completion/extconf.rb
253
+ - completion/travis.sh
213
254
  - example/org_overview.rb
214
255
  - lib/travis.rb
215
256
  - lib/travis/cacert.pem
216
257
  - lib/travis/cli.rb
258
+ - lib/travis/cli/accounts.rb
217
259
  - lib/travis/cli/api_command.rb
218
260
  - lib/travis/cli/branches.rb
219
261
  - lib/travis/cli/command.rb
@@ -242,6 +284,7 @@ files:
242
284
  - lib/travis/cli/init/scala.yml
243
285
  - lib/travis/cli/login.rb
244
286
  - lib/travis/cli/logs.rb
287
+ - lib/travis/cli/monitor.rb
245
288
  - lib/travis/cli/open.rb
246
289
  - lib/travis/cli/parser.rb
247
290
  - lib/travis/cli/pubkey.rb
@@ -259,11 +302,13 @@ files:
259
302
  - lib/travis/client.rb
260
303
  - lib/travis/client/account.rb
261
304
  - lib/travis/client/artifact.rb
305
+ - lib/travis/client/broadcast.rb
262
306
  - lib/travis/client/build.rb
263
307
  - lib/travis/client/commit.rb
264
308
  - lib/travis/client/entity.rb
265
309
  - lib/travis/client/error.rb
266
310
  - lib/travis/client/job.rb
311
+ - lib/travis/client/listener.rb
267
312
  - lib/travis/client/methods.rb
268
313
  - lib/travis/client/namespace.rb
269
314
  - lib/travis/client/repository.rb
@@ -273,6 +318,7 @@ files:
273
318
  - lib/travis/client/worker.rb
274
319
  - lib/travis/pro.rb
275
320
  - lib/travis/tools/formatter.rb
321
+ - lib/travis/tools/safe_string.rb
276
322
  - lib/travis/tools/token_finder.rb
277
323
  - lib/travis/version.rb
278
324
  - spec/cli/encrypt_spec.rb
@@ -290,6 +336,7 @@ files:
290
336
  - spec/cli/version_spec.rb
291
337
  - spec/cli/whoami_spec.rb
292
338
  - spec/client/account_spec.rb
339
+ - spec/client/broadcast_spec.rb
293
340
  - spec/client/build_spec.rb
294
341
  - spec/client/commit_spec.rb
295
342
  - spec/client/job_spec.rb