ghub 0.3.0 → 0.4.1

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: 96b84a0c19eecb20f22e880efbe6dc98c8b487a0a4b3c2439e801385ff8b87cc
4
- data.tar.gz: 2b21819675c236e86020955566c4a606cdcd63511ba59b9ad2fdb963a672118a
3
+ metadata.gz: a91750b2be81431cc3f99587a763b31336aace7f73aa718d5d7f8077fe49676f
4
+ data.tar.gz: 2f4cdf71903e5bad8bc7250f6a207c3bed8d0072bda181409b859c1efa05398d
5
5
  SHA512:
6
- metadata.gz: 65fc3607531672ef9b3d5eba15d622afbcde73e672fbb81405adcb246d3b589e2711043ffda025de58a3e34445f763153ed974eeb9a54f71c4b3ff4ef61d2b2b
7
- data.tar.gz: 51786f853f2ac9bb5df018db2ca3bf0df1dd5a5aa0f25c8cd134200df6ed46fb199af770df87d3bdca30585522b21027d2ad168622af3f08f9d786679d50a61c
6
+ metadata.gz: 4853350c3f35a07da02797298e06644599030026d79f42bcf861aaf8392bf724831b52f172fca5bc68b4dc99884ee6aed478ccae1195e7829e767194f699ef98
7
+ data.tar.gz: 32c88bfcb34a396a9d8b49f848275261da0ba996b281ccadf68f553955b9fcb12be7e9cf6b77565616ee6e3181d82f47d1255e0aa242c801fba3a593f50c9a65
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -126,19 +126,27 @@ The following documents how to interact with repositories:
126
126
 
127
127
  [source,ruby]
128
128
  ----
129
- client.repositories.index "<owner>", "<repository>"
130
- client.repositories.show "<owner>", "<repository>"
129
+ # Index (user and organization)
130
+ # Format: client.repositories.index :<kind>, "<owner>"
131
+ client.repositories.index :users, "doe"
132
+ client.repositories.index :orgs, "acme"
131
133
 
132
- # For a user.
133
- # Example: client.repositories.create :users, {name: "ghub-test", private: true}
134
- client.repositories.create :users, <attributes>
134
+ # Show (user or organization)
135
+ # Format: client.repositories.show "<owner>", "<repository>"
136
+ client.repositories.show "acme", "ghub-test"
135
137
 
136
- # For an organization.
137
- # Example: client.repositories.create :orgs, {name: "ghub-test", private: true}, owner: "acme"
138
- client.repositories.create :orgs, <attributes>, owner: "<organization>"
138
+ # Create (user and organization)
139
+ # Format: client.repositories.create :<kind>, <body>
140
+ client.repositories.create :users, {name: "ghub-test", private: true}
141
+ client.repositories.create :orgs, {name: "ghub-test", private: true}, owner: "acme"
139
142
 
140
- client.repositories.patch "<owner>", {description: "For test only."}
141
- client.repositories.destroy "<owner>", <id>
143
+ # Patch (user or organization)
144
+ # Format: client.repositories.patch "<owner>", "<repository>", <body>
145
+ client.repositories.patch "acme", "ghub-test", {description: "For test only."}
146
+
147
+ # Destroy (user or organization)
148
+ # Format: client.repositories.destroy "<owner>", "<repository>"
149
+ client.repositories.destroy "acme", "ghub-test"
142
150
  ----
143
151
 
144
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.
@@ -177,7 +185,7 @@ To test, run:
177
185
 
178
186
  [source,bash]
179
187
  ----
180
- bundle exec rake
188
+ bin/rake
181
189
  ----
182
190
 
183
191
  == link:https://www.alchemists.io/policies/license[License]
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.3.0"
5
+ spec.version = "0.4.1"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://www.alchemists.io/projects/ghub"
@@ -9,8 +9,8 @@ module Ghub
9
9
  include Import[:configuration, :http]
10
10
  include Dry::Monads[:result]
11
11
 
12
- def initialize page: Page, **dependencies
13
- super(**dependencies)
12
+ def initialize(page: Page, **)
13
+ super(**)
14
14
  @page = page
15
15
  end
16
16
 
data/lib/ghub/client.rb CHANGED
@@ -14,8 +14,8 @@ module Ghub
14
14
  users_endpoint: :users
15
15
  ]
16
16
 
17
- def initialize **dependencies
18
- super(**dependencies)
17
+ def initialize(**)
18
+ super(**)
19
19
  yield configuration if block_given?
20
20
  end
21
21
 
@@ -13,8 +13,8 @@ module Ghub
13
13
 
14
14
  PATH = "repos/%{owner}/%{repository}/branches/%{branch}/protection/required_signatures"
15
15
 
16
- def initialize path: PATH, **dependencies
17
- super(**dependencies)
16
+ def initialize(path: PATH, **)
17
+ super(**)
18
18
  @path = path
19
19
  end
20
20
 
@@ -32,7 +32,7 @@ module Ghub
32
32
  :labels,
33
33
  :locked,
34
34
  :maintainer_can_modify,
35
- :mergable,
35
+ :mergeable,
36
36
  :merge_commit_sha,
37
37
  :mergeable_state,
38
38
  :merged,
@@ -59,9 +59,11 @@ module Ghub
59
59
  include Resultable
60
60
 
61
61
  def self.for attributes
62
+ assignee = attributes[:assignee]
63
+
62
64
  new attributes.merge(
63
65
  _links: Ghub::Models::Links.for(attributes[:_links]),
64
- assignee: Ghub::Models::User[attributes[:assignee]],
66
+ assignee: (Ghub::Models::User[assignee] if assignee),
65
67
  assignees: attributes[:assignees].map { |data| Ghub::Models::User[data] },
66
68
  base: Ghub::Models::Branch[attributes[:base]],
67
69
  head: Ghub::Models::Branch[attributes[:head]],
@@ -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(Ghub::Responses::Links)
9
+ required(:_links).hash Ghub::Responses::Links
10
10
  required(:active_lock_reason).maybe :string
11
- required(:assignee).hash(Ghub::Responses::User)
12
- required(:assignees).array(Ghub::Responses::User)
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(Ghub::Responses::Branch)
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(Ghub::Responses::Branch)
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(Ghub::Responses::Label)
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(Ghub::Responses::User)
44
+ required(:user).hash Ghub::Responses::User
45
45
 
46
46
  optional(:additions).filled :integer
47
47
  optional(:changed_files).filled :integer
@@ -19,16 +19,16 @@ module Ghub
19
19
  include Transactable
20
20
 
21
21
  def call kind, body, owner: nil, **parameters
22
- path.create(kind, owner:)
23
- .bind do |url_path|
24
- pipe body,
25
- validate(request),
26
- insert(url_path, parameters, at: 0),
27
- to(client, :post),
28
- try(:parse, catch: JSON::ParserError),
29
- validate(response),
30
- to(model, :for)
31
- end
22
+ path.create(kind, owner:).bind do |url_path|
23
+ pipe body,
24
+ validate(request),
25
+ insert(url_path, at: 0),
26
+ insert(parameters),
27
+ to(client, :post),
28
+ try(:parse, catch: JSON::ParserError),
29
+ validate(response),
30
+ to(model, :for)
31
+ end
32
32
  end
33
33
  end
34
34
  end
@@ -19,16 +19,16 @@ module Ghub
19
19
  include Transactable
20
20
 
21
21
  def call owner, id, body, **parameters
22
- path.patch(owner, id)
23
- .bind do |url_path|
24
- pipe body,
25
- validate(request),
26
- insert(url_path, parameters, at: 0),
27
- to(client, :patch),
28
- try(:parse, catch: JSON::ParserError),
29
- validate(response),
30
- to(model, :for)
31
- end
22
+ path.patch(owner, id).bind do |url_path|
23
+ pipe body,
24
+ validate(request),
25
+ insert(url_path, at: 0),
26
+ insert(parameters),
27
+ to(client, :patch),
28
+ try(:parse, catch: JSON::ParserError),
29
+ validate(response),
30
+ to(model, :for)
31
+ end
32
32
  end
33
33
  end
34
34
  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.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,7 +28,7 @@ cert_chain:
28
28
  CxDe2+VuChj4I1nvIHdu+E6XoEVlanUPKmSg6nddhkKn2gC45Kyzh6FZqnzH/CRp
29
29
  RFE=
30
30
  -----END CERTIFICATE-----
31
- date: 2022-12-27 00:00:00.000000000 Z
31
+ date: 2023-02-05 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: dry-container
@@ -269,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
269
  - !ruby/object:Gem::Version
270
270
  version: '0'
271
271
  requirements: []
272
- rubygems_version: 3.4.1
272
+ rubygems_version: 3.4.6
273
273
  signing_key:
274
274
  specification_version: 4
275
275
  summary: A monadic GitHub API client.
metadata.gz.sig CHANGED
Binary file