ghub 0.3.0 → 0.4.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: 96b84a0c19eecb20f22e880efbe6dc98c8b487a0a4b3c2439e801385ff8b87cc
4
- data.tar.gz: 2b21819675c236e86020955566c4a606cdcd63511ba59b9ad2fdb963a672118a
3
+ metadata.gz: 86ed95e15942ee666a5e4094d1d5d7e77daed1886228491ba556cefa20cb9802
4
+ data.tar.gz: 555ba2c32b311df27c11965749a1caece8ef1e55561c72941524fdec862b4fef
5
5
  SHA512:
6
- metadata.gz: 65fc3607531672ef9b3d5eba15d622afbcde73e672fbb81405adcb246d3b589e2711043ffda025de58a3e34445f763153ed974eeb9a54f71c4b3ff4ef61d2b2b
7
- data.tar.gz: 51786f853f2ac9bb5df018db2ca3bf0df1dd5a5aa0f25c8cd134200df6ed46fb199af770df87d3bdca30585522b21027d2ad168622af3f08f9d786679d50a61c
6
+ metadata.gz: 463c48c1e6a9407ab559bcc1a585affd67afc1f1f97d5db28c55e5cd56815ac6b8b402d14f0cd3b3c0424616ad4eb4cd5d7c085578c2e2a754dd99810f4cc14b
7
+ data.tar.gz: 36b9c113333d009fd8c71319bda53c1ba41bfb155f6d5f2bb6b7777b47de0c7a245ee69b6b219a904ff332bf1bb78c2fd55dc2ea878b3aca8ee32157dff975b0
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>"
131
-
132
- # For a user.
133
- # Example: client.repositories.create :users, {name: "ghub-test", private: true}
134
- client.repositories.create :users, <attributes>
135
-
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>"
139
-
140
- client.repositories.patch "<owner>", {description: "For test only."}
141
- client.repositories.destroy "<owner>", <id>
129
+ # Index (user and organization)
130
+ # Format: client.repositories.index :<kind>, "<owner>"
131
+ client.repositories.index :users, "doe"
132
+ client.repositories.index :orgs, "acme"
133
+
134
+ # Show (user or organization)
135
+ # Format: client.repositories.show "<owner>", "<repository>"
136
+ client.repositories.show "acme", "ghub-test"
137
+
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"
142
+
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.
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.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://www.alchemists.io/projects/ghub"
@@ -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.0
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-01-08 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.2
273
273
  signing_key:
274
274
  specification_version: 4
275
275
  summary: A monadic GitHub API client.
metadata.gz.sig CHANGED
Binary file