trav3 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/trav3.rb +25 -1
- data/lib/trav3/options.rb +2 -2
- data/lib/trav3/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0aafa22212b53bac7b091d13ffccbfbee54ac0757f6d0271f7090fb1586dcc31
|
4
|
+
data.tar.gz: 1b754a8ba61877f424a66e6a16268d42958b363c397f83663085e5d2052f3a24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfa80306d50c55d3bd3602a0e79688c61144a2a79a92e14becb511171908a97e9399a9b3f2963f19b39f6e12055b9ede4dca60cad0081e0c5840a44bf3ed6723
|
7
|
+
data.tar.gz: 852fee66e709450e4e1666b96be8f0085df8b394374fd3f996462c4f6580545d62ba0eadfbf9e01df1e367ed9984b76d985e1055b28141bb13575c436c8534e0
|
data/README.md
CHANGED
@@ -30,6 +30,12 @@ Or install it yourself as:
|
|
30
30
|
```ruby
|
31
31
|
require 'trav3'
|
32
32
|
project = Trav3::Travis.new("name/example")
|
33
|
+
project.owner
|
34
|
+
project.owner("owner")
|
35
|
+
project.repositories
|
36
|
+
project.repositories("owner")
|
37
|
+
project.repository
|
38
|
+
project.repository("owner/repo")
|
33
39
|
project.builds
|
34
40
|
project.build(12345)
|
35
41
|
project.build_jobs(12345)
|
@@ -45,6 +51,10 @@ builds = project.builds
|
|
45
51
|
builds.page.next
|
46
52
|
builds.page.first
|
47
53
|
builds.page.last
|
54
|
+
|
55
|
+
# Recommended inspection
|
56
|
+
builds.keys
|
57
|
+
builds.dig("some_key")
|
48
58
|
```
|
49
59
|
|
50
60
|
## Development
|
data/lib/trav3.rb
CHANGED
@@ -9,6 +9,7 @@ module Trav3
|
|
9
9
|
|
10
10
|
class Travis
|
11
11
|
API_ENDPOINT = "#{API_ROOT}/v3"
|
12
|
+
attr_reader :options
|
12
13
|
def initialize(repo)
|
13
14
|
raise InvalidRepository unless repo.is_a?(String) and
|
14
15
|
Regexp.new(/(^\d+$)|(^\w+(?:\/|%2F){1}\w+$)/) === repo
|
@@ -17,7 +18,7 @@ module Trav3
|
|
17
18
|
defaults(limit: 25)
|
18
19
|
end
|
19
20
|
|
20
|
-
def [](repository =
|
21
|
+
def [](repository = false)
|
21
22
|
[API_ENDPOINT].tap {|a| a.push("repo/#{@repo}") if repository }.join('/')
|
22
23
|
end
|
23
24
|
private :[]
|
@@ -27,6 +28,29 @@ module Trav3
|
|
27
28
|
self
|
28
29
|
end
|
29
30
|
|
31
|
+
def owner(owner = @repo[/.*?(?=(?:\/|%2F)|$)/])
|
32
|
+
if /^\d+$/ === owner
|
33
|
+
get("#{self[]}/owner/github_id/#{owner}")
|
34
|
+
else
|
35
|
+
get("#{self[]}/owner/#{owner}")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def repositories(owner = @repo[/.*?(?=(?:\/|%2F)|$)/])
|
40
|
+
if /^\d+$/ === owner
|
41
|
+
get("#{self[]}/owner/github_id/#{owner}/repos#{opts}")
|
42
|
+
else
|
43
|
+
get("#{self[]}/owner/#{owner}/repos#{opts}")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def repository(repo = @repo)
|
48
|
+
raise InvalidRepository unless repo.is_a?(String) and
|
49
|
+
Regexp.new(/(^\d+$)|(^\w+(?:\/|%2F){1}\w+$)/) === repo
|
50
|
+
|
51
|
+
get("#{self[]}/repo/#{repo.gsub(/\//, '%2F')}")
|
52
|
+
end
|
53
|
+
|
30
54
|
def builds
|
31
55
|
get("#{self[true]}/builds#{opts}")
|
32
56
|
end
|
data/lib/trav3/options.rb
CHANGED
@@ -22,7 +22,7 @@ module Trav3
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def remove(key)
|
25
|
-
@opts = @opts.keep_if {|a, _|
|
25
|
+
@opts = @opts.keep_if {|a, _| ki[key][a] }
|
26
26
|
end
|
27
27
|
|
28
28
|
def +(other)
|
@@ -40,7 +40,7 @@ module Trav3
|
|
40
40
|
private :pb
|
41
41
|
|
42
42
|
def ki
|
43
|
-
|
43
|
+
lambda {|key| lambda {|item| !(/^#{key}=/ === "#{item}") } }
|
44
44
|
end
|
45
45
|
private :ki
|
46
46
|
end
|
data/lib/trav3/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trav3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel P. Clark
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|