ghub 0.5.1 → 0.7.0

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: 70374819e231535495ea7691e634aef56616e2065bd6a65bec82a33f4f8af7ee
4
- data.tar.gz: 0657d78763952299f611047d9c8f640189478037ce770a75dcab5c9a1e14a199
3
+ metadata.gz: ce5b37f7c61c21eeeff22b06117bee8ec9cf0c80bc119f82d92f8b8c7d2475c6
4
+ data.tar.gz: 62cfd658f42a0b836869b212c13c9f5f6e6e2c9e86bc5d06da43367268f668c6
5
5
  SHA512:
6
- metadata.gz: c0df55e7dd487a9b9d62302f6f4403ad5b11cab6e5fcd869d7a4e147c3e40d8e6b984926d5bb24f363c15087090013d0a1db674848e1056eef1d02081df05a45
7
- data.tar.gz: 851294544b56028aa1bf060a8cd0d745c7501885ed798e6d699a5590ddf9c5264f5ce1e6a0c643905adbd27b4aaa171ddf6e4c463b2c5da20590b4c58172cd84
6
+ metadata.gz: 8f5c9a045f4abfab759860eeefc8169f402fce8906f9471b4542880da9caae712816996be863f392723dbee49e6e2a2d59fd3373a0cef120ea852054a8043e0c
7
+ data.tar.gz: b589f93696d26551cca0db2629c0551911b29dba3e4bcc59dc5e3c6857f29638bbde5758687a28be658876526b570b6adde3e1af14f775f3c565721aab06846a
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  = Ghub
6
6
 
7
- 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 instead of link:https://lostisland.github.io/faraday[Faraday] which is what the link:https://github.com/octokit/octokit.rb[Octokit] gem uses.
7
+ 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.
8
8
 
9
9
  toc::[]
10
10
 
@@ -151,6 +151,15 @@ client.repositories.destroy "acme", "ghub-test"
151
151
 
152
152
  GitHub's API design for repositories is awkward and you can see this infect the Object API, especially when creating a repository. Use `:users` or `:orgs` (can be strings) to distinguish between the two types of repository creation. The only stipulation for organization creation is that you must supply the organization name. This was done so you could use the same Object API for both.
153
153
 
154
+ ==== Search
155
+
156
+ The following is how to search link:https://docs.github.com/en/rest/search/search#search-users[users]:
157
+
158
+ [source,ruby]
159
+ ----
160
+ client.search_users.index q: "test@example.com"
161
+ ----
162
+
154
163
  ==== Users
155
164
 
156
165
  The following is how to link:https://docs.github.com/en/rest/users/users#list-users[index] and link:https://docs.github.com/en/rest/users/users#get-a-user[show] users:
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.5.1"
5
+ spec.version = "0.7.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/ghub"
data/lib/ghub/client.rb CHANGED
@@ -11,6 +11,7 @@ module Ghub
11
11
  organization_members_endpoint: :organization_members,
12
12
  pulls_endpoint: :pulls,
13
13
  repositories_endpoint: :repositories,
14
+ search_users_endpoint: :search_users,
14
15
  users_endpoint: :users
15
16
  ]
16
17
 
@@ -29,6 +30,8 @@ module Ghub
29
30
 
30
31
  def repositories = repositories_endpoint
31
32
 
33
+ def search_users = search_users_endpoint
34
+
32
35
  def users = users_endpoint
33
36
  end
34
37
  end
@@ -13,6 +13,7 @@ module Ghub
13
13
  register(:organization_members) { Endpoints::Organizations::Members::Root.new }
14
14
  register(:pulls) { Endpoints::Pulls::Root.new }
15
15
  register(:repositories) { Endpoints::Repositories::Root.new }
16
+ register(:search_users) { Endpoints::Search::Users::Root.new }
16
17
  register(:users) { Endpoints::Users::Root.new }
17
18
  end
18
19
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "transactable"
4
+
5
+ module Ghub
6
+ module Endpoints
7
+ module Search
8
+ module Users
9
+ module Actions
10
+ # Handles a user index action.
11
+ class Index
12
+ include Import[:client, response: "responses.index", model: "models.index"]
13
+ include Transactable
14
+
15
+ def call **parameters
16
+ pipe(
17
+ client.get("search/users", **parameters),
18
+ try(:parse, catch: JSON::ParserError),
19
+ validate(response),
20
+ as(:fetch, :items),
21
+ map { |item| model.new item.to_h }
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/container"
4
+
5
+ module Ghub
6
+ module Endpoints
7
+ module Search
8
+ module Users
9
+ # Defines user dependencies.
10
+ module Container
11
+ extend Dry::Container::Mixin
12
+
13
+ merge Ghub::Container
14
+
15
+ namespace :responses do
16
+ register(:index) { Responses::Index }
17
+ end
18
+
19
+ namespace :models do
20
+ register(:index) { Models::Index }
21
+ end
22
+
23
+ namespace :actions do
24
+ register(:index) { Actions::Index.new }
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "infusible"
4
+
5
+ module Ghub
6
+ module Endpoints
7
+ module Search
8
+ module Users
9
+ Import = Infusible.with Container
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ghub
4
+ module Endpoints
5
+ module Search
6
+ module Users
7
+ module Models
8
+ # Defines a user within a collection.
9
+ Index = Struct.new(
10
+ :avatar_url,
11
+ :events_url,
12
+ :followers_url,
13
+ :following_url,
14
+ :gists_url,
15
+ :gravatar_id,
16
+ :html_url,
17
+ :id,
18
+ :login,
19
+ :node_id,
20
+ :organizations_url,
21
+ :received_events_url,
22
+ :repos_url,
23
+ :score,
24
+ :site_admin,
25
+ :starred_url,
26
+ :subscriptions_url,
27
+ :type,
28
+ :url,
29
+ keyword_init: true
30
+ ) do
31
+ include Resultable
32
+
33
+ def initialize *arguments
34
+ super
35
+ freeze
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ghub
4
+ module Endpoints
5
+ module Search
6
+ module Users
7
+ module Responses
8
+ # Defines a user within a collection.
9
+ Index = Dry::Schema.Params do
10
+ required(:total_count).filled :integer
11
+ required(:incomplete_results).filled :bool
12
+ required(:items).array(:hash) do
13
+ required(:avatar_url).filled :string
14
+ required(:events_url).filled :string
15
+ required(:followers_url).filled :string
16
+ required(:following_url).filled :string
17
+ required(:gists_url).filled :string
18
+ required(:gravatar_id).maybe :string
19
+ required(:html_url).filled :string
20
+ required(:id).filled :integer
21
+ required(:login).filled :string
22
+ required(:node_id).filled :string
23
+ required(:organizations_url).filled :string
24
+ required(:received_events_url).filled :string
25
+ required(:repos_url).filled :string
26
+ required(:score).filled :float
27
+ required(:site_admin).filled :bool
28
+ required(:starred_url).filled :string
29
+ required(:subscriptions_url).filled :string
30
+ required(:type).filled :string
31
+ required(:url).filled :string
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ghub
4
+ module Endpoints
5
+ module Search
6
+ module Users
7
+ # Provides access to the search API endpoint for users.
8
+ class Root
9
+ include Users::Import[index_action: "actions.index"]
10
+
11
+ def index(...) = index_action.call(...)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -5,9 +5,9 @@ module Ghub
5
5
  module Resultable
6
6
  include Dry::Monads[:result]
7
7
 
8
- def self.included object
8
+ def self.included descendant
9
9
  super
10
- object.extend ClassMethods
10
+ descendant.extend ClassMethods
11
11
  end
12
12
 
13
13
  # Allows an object to be callable via a class method.
data/lib/ghub.rb CHANGED
@@ -6,11 +6,14 @@ require "zeitwerk"
6
6
 
7
7
  Dry::Schema.load_extensions :monads
8
8
 
9
- Zeitwerk::Loader.for_gem.then do |loader|
9
+ Zeitwerk::Loader.new.then do |loader|
10
10
  loader.inflector.inflect "api" => "API"
11
+ loader.tag = File.basename __FILE__, ".rb"
12
+ loader.push_dir __dir__
11
13
  loader.setup
12
14
  end
13
15
 
14
16
  # Main namespace.
15
17
  module Ghub
18
+ def self.loader(registry = Zeitwerk::Registry) = registry.loader_for __FILE__
16
19
  end
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.5.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -35,7 +35,7 @@ cert_chain:
35
35
  3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
36
36
  gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
37
37
  -----END CERTIFICATE-----
38
- date: 2023-06-19 00:00:00.000000000 Z
38
+ date: 2023-10-01 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: dry-container
@@ -206,6 +206,12 @@ files:
206
206
  - lib/ghub/endpoints/repositories/responses/index.rb
207
207
  - lib/ghub/endpoints/repositories/responses/show.rb
208
208
  - lib/ghub/endpoints/repositories/root.rb
209
+ - lib/ghub/endpoints/search/users/actions/index.rb
210
+ - lib/ghub/endpoints/search/users/container.rb
211
+ - lib/ghub/endpoints/search/users/import.rb
212
+ - lib/ghub/endpoints/search/users/models/index.rb
213
+ - lib/ghub/endpoints/search/users/responses/index.rb
214
+ - lib/ghub/endpoints/search/users/root.rb
209
215
  - lib/ghub/endpoints/users/actions/index.rb
210
216
  - lib/ghub/endpoints/users/actions/show.rb
211
217
  - lib/ghub/endpoints/users/container.rb
@@ -276,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
276
282
  - !ruby/object:Gem::Version
277
283
  version: '0'
278
284
  requirements: []
279
- rubygems_version: 3.4.14
285
+ rubygems_version: 3.4.20
280
286
  signing_key:
281
287
  specification_version: 4
282
288
  summary: A monadic GitHub API client.
metadata.gz.sig CHANGED
Binary file