travis 1.5.6.travis.297.4 → 1.5.6.travis.299.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +8 -0
- data/lib/travis/client/account.rb +29 -1
- data/lib/travis/client/entity.rb +12 -1
- data/lib/travis/client/error.rb +3 -0
- data/lib/travis/client/methods.rb +6 -0
- data/lib/travis/client/repository.rb +12 -0
- data/lib/travis/client/session.rb +6 -6
- data/lib/travis/client/worker.rb +4 -0
- data/spec/client/account_spec.rb +28 -8
- data/spec/client/repository_spec.rb +5 -1
- data/spec/support/fake_api.rb +1 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjA0ZDQ3MjhlOGUzMzY3NmEzY2MxNTI3ZTZhNzg0YTkwM2Q3MjQ3YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTUxNjZiNTcxMjg1Y2VkZWQ3OGRmOWIwM2I2NjdlMTllM2FkZDY3Nw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjNjZTI4MWM4ZGJhNzY0MjFjZDc2ZDA4NmQ1NzliYzFjYjI2OTU0NmQ2OTVj
|
10
|
+
NTIxNTIzNjY2OTIzZmJjZWU1Zjg0MDdiMDcwNTVlMWQ1NjBlYzgxN2Q2ZTYy
|
11
|
+
NTY4ZGM2MWZiNTU3Zjg5ZjZhZGQzZDU3Y2FkZDg2NmQyYTBkNGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODk1YTBmZWRjMTg2NjI1NGM2ZTI5MzY0Yzg2ZTI4Mjk3ODYzMjRkZjEzYzRi
|
14
|
+
Y2MzNmUzODU5ZDNjN2M5M2Q5MGE0OGExNWUwNzhhMWIzMTcxZjI5NzNiYTEy
|
15
|
+
OTk2YTBmYWEzYjViOGRjMDVkOTIwMmJjODNlMjRhMzY1NTdlMWI=
|
data/README.md
CHANGED
@@ -897,6 +897,9 @@ Travis::Repository.find('rails/rails') # find by slug
|
|
897
897
|
Travis::Repository.find(891) # find by id
|
898
898
|
Travis::Repository.find_all(owner_name: 'rails') # all repos in the rails organization
|
899
899
|
Travis::Repository.current # repos that see some action right now
|
900
|
+
|
901
|
+
# all repos with the same owner as the repo with id 891
|
902
|
+
Travis::Repository.find(891).owner.repositories
|
900
903
|
```
|
901
904
|
|
902
905
|
Once you have a repository, you can for instance encrypt some strings with its private key:
|
@@ -1250,6 +1253,11 @@ If you have the old `travis-cli` gem installed, you should `gem uninstall travis
|
|
1250
1253
|
|
1251
1254
|
* Use new API for fetching a single branch for Repository#branch. This also circumvents the 25 branches limit.
|
1252
1255
|
* Start publishing gem prereleases after successful builds.
|
1256
|
+
* Add `account` method for fetching a single account to `Travis::Client::Methods`.
|
1257
|
+
* Allow creating account objects for any account, not just these the user is part of. Add `Account#member?` to check for membership.
|
1258
|
+
* Add `Account#repositories` to load all repos for a given account.
|
1259
|
+
* Add `Repository#owner_name` and `Repository#owner` to load the account owning a repository.
|
1260
|
+
* Add `Repository#member?` to check if the current user is a member of a repository.
|
1253
1261
|
|
1254
1262
|
**1.5.5** (October 2, 2013)
|
1255
1263
|
|
@@ -9,10 +9,38 @@ module Travis
|
|
9
9
|
many :accounts
|
10
10
|
|
11
11
|
inspect_info :login
|
12
|
+
id_field :login
|
13
|
+
|
14
|
+
def self.cast_id(id)
|
15
|
+
String(id)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.id?(object)
|
19
|
+
object.is_a? String
|
20
|
+
end
|
12
21
|
|
13
22
|
def subscribed
|
14
|
-
|
23
|
+
load_attribute('subscribed') { true } if member?
|
24
|
+
end
|
25
|
+
|
26
|
+
def repos_count
|
27
|
+
load_attribute("repos_count") { repositories.count }
|
15
28
|
end
|
29
|
+
|
30
|
+
def repositories
|
31
|
+
attributes['repositories'] ||= session.repos(:owner_name => login)
|
32
|
+
end
|
33
|
+
|
34
|
+
def member?
|
35
|
+
session.accounts.include? self
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def load_attribute(name, &block)
|
41
|
+
session.accounts if missing? name
|
42
|
+
block ? attributes.fetch(name.to_s, &block) : attributes[name.to_s]
|
43
|
+
end
|
16
44
|
end
|
17
45
|
end
|
18
46
|
end
|
data/lib/travis/client/entity.rb
CHANGED
@@ -18,7 +18,7 @@ module Travis
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.subclass_for(key)
|
21
|
-
MAP.fetch(key)
|
21
|
+
MAP.fetch(key.to_s)
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.aka(*names)
|
@@ -73,6 +73,17 @@ module Travis
|
|
73
73
|
Integer(id)
|
74
74
|
end
|
75
75
|
|
76
|
+
def self.id?(object)
|
77
|
+
object.is_a? Integer
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.id_field(key = nil)
|
81
|
+
@id_field = key.to_s if key
|
82
|
+
@id_field || superclass.id_field
|
83
|
+
end
|
84
|
+
|
85
|
+
id_field :id
|
86
|
+
|
76
87
|
def initialize(session, id)
|
77
88
|
@attributes = {}
|
78
89
|
@session = session
|
data/lib/travis/client/error.rb
CHANGED
@@ -166,6 +166,18 @@ module Travis
|
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
169
|
+
def member?
|
170
|
+
session.user.repositories.include? self
|
171
|
+
end
|
172
|
+
|
173
|
+
def owner_name
|
174
|
+
slug[/^[^\/]+/]
|
175
|
+
end
|
176
|
+
|
177
|
+
def owner
|
178
|
+
session.account(owner_name)
|
179
|
+
end
|
180
|
+
|
169
181
|
private
|
170
182
|
|
171
183
|
def state
|
@@ -83,18 +83,18 @@ module Travis
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def find_one(entity, id = nil)
|
86
|
-
raise Travis::Error, "cannot fetch #{entity}" unless entity.respond_to?(:many) and entity.many
|
87
|
-
return create_entity(entity,
|
86
|
+
raise Travis::Client::Error, "cannot fetch #{entity}" unless entity.respond_to?(:many) and entity.many
|
87
|
+
return create_entity(entity, entity.id_field => id) if entity.id? id
|
88
88
|
cached(entity, :by, id) { fetch_one(entity, id) }
|
89
89
|
end
|
90
90
|
|
91
91
|
def find_many(entity, args = {})
|
92
|
-
raise Travis::Error, "cannot fetch #{entity}" unless entity.respond_to?(:many) and entity.many
|
92
|
+
raise Travis::Client::Error, "cannot fetch #{entity}" unless entity.respond_to?(:many) and entity.many
|
93
93
|
cached(entity, :many, args) { fetch_many(entity, args) }
|
94
94
|
end
|
95
95
|
|
96
96
|
def find_one_or_many(entity, args = nil)
|
97
|
-
raise Travis::Error, "cannot fetch #{entity}" unless entity.respond_to?(:many) and entity.many
|
97
|
+
raise Travis::Client::Error, "cannot fetch #{entity}" unless entity.respond_to?(:many) and entity.many
|
98
98
|
cached(entity, :one_or_many, args) do
|
99
99
|
path = "/#{entity.many}"
|
100
100
|
path, args = "#{path}/#{args}", {} unless args.is_a? Hash
|
@@ -213,8 +213,8 @@ module Travis
|
|
213
213
|
end
|
214
214
|
|
215
215
|
def create_entity(type, data)
|
216
|
-
data = {
|
217
|
-
id = type.cast_id(data.fetch(
|
216
|
+
data = { type.id_field => data } if type.id? data
|
217
|
+
id = type.cast_id(data.fetch(type.id_field))
|
218
218
|
entity = cached(type, :id, id) { type.new(self, id) }
|
219
219
|
entity.update_attributes(data)
|
220
220
|
entity
|
data/lib/travis/client/worker.rb
CHANGED
data/spec/client/account_spec.rb
CHANGED
@@ -1,12 +1,32 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Travis::Client::Account do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
context "from all accounts" do
|
5
|
+
let(:session) { Travis::Client.new }
|
6
|
+
subject { session.accounts.first }
|
7
|
+
its(:name) { should be == 'Konstantin Haase' }
|
8
|
+
its(:login) { should be == 'rkh' }
|
9
|
+
its(:type) { should be == 'user' }
|
10
|
+
its(:repos_count) { should be == 200 }
|
11
|
+
its(:inspect) { should be == "#<Travis::Client::Account: rkh>" }
|
12
|
+
end
|
13
|
+
|
14
|
+
context "known account" do
|
15
|
+
let(:session) { Travis::Client.new }
|
16
|
+
subject { session.account('rkh') }
|
17
|
+
its(:name) { should be == 'Konstantin Haase' }
|
18
|
+
its(:login) { should be == 'rkh' }
|
19
|
+
its(:type) { should be == 'user' }
|
20
|
+
its(:repos_count) { should be == 200 }
|
21
|
+
its(:inspect) { should be == "#<Travis::Client::Account: rkh>" }
|
22
|
+
end
|
23
|
+
|
24
|
+
context "known account" do
|
25
|
+
let(:session) { Travis::Client.new }
|
26
|
+
subject { session.account('foo') }
|
27
|
+
its(:name) { should be_nil }
|
28
|
+
its(:login) { should be == 'foo' }
|
29
|
+
its(:type) { should be_nil }
|
30
|
+
its(:inspect) { should be == "#<Travis::Client::Account: foo>" }
|
31
|
+
end
|
12
32
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Travis::Client::Repository do
|
4
|
-
|
4
|
+
let(:session) { Travis::Client.new }
|
5
|
+
subject { session.repo('rails/rails') }
|
6
|
+
|
5
7
|
its(:slug) { should be == 'rails/rails' }
|
6
8
|
its(:description) { should_not be_empty }
|
7
9
|
its(:last_build_id) { should be == 4125095 }
|
@@ -15,6 +17,8 @@ describe Travis::Client::Repository do
|
|
15
17
|
its(:last_build) { should be_a(Travis::Client::Build) }
|
16
18
|
its(:color) { should be == 'red' }
|
17
19
|
its(:github_language) { should be == 'Ruby' }
|
20
|
+
its(:owner_name) { should be == 'rails' }
|
21
|
+
its(:owner) { should be == session.account("rails") }
|
18
22
|
|
19
23
|
it { should_not be_pending }
|
20
24
|
it { should be_started }
|
data/spec/support/fake_api.rb
CHANGED
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.5.6.travis.
|
4
|
+
version: 1.5.6.travis.299.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Haase
|
@@ -25,7 +25,7 @@ authors:
|
|
25
25
|
autorequire:
|
26
26
|
bindir: bin
|
27
27
|
cert_chain: []
|
28
|
-
date: 2013-10-
|
28
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
29
29
|
dependencies:
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: faraday
|