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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9d051368b7f9cdc96624c21a8633de396652dcce787bed17be43429efc58b9b
4
- data.tar.gz: d428964b0cc846da949efd73f6bbf5f19822f33b5c6994f18c2f8f40861d257b
3
+ metadata.gz: 0aafa22212b53bac7b091d13ffccbfbee54ac0757f6d0271f7090fb1586dcc31
4
+ data.tar.gz: 1b754a8ba61877f424a66e6a16268d42958b363c397f83663085e5d2052f3a24
5
5
  SHA512:
6
- metadata.gz: f379a2fe4db84e699a6b33e41fd5ee7d66491d15fc437ee6ade66e0cdf5fc8e8db390cfdf66af10dfd56705aedf2bb66dc9a4c2ca63a005a793926db42403ab8
7
- data.tar.gz: beea9526ee488f54770d5c7fcfd792660c9a1d66ae6eeaed414483fab08ee9388b5805a26b83efdbd9c35bb7667db6660138c35e54b2cb943f63bc66762dc894
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
@@ -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 = nil)
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
@@ -22,7 +22,7 @@ module Trav3
22
22
  end
23
23
 
24
24
  def remove(key)
25
- @opts = @opts.keep_if {|a, _| (eval ki)[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
- 'lambda {|item| !(/^#{key}=/ === "#{item}") }'
43
+ lambda {|key| lambda {|item| !(/^#{key}=/ === "#{item}") } }
44
44
  end
45
45
  private :ki
46
46
  end
@@ -1,3 +1,3 @@
1
1
  module Trav3
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
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
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-15 00:00:00.000000000 Z
11
+ date: 2018-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler