ghub 0.0.0 → 2.3.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.adoc +42 -21
- data/ghub.gemspec +16 -13
- data/lib/ghub/api/client.rb +6 -6
- data/lib/ghub/api/page.rb +12 -8
- data/lib/ghub/client.rb +24 -23
- data/lib/ghub/configuration/content.rb +3 -1
- data/lib/ghub/configuration/loader.rb +3 -3
- data/lib/ghub/container.rb +7 -5
- data/lib/ghub/{import.rb → dependencies.rb} +1 -1
- data/lib/ghub/endpoints/branches/protection/actions/show.rb +6 -5
- data/lib/ghub/endpoints/branches/protection/actions/update.rb +7 -6
- data/lib/ghub/endpoints/branches/protection/container.rb +5 -7
- data/lib/ghub/endpoints/branches/protection/{import.rb → dependencies.rb} +1 -1
- data/lib/ghub/endpoints/branches/protection/models/show.rb +17 -16
- data/lib/ghub/endpoints/branches/protection/root.rb +3 -6
- data/lib/ghub/endpoints/branches/signature/container.rb +4 -6
- data/lib/ghub/endpoints/branches/signature/{import.rb → dependencies.rb} +1 -1
- data/lib/ghub/endpoints/branches/signature/root.rb +14 -13
- data/lib/ghub/endpoints/container.rb +3 -2
- data/lib/ghub/endpoints/{import.rb → dependencies.rb} +1 -1
- data/lib/ghub/endpoints/organizations/members/actions/index.rb +7 -6
- data/lib/ghub/endpoints/organizations/members/container.rb +4 -6
- data/lib/ghub/endpoints/organizations/members/{import.rb → dependencies.rb} +1 -1
- data/lib/ghub/endpoints/organizations/members/root.rb +1 -1
- data/lib/ghub/endpoints/pulls/actions/index.rb +7 -6
- data/lib/ghub/endpoints/pulls/actions/show.rb +6 -5
- data/lib/ghub/endpoints/pulls/container.rb +5 -7
- data/lib/ghub/endpoints/pulls/{import.rb → dependencies.rb} +1 -1
- data/lib/ghub/endpoints/pulls/models/show.rb +15 -14
- data/lib/ghub/endpoints/pulls/responses/show.rb +7 -7
- data/lib/ghub/endpoints/pulls/root.rb +1 -1
- data/lib/ghub/endpoints/repositories/actions/create.rb +15 -14
- data/lib/ghub/endpoints/repositories/actions/index.rb +7 -12
- data/lib/ghub/endpoints/repositories/actions/patch.rb +15 -14
- data/lib/ghub/endpoints/repositories/actions/show.rb +6 -11
- data/lib/ghub/endpoints/repositories/container.rb +7 -9
- data/lib/ghub/endpoints/repositories/{import.rb → dependencies.rb} +1 -1
- data/lib/ghub/endpoints/repositories/path.rb +3 -7
- data/lib/ghub/endpoints/repositories/root.rb +4 -3
- data/lib/ghub/endpoints/search/users/actions/index.rb +30 -0
- data/lib/ghub/endpoints/search/users/container.rb +28 -0
- data/lib/ghub/endpoints/search/users/dependencies.rb +13 -0
- data/lib/ghub/endpoints/search/users/models/index.rb +41 -0
- data/lib/ghub/endpoints/search/users/responses/index.rb +38 -0
- data/lib/ghub/endpoints/search/users/root.rb +16 -0
- data/lib/ghub/endpoints/users/actions/index.rb +7 -6
- data/lib/ghub/endpoints/users/actions/show.rb +7 -6
- data/lib/ghub/endpoints/users/container.rb +6 -8
- data/lib/ghub/endpoints/users/{import.rb → dependencies.rb} +1 -1
- data/lib/ghub/endpoints/users/models/index.rb +3 -4
- data/lib/ghub/endpoints/users/models/show.rb +3 -4
- data/lib/ghub/endpoints/users/root.rb +1 -1
- data/lib/ghub/models/application.rb +8 -7
- data/lib/ghub/models/boolean_link.rb +4 -2
- data/lib/ghub/models/branch.rb +8 -6
- data/lib/ghub/models/check.rb +2 -6
- data/lib/ghub/models/dismissal_restriction.rb +10 -9
- data/lib/ghub/models/label.rb +2 -3
- data/lib/ghub/models/license.rb +2 -3
- data/lib/ghub/models/link.rb +2 -2
- data/lib/ghub/models/links.rb +5 -6
- data/lib/ghub/models/owner.rb +2 -3
- data/lib/ghub/models/permissions/branch.rb +2 -3
- data/lib/ghub/models/permissions/repository.rb +2 -3
- data/lib/ghub/models/repository.rb +17 -11
- data/lib/ghub/models/restriction.rb +10 -9
- data/lib/ghub/models/review.rb +8 -7
- data/lib/ghub/models/status_check.rb +6 -5
- data/lib/ghub/models/team.rb +2 -3
- data/lib/ghub/models/user.rb +4 -3
- data/lib/ghub.rb +6 -1
- data.tar.gz.sig +0 -0
- metadata +90 -55
- metadata.gz.sig +0 -0
- data/lib/ghub/resultable.rb +0 -20
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "pipeable"
|
|
4
4
|
|
|
5
5
|
module Ghub
|
|
6
6
|
module Endpoints
|
|
@@ -8,34 +8,35 @@ module Ghub
|
|
|
8
8
|
module Signature
|
|
9
9
|
# Provides access to the branch signature API endpoint.
|
|
10
10
|
class Root
|
|
11
|
-
include
|
|
12
|
-
include
|
|
11
|
+
include Ghub::Dependencies[:api]
|
|
12
|
+
include Dependencies[response: "responses.show", model: "models.show"]
|
|
13
|
+
include Pipeable
|
|
13
14
|
|
|
14
|
-
PATH = "repos
|
|
15
|
+
PATH = "repos/%<owner>s/%<repository>s/branches/%<branch>s/protection/required_signatures"
|
|
15
16
|
|
|
16
|
-
def initialize
|
|
17
|
-
super(**
|
|
17
|
+
def initialize(path: PATH, **)
|
|
18
|
+
super(**)
|
|
18
19
|
@path = path
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
def show owner, repository, branch
|
|
22
23
|
pipe format(path, owner:, repository:, branch:),
|
|
23
|
-
to(
|
|
24
|
+
to(api, :get),
|
|
24
25
|
try(:parse, catch: JSON::ParserError),
|
|
25
|
-
validate(response),
|
|
26
|
-
to(model, :
|
|
26
|
+
validate(response, as: :to_h),
|
|
27
|
+
to(model, :for)
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
def create owner, repository, branch
|
|
30
31
|
pipe format(path, owner:, repository:, branch:),
|
|
31
|
-
to(
|
|
32
|
+
to(api, :post),
|
|
32
33
|
try(:parse, catch: JSON::ParserError),
|
|
33
|
-
validate(response),
|
|
34
|
-
to(model, :
|
|
34
|
+
validate(response, as: :to_h),
|
|
35
|
+
to(model, :for)
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
def destroy owner, repository, branch
|
|
38
|
-
|
|
39
|
+
api.delete format(path, owner:, repository:, branch:)
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
private
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "containable"
|
|
4
4
|
|
|
5
5
|
module Ghub
|
|
6
6
|
module Endpoints
|
|
7
7
|
# Defines endpoint dependencies.
|
|
8
8
|
module Container
|
|
9
|
-
extend
|
|
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 }
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "pipeable"
|
|
4
4
|
|
|
5
5
|
module Ghub
|
|
6
6
|
module Endpoints
|
|
@@ -9,19 +9,20 @@ module Ghub
|
|
|
9
9
|
module Actions
|
|
10
10
|
# Handles an organization member index action.
|
|
11
11
|
class Index
|
|
12
|
-
include
|
|
13
|
-
include
|
|
12
|
+
include Ghub::Dependencies[:api]
|
|
13
|
+
include Dependencies[response: "responses.index", model: "models.show"]
|
|
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(
|
|
20
|
+
to(api, :get),
|
|
20
21
|
try(:parse, catch: JSON::ParserError),
|
|
21
22
|
fmap { |body| {body:} },
|
|
22
|
-
validate(response),
|
|
23
|
+
validate(response, as: :to_h),
|
|
23
24
|
as(:fetch, :body),
|
|
24
|
-
map { |item| model.
|
|
25
|
+
map { |item| model.for(**item) }
|
|
25
26
|
)
|
|
26
27
|
end
|
|
27
28
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
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
|
|
12
|
-
|
|
13
|
-
merge Ghub::Container
|
|
11
|
+
extend Containable
|
|
14
12
|
|
|
15
13
|
namespace :responses do
|
|
16
|
-
register
|
|
14
|
+
register :index, Responses::Index
|
|
17
15
|
end
|
|
18
16
|
|
|
19
17
|
namespace :models do
|
|
20
|
-
register
|
|
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 Members
|
|
7
7
|
# Provides access to the organization members API endpoint.
|
|
8
8
|
class Root
|
|
9
|
-
include
|
|
9
|
+
include Dependencies[index_action: "actions.index"]
|
|
10
10
|
|
|
11
11
|
def index(...) = index_action.call(...)
|
|
12
12
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "pipeable"
|
|
4
4
|
|
|
5
5
|
module Ghub
|
|
6
6
|
module Endpoints
|
|
@@ -8,17 +8,18 @@ module Ghub
|
|
|
8
8
|
module Actions
|
|
9
9
|
# Handles a repository index action.
|
|
10
10
|
class Index
|
|
11
|
-
include
|
|
12
|
-
include
|
|
11
|
+
include Ghub::Dependencies[:api]
|
|
12
|
+
include Dependencies[response: "responses.index", model: "models.show"]
|
|
13
|
+
include Pipeable
|
|
13
14
|
|
|
14
15
|
def call owner, repository, **parameters
|
|
15
16
|
pipe(
|
|
16
|
-
|
|
17
|
+
api.get("repos/#{owner}/#{repository}/pulls", **parameters),
|
|
17
18
|
try(:parse, catch: JSON::ParserError),
|
|
18
19
|
fmap { |body| {body:} },
|
|
19
|
-
validate(response),
|
|
20
|
+
validate(response, as: :to_h),
|
|
20
21
|
as(:fetch, :body),
|
|
21
|
-
map { |item| model.for
|
|
22
|
+
map { |item| model.for(**item) }
|
|
22
23
|
)
|
|
23
24
|
end
|
|
24
25
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "pipeable"
|
|
4
4
|
|
|
5
5
|
module Ghub
|
|
6
6
|
module Endpoints
|
|
@@ -8,14 +8,15 @@ module Ghub
|
|
|
8
8
|
module Actions
|
|
9
9
|
# Handles a repository index action.
|
|
10
10
|
class Show
|
|
11
|
-
include
|
|
12
|
-
include
|
|
11
|
+
include Ghub::Dependencies[:api]
|
|
12
|
+
include Dependencies[response: "responses.show", model: "models.show"]
|
|
13
|
+
include Pipeable
|
|
13
14
|
|
|
14
15
|
def call owner, repository, id, **parameters
|
|
15
16
|
pipe(
|
|
16
|
-
|
|
17
|
+
api.get("repos/#{owner}/#{repository}/pulls/#{id}", **parameters),
|
|
17
18
|
try(:parse, catch: JSON::ParserError),
|
|
18
|
-
validate(response),
|
|
19
|
+
validate(response, as: :to_h),
|
|
19
20
|
to(model, :for)
|
|
20
21
|
)
|
|
21
22
|
end
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
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
|
|
11
|
-
|
|
12
|
-
merge Ghub::Container
|
|
10
|
+
extend Containable
|
|
13
11
|
|
|
14
12
|
namespace :responses do
|
|
15
|
-
register
|
|
16
|
-
register
|
|
13
|
+
register :index, Responses::Index
|
|
14
|
+
register :show, Responses::Show
|
|
17
15
|
end
|
|
18
16
|
|
|
19
17
|
namespace :models do
|
|
20
|
-
register
|
|
18
|
+
register :show, Models::Show
|
|
21
19
|
end
|
|
22
20
|
|
|
23
21
|
namespace :actions do
|
|
@@ -32,7 +32,7 @@ module Ghub
|
|
|
32
32
|
:labels,
|
|
33
33
|
:locked,
|
|
34
34
|
:maintainer_can_modify,
|
|
35
|
-
:
|
|
35
|
+
:mergeable,
|
|
36
36
|
:merge_commit_sha,
|
|
37
37
|
:mergeable_state,
|
|
38
38
|
:merged,
|
|
@@ -53,24 +53,25 @@ module Ghub
|
|
|
53
53
|
:title,
|
|
54
54
|
:updated_at,
|
|
55
55
|
:url,
|
|
56
|
-
:user
|
|
57
|
-
keyword_init: true
|
|
56
|
+
:user
|
|
58
57
|
) do
|
|
59
|
-
|
|
58
|
+
def self.for **attributes
|
|
59
|
+
assignee = attributes[:assignee]
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
new(
|
|
62
|
+
**attributes.merge!(
|
|
63
|
+
_links: Ghub::Models::Links.for(**attributes[:_links]),
|
|
64
|
+
assignee: (Ghub::Models::User[**assignee] if assignee),
|
|
65
|
+
assignees: attributes[:assignees].map { |data| Ghub::Models::User[**data] },
|
|
66
|
+
base: Ghub::Models::Branch[**attributes[:base]],
|
|
67
|
+
head: Ghub::Models::Branch[**attributes[:head]],
|
|
68
|
+
labels: attributes[:labels].map { |data| Ghub::Models::Label[**data] },
|
|
69
|
+
user: Ghub::Models::User[**attributes[:user]]
|
|
70
|
+
)
|
|
70
71
|
)
|
|
71
72
|
end
|
|
72
73
|
|
|
73
|
-
def initialize
|
|
74
|
+
def initialize(**)
|
|
74
75
|
super
|
|
75
76
|
freeze
|
|
76
77
|
end
|
|
@@ -6,13 +6,13 @@ module Ghub
|
|
|
6
6
|
module Responses
|
|
7
7
|
# Defines a single pull request.
|
|
8
8
|
Show = Dry::Schema.Params do
|
|
9
|
-
required(:_links).hash
|
|
9
|
+
required(:_links).hash Ghub::Responses::Links
|
|
10
10
|
required(:active_lock_reason).maybe :string
|
|
11
|
-
required(:assignee).hash
|
|
12
|
-
required(:assignees).array
|
|
11
|
+
required(:assignee).maybe :hash, Ghub::Responses::User
|
|
12
|
+
required(:assignees).array Ghub::Responses::User
|
|
13
13
|
required(:author_association).filled :string
|
|
14
14
|
required(:auto_merge).maybe :bool
|
|
15
|
-
required(:base).hash
|
|
15
|
+
required(:base).hash Ghub::Responses::Branch
|
|
16
16
|
required(:body).filled :string
|
|
17
17
|
required(:closed_at).filled :string
|
|
18
18
|
required(:comments_url).filled :string
|
|
@@ -20,11 +20,11 @@ module Ghub
|
|
|
20
20
|
required(:created_at).filled :string
|
|
21
21
|
required(:diff_url).filled :string
|
|
22
22
|
required(:draft).filled :bool
|
|
23
|
-
required(:head).hash
|
|
23
|
+
required(:head).hash Ghub::Responses::Branch
|
|
24
24
|
required(:html_url).filled :string
|
|
25
25
|
required(:id).filled :integer
|
|
26
26
|
required(:issue_url).filled :string
|
|
27
|
-
required(:labels).array
|
|
27
|
+
required(:labels).array Ghub::Responses::Label
|
|
28
28
|
required(:locked).filled :bool
|
|
29
29
|
required(:merge_commit_sha).filled :string
|
|
30
30
|
required(:merged_at).maybe :date_time
|
|
@@ -41,7 +41,7 @@ module Ghub
|
|
|
41
41
|
required(:title).filled :string
|
|
42
42
|
required(:updated_at).filled :string
|
|
43
43
|
required(:url).filled :string
|
|
44
|
-
required(:user).hash
|
|
44
|
+
required(:user).hash Ghub::Responses::User
|
|
45
45
|
|
|
46
46
|
optional(:additions).filled :integer
|
|
47
47
|
optional(:changed_files).filled :integer
|
|
@@ -5,7 +5,7 @@ module Ghub
|
|
|
5
5
|
module Pulls
|
|
6
6
|
# Provides access to the pulls API endpoint.
|
|
7
7
|
class Root
|
|
8
|
-
include
|
|
8
|
+
include Dependencies[index_action: "actions.index", show_action: "actions.show"]
|
|
9
9
|
|
|
10
10
|
def index(...) = index_action.call(...)
|
|
11
11
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "pipeable"
|
|
4
4
|
|
|
5
5
|
module Ghub
|
|
6
6
|
module Endpoints
|
|
@@ -8,27 +8,28 @@ module Ghub
|
|
|
8
8
|
module Actions
|
|
9
9
|
# Handles a repository create action.
|
|
10
10
|
class Create
|
|
11
|
-
include
|
|
12
|
-
|
|
11
|
+
include Ghub::Dependencies[:api]
|
|
12
|
+
|
|
13
|
+
include Dependencies[
|
|
13
14
|
:path,
|
|
14
15
|
request: "requests.create",
|
|
15
16
|
response: "responses.show",
|
|
16
17
|
model: "models.show"
|
|
17
18
|
]
|
|
18
19
|
|
|
19
|
-
include
|
|
20
|
+
include Pipeable
|
|
20
21
|
|
|
21
22
|
def call kind, body, owner: nil, **parameters
|
|
22
|
-
path.create(kind, owner:)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
path.create(kind, owner:).bind do |url_path|
|
|
24
|
+
pipe body,
|
|
25
|
+
validate(request),
|
|
26
|
+
insert(url_path, at: 0),
|
|
27
|
+
insert(parameters),
|
|
28
|
+
to(api, :post),
|
|
29
|
+
try(:parse, catch: JSON::ParserError),
|
|
30
|
+
validate(response, as: :to_h),
|
|
31
|
+
to(model, :for)
|
|
32
|
+
end
|
|
32
33
|
end
|
|
33
34
|
end
|
|
34
35
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "pipeable"
|
|
4
4
|
|
|
5
5
|
module Ghub
|
|
6
6
|
module Endpoints
|
|
@@ -8,25 +8,20 @@ module Ghub
|
|
|
8
8
|
module Actions
|
|
9
9
|
# Handles a repository index action.
|
|
10
10
|
class Index
|
|
11
|
-
include
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
response: "responses.index",
|
|
15
|
-
model: "models.show"
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
include Transactable
|
|
11
|
+
include Ghub::Dependencies[:api]
|
|
12
|
+
include Dependencies[:path, response: "responses.index", model: "models.show"]
|
|
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(
|
|
19
|
+
to(api, :get),
|
|
25
20
|
try(:parse, catch: JSON::ParserError),
|
|
26
21
|
fmap { |body| {body:} },
|
|
27
|
-
validate(response),
|
|
22
|
+
validate(response, as: :to_h),
|
|
28
23
|
as(:fetch, :body),
|
|
29
|
-
map { |item| model.for
|
|
24
|
+
map { |item| model.for(**item) }
|
|
30
25
|
)
|
|
31
26
|
end
|
|
32
27
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "pipeable"
|
|
4
4
|
|
|
5
5
|
module Ghub
|
|
6
6
|
module Endpoints
|
|
@@ -8,27 +8,28 @@ module Ghub
|
|
|
8
8
|
module Actions
|
|
9
9
|
# Handles a repository patch action.
|
|
10
10
|
class Patch
|
|
11
|
-
include
|
|
12
|
-
|
|
11
|
+
include Ghub::Dependencies[:api]
|
|
12
|
+
|
|
13
|
+
include Dependencies[
|
|
13
14
|
:path,
|
|
14
15
|
request: "requests.patch",
|
|
15
16
|
response: "responses.show",
|
|
16
17
|
model: "models.show"
|
|
17
18
|
]
|
|
18
19
|
|
|
19
|
-
include
|
|
20
|
+
include Pipeable
|
|
20
21
|
|
|
21
22
|
def call owner, id, body, **parameters
|
|
22
|
-
path.patch(owner, id)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
path.patch(owner, id).bind do |url_path|
|
|
24
|
+
pipe body,
|
|
25
|
+
validate(request),
|
|
26
|
+
insert(url_path, at: 0),
|
|
27
|
+
insert(parameters),
|
|
28
|
+
to(api, :patch),
|
|
29
|
+
try(:parse, catch: JSON::ParserError),
|
|
30
|
+
validate(response, as: :to_h),
|
|
31
|
+
to(model, :for)
|
|
32
|
+
end
|
|
32
33
|
end
|
|
33
34
|
end
|
|
34
35
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "pipeable"
|
|
4
4
|
|
|
5
5
|
module Ghub
|
|
6
6
|
module Endpoints
|
|
@@ -8,21 +8,16 @@ module Ghub
|
|
|
8
8
|
module Actions
|
|
9
9
|
# Handles a repository show action.
|
|
10
10
|
class Show
|
|
11
|
-
include
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
response: "responses.show",
|
|
15
|
-
model: "models.show"
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
include Transactable
|
|
11
|
+
include Ghub::Dependencies[:api]
|
|
12
|
+
include Dependencies[:path, response: "responses.show", model: "models.show"]
|
|
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(
|
|
18
|
+
to(api, :get),
|
|
24
19
|
try(:parse, catch: JSON::ParserError),
|
|
25
|
-
validate(response),
|
|
20
|
+
validate(response, as: :to_h),
|
|
26
21
|
to(model, :for)
|
|
27
22
|
end
|
|
28
23
|
end
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
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
|
|
11
|
-
|
|
12
|
-
merge Ghub::Container
|
|
10
|
+
extend Containable
|
|
13
11
|
|
|
14
12
|
namespace :requests do
|
|
15
|
-
register
|
|
16
|
-
register
|
|
13
|
+
register :create, Requests::Create
|
|
14
|
+
register :patch, Requests::Patch
|
|
17
15
|
end
|
|
18
16
|
|
|
19
17
|
namespace :responses do
|
|
20
|
-
register
|
|
21
|
-
register
|
|
18
|
+
register :index, Responses::Index
|
|
19
|
+
register :show, Ghub::Responses::Repository
|
|
22
20
|
end
|
|
23
21
|
|
|
24
22
|
namespace :models do
|
|
25
|
-
register
|
|
23
|
+
register :show, Ghub::Models::Repository
|
|
26
24
|
end
|
|
27
25
|
|
|
28
26
|
register(:path) { Path.new }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "dry/monads"
|
|
4
|
-
require "refinements/
|
|
4
|
+
require "refinements/array"
|
|
5
5
|
|
|
6
6
|
module Ghub
|
|
7
7
|
module Endpoints
|
|
@@ -10,7 +10,7 @@ module Ghub
|
|
|
10
10
|
class Path
|
|
11
11
|
include Dry::Monads[:result]
|
|
12
12
|
|
|
13
|
-
using Refinements::
|
|
13
|
+
using Refinements::Array
|
|
14
14
|
|
|
15
15
|
KINDS = %w[users orgs].freeze
|
|
16
16
|
|
|
@@ -43,11 +43,7 @@ module Ghub
|
|
|
43
43
|
|
|
44
44
|
def resource(owner, id) = Success "repos/#{owner}/#{id}"
|
|
45
45
|
|
|
46
|
-
def error kind
|
|
47
|
-
kinds.map(&:inspect)
|
|
48
|
-
.to_sentence(conjunction: "or")
|
|
49
|
-
.then { |choices| Failure "Invalid kind: #{kind.inspect}. Use: #{choices}." }
|
|
50
|
-
end
|
|
46
|
+
def error(kind) = Failure %(Invalid kind: #{kind.inspect}. Use: #{kinds.to_usage "or"}.)
|
|
51
47
|
end
|
|
52
48
|
end
|
|
53
49
|
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
|
|
9
|
-
|
|
8
|
+
include Ghub::Dependencies[:api]
|
|
9
|
+
|
|
10
|
+
include Dependencies[
|
|
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) =
|
|
25
|
+
def destroy(owner, id) = api.delete "repos/#{owner}/#{id}"
|
|
25
26
|
end
|
|
26
27
|
end
|
|
27
28
|
end
|