ghub 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b4cd241631d0c39b87be5ed66383f4cd3db0a69b751fc7cf04157542e0044d3
4
- data.tar.gz: 52169eb35f653636698bc691389a0166ed4431b7d468691d498abe249a51c763
3
+ metadata.gz: 5696032538ac72fddd970e849721e897c1e8ad5ffe5a7709c695cda3a1bdc8d5
4
+ data.tar.gz: 977c707839c5b937a465de02872e49d5643aed4d8f7b46b39d38ca18a996203c
5
5
  SHA512:
6
- metadata.gz: 67cd93020598662ff094fe825f71809b2972fda4dcbfafc7802d150c9b885bc0b929189a799465a6824a8a234e35f0900b161dd0348133f4a47da5198aa8e587
7
- data.tar.gz: d6898359980054bd6a115179b203d847af4e1c56c114eae043cb734f5c245962b92056afc8709c13fbb90216cb7a42ecc6acedba0d6ec8155ed97c8359b28f65
6
+ metadata.gz: 7898aae0faebc26f84a172110d09daf868113f604eed4979ec6e2e09481daa966ac4b9e44ab868d5a6de6d19ba777aefc20487d841edb933745bfec51b4860e3
7
+ data.tar.gz: 0b28de3cd41723e520d433213937c7a54cb87ca3110748f5ae3a9d9ca8d1f7c7b14f5ae4584cebf1df2943f0d4cad2a904057342b6501c60a0e48c52dde944dd
checksums.yaml.gz.sig CHANGED
Binary file
data/ghub.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "ghub"
5
- spec.version = "2.0.0"
5
+ spec.version = "2.2.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/ghub"
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency "inspectable", "~> 1.0"
33
33
  spec.add_dependency "pipeable", "~> 2.0"
34
34
  spec.add_dependency "refinements", "~> 14.0"
35
+ spec.add_dependency "rfc-web-link", "~> 0.1"
35
36
  spec.add_dependency "zeitwerk", "~> 2.8"
36
37
 
37
38
  spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
data/lib/ghub/api/page.rb CHANGED
@@ -3,11 +3,13 @@
3
3
  require "dry/monads"
4
4
  require "json"
5
5
  require "refinements/array"
6
+ require "rfc/web/link"
6
7
 
7
8
  module Ghub
8
9
  module API
9
10
  # Represents a page of an API response.
10
11
  class Page
12
+ include Dependencies[:configuration, :web_link]
11
13
  extend Dry::Monads[:result]
12
14
 
13
15
  using Refinements::Array
@@ -24,8 +26,9 @@ module Ghub
24
26
  end
25
27
  end
26
28
 
27
- def initialize response
29
+ def initialize(response, **)
28
30
  @response = response
31
+ super(**)
29
32
  end
30
33
 
31
34
  def next = navigation __method__
@@ -48,12 +51,13 @@ module Ghub
48
51
 
49
52
  attr_reader :response
50
53
 
51
- def navigation target
52
- links.find { |link| link.include? target.to_s }
53
- .then { |link| String(link)[/page=(?<page>\d+)/, :page].to_i }
54
- end
54
+ def navigation direction
55
+ link = web_link.call(response.headers).find do |link|
56
+ link.find_pair key: /rel/, value: direction.to_s
57
+ end
55
58
 
56
- def links = String(response.headers["Link"]).split ", "
59
+ link ? link.uri[/page=(?<page>\d+)/, :page].to_i : 0
60
+ end
57
61
  end
58
62
  end
59
63
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "containable"
4
4
  require "http"
5
+ require "rfc/web/link"
5
6
 
6
7
  module Ghub
7
8
  # Defines application dependencies.
@@ -11,5 +12,6 @@ module Ghub
11
12
  register(:configuration) { Configuration::Loader.new.call }
12
13
  register :http, HTTP
13
14
  register(:api) { API::Client.new }
15
+ register(:web_link) { RFC::Web::Link.new self[:configuration].url }
14
16
  end
15
17
  end
@@ -19,7 +19,7 @@ module Ghub
19
19
  :restrictions,
20
20
  :url
21
21
  ) do
22
- def self.for(**attributes)
22
+ def self.for **attributes
23
23
  new(
24
24
  **attributes.merge!(
25
25
  enforce_admins: Ghub::Models::BooleanLink[**attributes[:enforce_admins]],
@@ -55,7 +55,7 @@ module Ghub
55
55
  :url,
56
56
  :user
57
57
  ) do
58
- def self.for(**attributes)
58
+ def self.for **attributes
59
59
  assignee = attributes[:assignee]
60
60
 
61
61
  new(
@@ -17,7 +17,7 @@ module Ghub
17
17
  :slug,
18
18
  :updated_at
19
19
  ) do
20
- def self.for(**attributes)
20
+ def self.for **attributes
21
21
  new(
22
22
  **attributes.merge!(
23
23
  owner: Owner[**attributes[:owner]],
@@ -4,7 +4,7 @@ module Ghub
4
4
  module Models
5
5
  # Defines a branch.
6
6
  Branch = Struct.new :label, :ref, :repo, :sha, :user do
7
- def self.for(**attributes)
7
+ def self.for **attributes
8
8
  new(
9
9
  **attributes.merge!(
10
10
  user: User[**attributes[:user]],
@@ -11,7 +11,7 @@ module Ghub
11
11
  :users,
12
12
  :users_url
13
13
  ) do
14
- def self.for(**attributes)
14
+ def self.for **attributes
15
15
  return new if attributes.empty?
16
16
 
17
17
  new(
@@ -13,7 +13,7 @@ module Ghub
13
13
  :commits,
14
14
  :statuses
15
15
  ) do
16
- def self.for(**attributes)
16
+ def self.for **attributes
17
17
  attributes.reduce({}) { |collection, (key, value)| collection.merge key => Link[**value] }
18
18
  .then { |updates| new(**updates) }
19
19
  end
@@ -88,7 +88,7 @@ module Ghub
88
88
  :web_commit_signoff_required,
89
89
  :weight
90
90
  ) do
91
- def self.for(**attributes)
91
+ def self.for **attributes
92
92
  new(
93
93
  **attributes.transform_keys!(size: :weight),
94
94
  license: (License[**Hash(attributes[:license])] if attributes.key? :license),
@@ -12,7 +12,7 @@ module Ghub
12
12
  :users,
13
13
  :users_url
14
14
  ) do
15
- def self.for(**attributes)
15
+ def self.for **attributes
16
16
  return new if attributes.empty?
17
17
 
18
18
  new(
@@ -10,7 +10,7 @@ module Ghub
10
10
  :url,
11
11
  :dismissal_restrictions
12
12
  ) do
13
- def self.for(**attributes)
13
+ def self.for **attributes
14
14
  return new if attributes.empty?
15
15
 
16
16
  new(
@@ -11,7 +11,7 @@ module Ghub
11
11
  :checks,
12
12
  :enforcement_level
13
13
  ) do
14
- def self.for(**attributes)
14
+ def self.for **attributes
15
15
  new(
16
16
  **attributes.merge!(checks: attributes[:checks].map { |arguments| Check[**arguments] })
17
17
  )
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghub
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -147,6 +147,20 @@ dependencies:
147
147
  - - "~>"
148
148
  - !ruby/object:Gem::Version
149
149
  version: '14.0'
150
+ - !ruby/object:Gem::Dependency
151
+ name: rfc-web-link
152
+ requirement: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - "~>"
155
+ - !ruby/object:Gem::Version
156
+ version: '0.1'
157
+ type: :runtime
158
+ prerelease: false
159
+ version_requirements: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - "~>"
162
+ - !ruby/object:Gem::Version
163
+ version: '0.1'
150
164
  - !ruby/object:Gem::Dependency
151
165
  name: zeitwerk
152
166
  requirement: !ruby/object:Gem::Requirement
@@ -291,7 +305,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
305
  - !ruby/object:Gem::Version
292
306
  version: '0'
293
307
  requirements: []
294
- rubygems_version: 4.0.12
308
+ rubygems_version: 4.0.19
295
309
  specification_version: 4
296
310
  summary: A monadic GitHub API client.
297
311
  test_files: []
metadata.gz.sig CHANGED
Binary file