ghub 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +1 -3
  3. data/README.adoc +3 -1
  4. data/ghub.gemspec +4 -4
  5. data/lib/ghub/container.rb +5 -5
  6. data/lib/ghub/endpoints/branches/protection/actions/show.rb +3 -2
  7. data/lib/ghub/endpoints/branches/protection/actions/update.rb +3 -2
  8. data/lib/ghub/endpoints/branches/protection/container.rb +5 -7
  9. data/lib/ghub/endpoints/branches/protection/import.rb +1 -1
  10. data/lib/ghub/endpoints/branches/protection/models/show.rb +0 -2
  11. data/lib/ghub/endpoints/branches/protection/root.rb +3 -6
  12. data/lib/ghub/endpoints/branches/signature/container.rb +4 -6
  13. data/lib/ghub/endpoints/branches/signature/import.rb +1 -1
  14. data/lib/ghub/endpoints/branches/signature/root.rb +5 -4
  15. data/lib/ghub/endpoints/container.rb +2 -2
  16. data/lib/ghub/endpoints/import.rb +1 -1
  17. data/lib/ghub/endpoints/organizations/members/actions/index.rb +3 -2
  18. data/lib/ghub/endpoints/organizations/members/container.rb +4 -6
  19. data/lib/ghub/endpoints/organizations/members/import.rb +1 -1
  20. data/lib/ghub/endpoints/pulls/actions/index.rb +3 -2
  21. data/lib/ghub/endpoints/pulls/actions/show.rb +3 -2
  22. data/lib/ghub/endpoints/pulls/container.rb +5 -7
  23. data/lib/ghub/endpoints/pulls/import.rb +1 -1
  24. data/lib/ghub/endpoints/pulls/models/show.rb +0 -2
  25. data/lib/ghub/endpoints/repositories/actions/create.rb +3 -2
  26. data/lib/ghub/endpoints/repositories/actions/index.rb +3 -8
  27. data/lib/ghub/endpoints/repositories/actions/patch.rb +3 -2
  28. data/lib/ghub/endpoints/repositories/actions/show.rb +3 -8
  29. data/lib/ghub/endpoints/repositories/container.rb +7 -9
  30. data/lib/ghub/endpoints/repositories/import.rb +1 -1
  31. data/lib/ghub/endpoints/repositories/root.rb +3 -2
  32. data/lib/ghub/endpoints/search/users/actions/index.rb +3 -2
  33. data/lib/ghub/endpoints/search/users/container.rb +4 -6
  34. data/lib/ghub/endpoints/search/users/import.rb +1 -1
  35. data/lib/ghub/endpoints/search/users/models/index.rb +0 -2
  36. data/lib/ghub/endpoints/users/actions/index.rb +3 -2
  37. data/lib/ghub/endpoints/users/actions/show.rb +3 -2
  38. data/lib/ghub/endpoints/users/container.rb +6 -8
  39. data/lib/ghub/endpoints/users/import.rb +1 -1
  40. data/lib/ghub/endpoints/users/models/index.rb +0 -2
  41. data/lib/ghub/endpoints/users/models/show.rb +0 -2
  42. data/lib/ghub/import.rb +1 -1
  43. data/lib/ghub/models/repository.rb +0 -2
  44. data.tar.gz.sig +0 -0
  45. metadata +10 -11
  46. metadata.gz.sig +0 -0
  47. data/lib/ghub/resultable.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c043ed0767155337202f16830cca48c65ee20956d642ee21b36f3d9a7a40fe3b
4
- data.tar.gz: 5b6072e37686096115229fd1746275cc639bef455c431e37f1ef057f04150a7e
3
+ metadata.gz: 9af667b223b6cf1226e7c2dfe84da54bb2af2d70829467685913c981b1431a16
4
+ data.tar.gz: 9a5361db7503ff90c1278a4b966e0eca7d679fd6b226cf4dd0c409176a63d6fe
5
5
  SHA512:
6
- metadata.gz: 1d7316525994fdf1138a22e850b7692f6ad6df004170603a83903db777202d568d580e5d51a341f7a7bd8e02a045ef2f29c59825e45af6eb7838eebc5f1f0ca0
7
- data.tar.gz: 8fab22bed19b8acd25976c12afd8ff4ef78372c717b9248f9bca287033783a75e8fc55f6fd8d2678d995bf7c10a6824df8be33a751d7b313e103534e98fccc3f
6
+ metadata.gz: 721960e1144b387e89e139989d3394a71b2022ed891c3d1e1295e2f8b878e0668a96db3f8e556de46cb6612fa5b148a58b70f41b7c2f02bf35b530942fa274bf
7
+ data.tar.gz: 755456f6387e724c510583f30925a95739a35cce2d8bb23e6e4a7d76e4e5feef8310a3d7bf27ad620904527f9c23332cab5d3daeeebc173f7a21fdcbc9e80254
checksums.yaml.gz.sig CHANGED
@@ -1,3 +1 @@
1
- T��?��!,f�5�U��Rng��\#hݾ�ZtvR �?` S.K��pWMbű1GM��H��DqjB@����@�*���`!�n�/#�?rS(�p<Ɗ���ӿ-v�n�0d���mDo0����#ݦGq%,���?�E�ڀLOF�C������{����wZ���R�Ga_����*%���1^�@> 2!h�����cމ�]yn��Ɂ��o)�s�#���)>�M��)�!7f(m��e8b�LSeE����"�:-���m�_�.
2
- 5�u��\�i
3
- �j�L�Q�P�_"M���(x:�� ��bO2|�uS��\hc$>��4�zI�U�˩Yt�h���͏`���f��y�B��P
1
+ 6I�:���4��~�Lk��{N�M0 ���#��h�(�DEC�����6��R��mV��?��4T�5����- 4MI�~�*n��$ �������̉ޱ�a�x�~1����� >M<�����x���<�ށ 2چ�q��lG�K���x�N��9��<0{q���[��R��b�ǖ+���Έ|��"i�Kb6���H��o���B����EzgFT �$�v�p#��n�~^��0|q�/����/�x��!i��^�֥Pf>湪��6 �� NnJ�{X5��s��,}��iV��u J1��~�Џ�c�x)F'f?���D��B�c�x��m�z�M�q��Q���dk[?wl��j��k�[���],e���ʯ��G�H* �
data/README.adoc CHANGED
@@ -2,6 +2,8 @@
2
2
  :toclevels: 5
3
3
  :figure-caption!:
4
4
 
5
+ :pipeable_link: link:https://alchemists.io/projects/pipeable[Pipeable]
6
+
5
7
  = Ghub
6
8
 
7
9
  Ghub is portmanteau (i.e. [g]it + hub = ghub) that provides a GitHub link:https://docs.github.com/en/rest[API] client using a design which leverages link:https://alchemists.io/articles/ruby_function_composition[function composition] and link:https://dry-rb.org/gems/dry-monads[monads]. This gem is built upon the link:https://github.com/httprb/http[HTTP] gem which provides a nicer Object API instead of link:https://lostisland.github.io/faraday[Faraday] which is what the link:https://github.com/octokit/octokit.rb[Octokit] gem uses.
@@ -12,7 +14,7 @@ toc::[]
12
14
 
13
15
  * Provides an API client which is a partial implementation of GitHub's link:https://docs.github.com/en/rest[API].
14
16
  * Provides HTTP request and response verification using link:https://dry-rb.org/gems/dry-schema[Dry Schema].
15
- * Uses link:https://alchemists.io/articles/ruby_function_composition[Function Composition] -- coupled with link:https://alchemists.io/projects/transactable[Transactable] -- to process each HTTP request and response.
17
+ * Uses link:https://alchemists.io/articles/ruby_function_composition[Function Composition] -- coupled with {pipeable_link} -- to process each HTTP request and response.
16
18
 
17
19
  == Requirements
18
20
 
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 = "0.11.0"
5
+ spec.version = "0.12.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/ghub"
@@ -23,12 +23,12 @@ Gem::Specification.new do |spec|
23
23
  spec.cert_chain = [Gem.default_cert_path]
24
24
 
25
25
  spec.required_ruby_version = "~> 3.3"
26
- spec.add_dependency "dry-container", "~> 0.11"
26
+ spec.add_dependency "containable", "~> 0.0"
27
27
  spec.add_dependency "dry-monads", "~> 1.6"
28
28
  spec.add_dependency "dry-schema", "~> 1.13"
29
29
  spec.add_dependency "http", "~> 5.1"
30
- spec.add_dependency "infusible", "~> 3.4"
31
- spec.add_dependency "pipeable", "~> 0.1"
30
+ spec.add_dependency "infusible", "~> 3.5"
31
+ spec.add_dependency "pipeable", "~> 0.2"
32
32
  spec.add_dependency "refinements", "~> 12.1"
33
33
  spec.add_dependency "zeitwerk", "~> 2.6"
34
34
 
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry-container"
3
+ require "containable"
4
4
  require "http"
5
5
 
6
6
  module Ghub
7
7
  # Defines application dependencies.
8
8
  module Container
9
- extend Dry::Container::Mixin
9
+ extend Containable
10
10
 
11
- register(:configuration, memoize: true) { Configuration::Loader.new.call }
12
- register(:http) { HTTP }
13
- register(:client) { API::Client.new }
11
+ register(:configuration) { Configuration::Loader.new.call }
12
+ register :http, HTTP
13
+ register(:api) { API::Client.new }
14
14
  end
15
15
  end
@@ -9,12 +9,13 @@ module Ghub
9
9
  module Actions
10
10
  # Handles a branch projection show action.
11
11
  class Show
12
- include Protection::Import[:client, response: "responses.show", model: "models.show"]
12
+ include Ghub::Import[:api]
13
+ include Protection::Import[response: "responses.show", model: "models.show"]
13
14
  include Pipeable
14
15
 
15
16
  def call owner, repository, branch, **parameters
16
17
  pipe(
17
- client.get(
18
+ api.get(
18
19
  "repos/#{owner}/#{repository}/branches/#{branch}/protection",
19
20
  **parameters
20
21
  ),
@@ -9,8 +9,9 @@ module Ghub
9
9
  module Actions
10
10
  # Handles a branch projection update action.
11
11
  class Update
12
+ include Ghub::Import[:api]
13
+
12
14
  include Protection::Import[
13
- :client,
14
15
  request: "requests.update",
15
16
  response: "responses.show",
16
17
  model: "models.show"
@@ -24,7 +25,7 @@ module Ghub
24
25
  validate(request),
25
26
  insert("repos/#{owner}/#{repository}/branches/#{branch}/protection", at: 0),
26
27
  insert(parameters),
27
- to(client, :put),
28
+ to(api, :put),
28
29
  try(:parse, catch: JSON::ParserError),
29
30
  validate(response),
30
31
  to(model, :for)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/container"
3
+ require "containable"
4
4
 
5
5
  module Ghub
6
6
  module Endpoints
@@ -8,20 +8,18 @@ module Ghub
8
8
  module Protection
9
9
  # Defines branch protection dependencies.
10
10
  module Container
11
- extend Dry::Container::Mixin
12
-
13
- merge Ghub::Container
11
+ extend Containable
14
12
 
15
13
  namespace :requests do
16
- register(:update) { Requests::Update }
14
+ register :update, Requests::Update
17
15
  end
18
16
 
19
17
  namespace :responses do
20
- register(:show) { Responses::Show }
18
+ register :show, Responses::Show
21
19
  end
22
20
 
23
21
  namespace :models do
24
- register(:show) { Models::Show }
22
+ register :show, Models::Show
25
23
  end
26
24
 
27
25
  namespace :actions do
@@ -6,7 +6,7 @@ module Ghub
6
6
  module Endpoints
7
7
  module Branches
8
8
  module Protection
9
- Import = Infusible.with Container
9
+ Import = Infusible[Container]
10
10
  end
11
11
  end
12
12
  end
@@ -19,8 +19,6 @@ module Ghub
19
19
  :restrictions,
20
20
  :url
21
21
  ) do
22
- include Resultable
23
-
24
22
  def self.for(**attributes)
25
23
  new(
26
24
  **attributes.merge!(
@@ -6,18 +6,15 @@ module Ghub
6
6
  module Protection
7
7
  # Provides access to the branch protection API endpoint.
8
8
  class Root
9
- include Protection::Import[
10
- :client,
11
- show_action: "actions.show",
12
- update_action: "actions.update"
13
- ]
9
+ include Ghub::Import[:api]
10
+ include Protection::Import[show_action: "actions.show", update_action: "actions.update"]
14
11
 
15
12
  def show(...) = show_action.call(...)
16
13
 
17
14
  def update(...) = update_action.call(...)
18
15
 
19
16
  def destroy owner, repository, branch
20
- client.delete "repos/#{owner}/#{repository}/branches/#{branch}/protection"
17
+ api.delete "repos/#{owner}/#{repository}/branches/#{branch}/protection"
21
18
  end
22
19
  end
23
20
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/container"
3
+ require "containable"
4
4
 
5
5
  module Ghub
6
6
  module Endpoints
@@ -8,16 +8,14 @@ module Ghub
8
8
  module Signature
9
9
  # Defines branch signature dependencies.
10
10
  module Container
11
- extend Dry::Container::Mixin
12
-
13
- merge Ghub::Container
11
+ extend Containable
14
12
 
15
13
  namespace :responses do
16
- register(:show) { Ghub::Responses::BooleanLink }
14
+ register :show, Ghub::Responses::BooleanLink
17
15
  end
18
16
 
19
17
  namespace :models do
20
- register(:show) { Ghub::Models::BooleanLink }
18
+ register :show, Ghub::Models::BooleanLink
21
19
  end
22
20
  end
23
21
  end
@@ -6,7 +6,7 @@ module Ghub
6
6
  module Endpoints
7
7
  module Branches
8
8
  module Signature
9
- Import = Infusible.with Container
9
+ Import = Infusible[Container]
10
10
  end
11
11
  end
12
12
  end
@@ -8,7 +8,8 @@ module Ghub
8
8
  module Signature
9
9
  # Provides access to the branch signature API endpoint.
10
10
  class Root
11
- include Signature::Import[:client, response: "responses.show", model: "models.show"]
11
+ include Ghub::Import[:api]
12
+ include Signature::Import[response: "responses.show", model: "models.show"]
12
13
  include Pipeable
13
14
 
14
15
  PATH = "repos/%<owner>s/%<repository>s/branches/%<branch>s/protection/required_signatures"
@@ -20,7 +21,7 @@ module Ghub
20
21
 
21
22
  def show owner, repository, branch
22
23
  pipe format(path, owner:, repository:, branch:),
23
- to(client, :get),
24
+ to(api, :get),
24
25
  try(:parse, catch: JSON::ParserError),
25
26
  validate(response),
26
27
  to(model, :for)
@@ -28,14 +29,14 @@ module Ghub
28
29
 
29
30
  def create owner, repository, branch
30
31
  pipe format(path, owner:, repository:, branch:),
31
- to(client, :post),
32
+ to(api, :post),
32
33
  try(:parse, catch: JSON::ParserError),
33
34
  validate(response),
34
35
  to(model, :for)
35
36
  end
36
37
 
37
38
  def destroy owner, repository, branch
38
- client.delete format(path, owner:, repository:, branch:)
39
+ api.delete format(path, owner:, repository:, branch:)
39
40
  end
40
41
 
41
42
  private
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/container"
3
+ require "containable"
4
4
 
5
5
  module Ghub
6
6
  module Endpoints
7
7
  # Defines endpoint dependencies.
8
8
  module Container
9
- extend Dry::Container::Mixin
9
+ extend Containable
10
10
 
11
11
  register(:branch_protection) { Endpoints::Branches::Protection::Root.new }
12
12
  register(:branch_signature) { Endpoints::Branches::Signature::Root.new }
@@ -4,6 +4,6 @@ require "infusible"
4
4
 
5
5
  module Ghub
6
6
  module Endpoints
7
- Import = Infusible.with Container
7
+ Import = Infusible[Container]
8
8
  end
9
9
  end
@@ -9,14 +9,15 @@ module Ghub
9
9
  module Actions
10
10
  # Handles an organization member index action.
11
11
  class Index
12
- include Members::Import[:client, response: "responses.index", model: "models.show"]
12
+ include Ghub::Import[:api]
13
+ include Members::Import[response: "responses.index", model: "models.show"]
13
14
  include Pipeable
14
15
 
15
16
  def call owner, **parameters
16
17
  pipe(
17
18
  "orgs/#{owner}/members",
18
19
  insert(parameters),
19
- to(client, :get),
20
+ to(api, :get),
20
21
  try(:parse, catch: JSON::ParserError),
21
22
  fmap { |body| {body:} },
22
23
  validate(response),
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/container"
3
+ require "containable"
4
4
 
5
5
  module Ghub
6
6
  module Endpoints
@@ -8,16 +8,14 @@ module Ghub
8
8
  module Members
9
9
  # Defines member dependencies.
10
10
  module Container
11
- extend Dry::Container::Mixin
12
-
13
- merge Ghub::Container
11
+ extend Containable
14
12
 
15
13
  namespace :responses do
16
- register(:index) { Responses::Index }
14
+ register :index, Responses::Index
17
15
  end
18
16
 
19
17
  namespace :models do
20
- register(:show) { Ghub::Models::User }
18
+ register :show, Ghub::Models::User
21
19
  end
22
20
 
23
21
  namespace :actions do
@@ -6,7 +6,7 @@ module Ghub
6
6
  module Endpoints
7
7
  module Organizations
8
8
  module Members
9
- Import = Infusible.with Container
9
+ Import = Infusible[Container]
10
10
  end
11
11
  end
12
12
  end
@@ -8,12 +8,13 @@ module Ghub
8
8
  module Actions
9
9
  # Handles a repository index action.
10
10
  class Index
11
- include Pulls::Import[:client, response: "responses.index", model: "models.show"]
11
+ include Ghub::Import[:api]
12
+ include Pulls::Import[response: "responses.index", model: "models.show"]
12
13
  include Pipeable
13
14
 
14
15
  def call owner, repository, **parameters
15
16
  pipe(
16
- client.get("repos/#{owner}/#{repository}/pulls", **parameters),
17
+ api.get("repos/#{owner}/#{repository}/pulls", **parameters),
17
18
  try(:parse, catch: JSON::ParserError),
18
19
  fmap { |body| {body:} },
19
20
  validate(response),
@@ -8,12 +8,13 @@ module Ghub
8
8
  module Actions
9
9
  # Handles a repository index action.
10
10
  class Show
11
- include Pulls::Import[:client, response: "responses.show", model: "models.show"]
11
+ include Ghub::Import[:api]
12
+ include Pulls::Import[response: "responses.show", model: "models.show"]
12
13
  include Pipeable
13
14
 
14
15
  def call owner, repository, id, **parameters
15
16
  pipe(
16
- client.get("repos/#{owner}/#{repository}/pulls/#{id}", **parameters),
17
+ api.get("repos/#{owner}/#{repository}/pulls/#{id}", **parameters),
17
18
  try(:parse, catch: JSON::ParserError),
18
19
  validate(response),
19
20
  to(model, :for)
@@ -1,23 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/container"
3
+ require "containable"
4
4
 
5
5
  module Ghub
6
6
  module Endpoints
7
7
  module Pulls
8
8
  # Defines pull request dependencies.
9
9
  module Container
10
- extend Dry::Container::Mixin
11
-
12
- merge Ghub::Container
10
+ extend Containable
13
11
 
14
12
  namespace :responses do
15
- register(:index) { Responses::Index }
16
- register(:show) { Responses::Show }
13
+ register :index, Responses::Index
14
+ register :show, Responses::Show
17
15
  end
18
16
 
19
17
  namespace :models do
20
- register(:show) { Models::Show }
18
+ register :show, Models::Show
21
19
  end
22
20
 
23
21
  namespace :actions do
@@ -5,7 +5,7 @@ require "infusible"
5
5
  module Ghub
6
6
  module Endpoints
7
7
  module Pulls
8
- Import = Infusible.with Container
8
+ Import = Infusible[Container]
9
9
  end
10
10
  end
11
11
  end
@@ -55,8 +55,6 @@ module Ghub
55
55
  :url,
56
56
  :user
57
57
  ) do
58
- include Resultable
59
-
60
58
  def self.for(**attributes)
61
59
  assignee = attributes[:assignee]
62
60
 
@@ -8,8 +8,9 @@ module Ghub
8
8
  module Actions
9
9
  # Handles a repository create action.
10
10
  class Create
11
+ include Ghub::Import[:api]
12
+
11
13
  include Import[
12
- :client,
13
14
  :path,
14
15
  request: "requests.create",
15
16
  response: "responses.show",
@@ -24,7 +25,7 @@ module Ghub
24
25
  validate(request),
25
26
  insert(url_path, at: 0),
26
27
  insert(parameters),
27
- to(client, :post),
28
+ to(api, :post),
28
29
  try(:parse, catch: JSON::ParserError),
29
30
  validate(response),
30
31
  to(model, :for)
@@ -8,20 +8,15 @@ module Ghub
8
8
  module Actions
9
9
  # Handles a repository index action.
10
10
  class Index
11
- include Repositories::Import[
12
- :client,
13
- :path,
14
- response: "responses.index",
15
- model: "models.show"
16
- ]
17
-
11
+ include Ghub::Import[:api]
12
+ include Repositories::Import[:path, response: "responses.index", model: "models.show"]
18
13
  include Pipeable
19
14
 
20
15
  def call kind, owner, **parameters
21
16
  pipe(
22
17
  path.index(kind, owner),
23
18
  insert(parameters),
24
- to(client, :get),
19
+ to(api, :get),
25
20
  try(:parse, catch: JSON::ParserError),
26
21
  fmap { |body| {body:} },
27
22
  validate(response),
@@ -8,8 +8,9 @@ module Ghub
8
8
  module Actions
9
9
  # Handles a repository patch action.
10
10
  class Patch
11
+ include Ghub::Import[:api]
12
+
11
13
  include Import[
12
- :client,
13
14
  :path,
14
15
  request: "requests.patch",
15
16
  response: "responses.show",
@@ -24,7 +25,7 @@ module Ghub
24
25
  validate(request),
25
26
  insert(url_path, at: 0),
26
27
  insert(parameters),
27
- to(client, :patch),
28
+ to(api, :patch),
28
29
  try(:parse, catch: JSON::ParserError),
29
30
  validate(response),
30
31
  to(model, :for)
@@ -8,19 +8,14 @@ module Ghub
8
8
  module Actions
9
9
  # Handles a repository show action.
10
10
  class Show
11
- include Repositories::Import[
12
- :client,
13
- :path,
14
- response: "responses.show",
15
- model: "models.show"
16
- ]
17
-
11
+ include Ghub::Import[:api]
12
+ include Repositories::Import[:path, response: "responses.show", model: "models.show"]
18
13
  include Pipeable
19
14
 
20
15
  def call owner, id, **parameters
21
16
  pipe path.show(owner, id),
22
17
  insert(parameters),
23
- to(client, :get),
18
+ to(api, :get),
24
19
  try(:parse, catch: JSON::ParserError),
25
20
  validate(response),
26
21
  to(model, :for)
@@ -1,28 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/container"
3
+ require "containable"
4
4
 
5
5
  module Ghub
6
6
  module Endpoints
7
7
  module Repositories
8
8
  # Defines repository dependencies.
9
9
  module Container
10
- extend Dry::Container::Mixin
11
-
12
- merge Ghub::Container
10
+ extend Containable
13
11
 
14
12
  namespace :requests do
15
- register(:create) { Requests::Create }
16
- register(:patch) { Requests::Patch }
13
+ register :create, Requests::Create
14
+ register :patch, Requests::Patch
17
15
  end
18
16
 
19
17
  namespace :responses do
20
- register(:index) { Responses::Index }
21
- register(:show) { Ghub::Responses::Repository }
18
+ register :index, Responses::Index
19
+ register :show, Ghub::Responses::Repository
22
20
  end
23
21
 
24
22
  namespace :models do
25
- register(:show) { Ghub::Models::Repository }
23
+ register :show, Ghub::Models::Repository
26
24
  end
27
25
 
28
26
  register(:path) { Path.new }
@@ -5,7 +5,7 @@ require "infusible"
5
5
  module Ghub
6
6
  module Endpoints
7
7
  module Repositories
8
- Import = Infusible.with Container
8
+ Import = Infusible[Container]
9
9
  end
10
10
  end
11
11
  end
@@ -5,8 +5,9 @@ module Ghub
5
5
  module Repositories
6
6
  # Provides access to the users API endpoint.
7
7
  class Root
8
+ include Ghub::Import[:api]
9
+
8
10
  include Repositories::Import[
9
- :client,
10
11
  create_action: "actions.create",
11
12
  index_action: "actions.index",
12
13
  patch_action: "actions.patch",
@@ -21,7 +22,7 @@ module Ghub
21
22
 
22
23
  def patch(...) = patch_action.call(...)
23
24
 
24
- def destroy(owner, id) = client.delete "repos/#{owner}/#{id}"
25
+ def destroy(owner, id) = api.delete "repos/#{owner}/#{id}"
25
26
  end
26
27
  end
27
28
  end
@@ -9,12 +9,13 @@ module Ghub
9
9
  module Actions
10
10
  # Handles a user index action.
11
11
  class Index
12
- include Import[:client, response: "responses.index", model: "models.index"]
12
+ include Ghub::Import[:api]
13
+ include Import[response: "responses.index", model: "models.index"]
13
14
  include Pipeable
14
15
 
15
16
  def call **parameters
16
17
  pipe(
17
- client.get("search/users", **parameters),
18
+ api.get("search/users", **parameters),
18
19
  try(:parse, catch: JSON::ParserError),
19
20
  validate(response),
20
21
  as(:fetch, :items),
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/container"
3
+ require "containable"
4
4
 
5
5
  module Ghub
6
6
  module Endpoints
@@ -8,16 +8,14 @@ module Ghub
8
8
  module Users
9
9
  # Defines user dependencies.
10
10
  module Container
11
- extend Dry::Container::Mixin
12
-
13
- merge Ghub::Container
11
+ extend Containable
14
12
 
15
13
  namespace :responses do
16
- register(:index) { Responses::Index }
14
+ register :index, Responses::Index
17
15
  end
18
16
 
19
17
  namespace :models do
20
- register(:index) { Models::Index }
18
+ register :index, Models::Index
21
19
  end
22
20
 
23
21
  namespace :actions do
@@ -6,7 +6,7 @@ module Ghub
6
6
  module Endpoints
7
7
  module Search
8
8
  module Users
9
- Import = Infusible.with Container
9
+ Import = Infusible[Container]
10
10
  end
11
11
  end
12
12
  end
@@ -27,8 +27,6 @@ module Ghub
27
27
  :type,
28
28
  :url
29
29
  ) do
30
- include Resultable
31
-
32
30
  def self.for(**) = new(**)
33
31
 
34
32
  def initialize(**)
@@ -8,12 +8,13 @@ module Ghub
8
8
  module Actions
9
9
  # Handles a user index action.
10
10
  class Index
11
- include Users::Import[:client, response: "responses.index", model: "models.index"]
11
+ include Ghub::Import[:api]
12
+ include Users::Import[response: "responses.index", model: "models.index"]
12
13
  include Pipeable
13
14
 
14
15
  def call **parameters
15
16
  pipe(
16
- client.get("users", **parameters),
17
+ api.get("users", **parameters),
17
18
  try(:parse, catch: JSON::ParserError),
18
19
  fmap { |body| {body:} },
19
20
  validate(response),
@@ -8,11 +8,12 @@ module Ghub
8
8
  module Actions
9
9
  # Handles a user show action.
10
10
  class Show
11
- include Users::Import[:client, response: "responses.show", model: "models.show"]
11
+ include Ghub::Import[:api]
12
+ include Users::Import[response: "responses.show", model: "models.show"]
12
13
  include Pipeable
13
14
 
14
15
  def call id, **parameters
15
- pipe client.get("users/#{id}", **parameters),
16
+ pipe api.get("users/#{id}", **parameters),
16
17
  try(:parse, catch: JSON::ParserError),
17
18
  validate(response),
18
19
  to(model, :for)
@@ -1,24 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/container"
3
+ require "containable"
4
4
 
5
5
  module Ghub
6
6
  module Endpoints
7
7
  module Users
8
8
  # Defines user dependencies.
9
9
  module Container
10
- extend Dry::Container::Mixin
11
-
12
- merge Ghub::Container
10
+ extend Containable
13
11
 
14
12
  namespace :responses do
15
- register(:index) { Responses::Index }
16
- register(:show) { Responses::Show }
13
+ register :index, Responses::Index
14
+ register :show, Responses::Show
17
15
  end
18
16
 
19
17
  namespace :models do
20
- register(:index) { Models::Index }
21
- register(:show) { Models::Show }
18
+ register :index, Models::Index
19
+ register :show, Models::Show
22
20
  end
23
21
 
24
22
  namespace :actions do
@@ -5,7 +5,7 @@ require "infusible"
5
5
  module Ghub
6
6
  module Endpoints
7
7
  module Users
8
- Import = Infusible.with Container
8
+ Import = Infusible[Container]
9
9
  end
10
10
  end
11
11
  end
@@ -25,8 +25,6 @@ module Ghub
25
25
  :type,
26
26
  :url
27
27
  ) do
28
- include Resultable
29
-
30
28
  def self.for(**) = new(**)
31
29
 
32
30
  def initialize(**)
@@ -39,8 +39,6 @@ module Ghub
39
39
  :updated_at,
40
40
  :url
41
41
  ) do
42
- include Resultable
43
-
44
42
  def self.for(**) = new(**)
45
43
 
46
44
  def initialize(**)
data/lib/ghub/import.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  require "infusible"
4
4
 
5
5
  module Ghub
6
- Import = Infusible.with Container
6
+ Import = Infusible[Container]
7
7
  end
@@ -88,8 +88,6 @@ module Ghub
88
88
  :web_commit_signoff_required,
89
89
  :weight
90
90
  ) do
91
- include Resultable
92
-
93
91
  def self.for(**attributes)
94
92
  new(
95
93
  **attributes.transform_keys!(size: :weight).merge(
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: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -35,22 +35,22 @@ cert_chain:
35
35
  3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
36
36
  gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
37
37
  -----END CERTIFICATE-----
38
- date: 2024-03-09 00:00:00.000000000 Z
38
+ date: 2024-04-03 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
- name: dry-container
41
+ name: containable
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.11'
46
+ version: '0.0'
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0.11'
53
+ version: '0.0'
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: dry-monads
56
56
  requirement: !ruby/object:Gem::Requirement
@@ -99,28 +99,28 @@ dependencies:
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '3.4'
102
+ version: '3.5'
103
103
  type: :runtime
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: '3.4'
109
+ version: '3.5'
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: pipeable
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: '0.1'
116
+ version: '0.2'
117
117
  type: :runtime
118
118
  prerelease: false
119
119
  version_requirements: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: '0.1'
123
+ version: '0.2'
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: refinements
126
126
  requirement: !ruby/object:Gem::Requirement
@@ -255,7 +255,6 @@ files:
255
255
  - lib/ghub/responses/status_check.rb
256
256
  - lib/ghub/responses/team.rb
257
257
  - lib/ghub/responses/user.rb
258
- - lib/ghub/resultable.rb
259
258
  homepage: https://alchemists.io/projects/ghub
260
259
  licenses:
261
260
  - Hippocratic-2.1
@@ -282,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
282
281
  - !ruby/object:Gem::Version
283
282
  version: '0'
284
283
  requirements: []
285
- rubygems_version: 3.5.6
284
+ rubygems_version: 3.5.7
286
285
  signing_key:
287
286
  specification_version: 4
288
287
  summary: A monadic GitHub API client.
metadata.gz.sig CHANGED
Binary file
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ghub
4
- # Allows a model to be callable, frozen, and cast itself as a monad to be processed as a result.
5
- module Resultable
6
- include Dry::Monads[:result]
7
-
8
- def self.included descendant
9
- super
10
- descendant.extend ClassMethods
11
- end
12
-
13
- # Allows an object to be callable via a class method.
14
- module ClassMethods
15
- def call(...) = new(...)
16
- end
17
-
18
- def to_monad = Success self
19
- end
20
- end