github_api 0.9.0 → 0.9.1
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.
- data/README.md +50 -5
- data/features/cassettes/git_data/commits/get.yml +69 -0
- data/features/git_data/commmits.feature +14 -0
- data/lib/github_api.rb +1 -0
- data/lib/github_api/activity/events.rb +42 -33
- data/lib/github_api/activity/notifications.rb +22 -22
- data/lib/github_api/activity/starring.rb +16 -21
- data/lib/github_api/activity/watching.rb +16 -19
- data/lib/github_api/api.rb +51 -8
- data/lib/github_api/arguments.rb +155 -0
- data/lib/github_api/authorizations.rb +19 -20
- data/lib/github_api/configuration.rb +5 -0
- data/lib/github_api/emojis.rb +3 -3
- data/lib/github_api/error/validations.rb +2 -2
- data/lib/github_api/gists.rb +32 -42
- data/lib/github_api/gists/comments.rb +21 -23
- data/lib/github_api/git_data/blobs.rb +13 -16
- data/lib/github_api/git_data/commits.rb +12 -10
- data/lib/github_api/git_data/references.rb +24 -28
- data/lib/github_api/git_data/tags.rb +9 -11
- data/lib/github_api/git_data/trees.rb +10 -13
- data/lib/github_api/gitignore.rb +4 -6
- data/lib/github_api/issues.rb +24 -32
- data/lib/github_api/issues/assignees.rb +11 -8
- data/lib/github_api/issues/comments.rb +21 -26
- data/lib/github_api/issues/events.rb +7 -9
- data/lib/github_api/issues/labels.rb +39 -53
- data/lib/github_api/issues/milestones.rb +26 -33
- data/lib/github_api/markdown.rb +5 -6
- data/lib/github_api/meta.rb +3 -3
- data/lib/github_api/orgs.rb +10 -11
- data/lib/github_api/orgs/members.rb +18 -20
- data/lib/github_api/orgs/teams.rb +54 -58
- data/lib/github_api/pull_requests.rb +40 -54
- data/lib/github_api/pull_requests/comments.rb +19 -26
- data/lib/github_api/repos.rb +146 -101
- data/lib/github_api/repos/collaborators.rb +29 -30
- data/lib/github_api/repos/comments.rb +20 -25
- data/lib/github_api/repos/commits.rb +12 -14
- data/lib/github_api/repos/contents.rb +22 -14
- data/lib/github_api/repos/downloads.rb +19 -23
- data/lib/github_api/repos/forks.rb +6 -11
- data/lib/github_api/repos/hooks.rb +25 -34
- data/lib/github_api/repos/keys.rb +25 -27
- data/lib/github_api/repos/merging.rb +7 -6
- data/lib/github_api/repos/pub_sub_hubbub.rb +14 -18
- data/lib/github_api/repos/statuses.rb +13 -14
- data/lib/github_api/say.rb +1 -3
- data/lib/github_api/search.rb +12 -21
- data/lib/github_api/users.rb +10 -9
- data/lib/github_api/users/emails.rb +11 -9
- data/lib/github_api/users/followers.rb +25 -23
- data/lib/github_api/users/keys.rb +27 -29
- data/lib/github_api/version.rb +1 -1
- data/spec/github/activity/events/org_spec.rb +6 -6
- data/spec/github/activity/events/performed_spec.rb +1 -1
- data/spec/github/activity/events/received_spec.rb +1 -1
- data/spec/github/activity/events/user_org_spec.rb +4 -2
- data/spec/github/activity/notifications/create_spec.rb +1 -1
- data/spec/github/activity/notifications/delete_spec.rb +1 -1
- data/spec/github/activity/notifications/get_spec.rb +1 -1
- data/spec/github/activity/notifications/subscribed_spec.rb +1 -1
- data/spec/github/activity/starring/list_spec.rb +2 -0
- data/spec/github/activity/starring/starring_spec.rb +1 -1
- data/spec/github/activity/watching/list_spec.rb +2 -0
- data/spec/github/activity/watching/watching_spec.rb +1 -3
- data/spec/github/api/set_spec.rb +18 -4
- data/spec/github/api/with_spec.rb +28 -0
- data/spec/github/api_spec.rb +11 -33
- data/spec/github/arguments/parse_spec.rb +68 -0
- data/spec/github/authorizations/delete_spec.rb +1 -1
- data/spec/github/authorizations/get_spec.rb +1 -1
- data/spec/github/error/validations_spec.rb +3 -3
- data/spec/github/gists/comments/list_spec.rb +1 -1
- data/spec/github/gists/delete_spec.rb +1 -1
- data/spec/github/gists/fork_spec.rb +1 -1
- data/spec/github/gists/get_spec.rb +1 -1
- data/spec/github/gists/is_starred_spec.rb +2 -0
- data/spec/github/gists/star_spec.rb +1 -1
- data/spec/github/gists/unstar_spec.rb +1 -1
- data/spec/github/git_data/blobs/create_spec.rb +2 -0
- data/spec/github/git_data/blobs/get_spec.rb +1 -1
- data/spec/github/git_data/commits/create_spec.rb +2 -0
- data/spec/github/git_data/commits/get_spec.rb +3 -3
- data/spec/github/git_data/references/create_spec.rb +1 -1
- data/spec/github/git_data/references/delete_spec.rb +3 -1
- data/spec/github/git_data/tags/create_spec.rb +2 -0
- data/spec/github/gitignore/get_spec.rb +1 -1
- data/spec/github/issues/events/get_spec.rb +3 -1
- data/spec/github/issues/events/list_spec.rb +3 -1
- data/spec/github/issues/labels/add_spec.rb +6 -6
- data/spec/github/issues/labels/list_spec.rb +3 -1
- data/spec/github/issues/labels/replace_spec.rb +6 -7
- data/spec/github/issues/milestones/get_spec.rb +2 -0
- data/spec/github/normalizer_spec.rb +18 -6
- data/spec/github/orgs/members/conceal_spec.rb +6 -4
- data/spec/github/orgs/members/delete_spec.rb +2 -0
- data/spec/github/orgs/members/list_spec.rb +1 -1
- data/spec/github/orgs/members/member_spec.rb +3 -1
- data/spec/github/orgs/members/publicize_spec.rb +2 -0
- data/spec/github/orgs/teams/add_member_spec.rb +2 -0
- data/spec/github/orgs/teams/create_spec.rb +1 -1
- data/spec/github/orgs/teams/delete_spec.rb +1 -1
- data/spec/github/orgs/teams/edit_spec.rb +1 -1
- data/spec/github/orgs/teams/get_spec.rb +1 -1
- data/spec/github/orgs/teams/list_spec.rb +1 -1
- data/spec/github/orgs/teams/team_member_spec.rb +3 -1
- data/spec/github/parameter_filter_spec.rb +19 -58
- data/spec/github/pull_requests/comments/create_spec.rb +3 -1
- data/spec/github/pull_requests/comments/delete_spec.rb +1 -1
- data/spec/github/pull_requests/comments/edit_spec.rb +2 -0
- data/spec/github/pull_requests/comments/get_spec.rb +3 -1
- data/spec/github/pull_requests/comments/list_spec.rb +3 -1
- data/spec/github/pull_requests/commits_spec.rb +3 -3
- data/spec/github/pull_requests/create_spec.rb +4 -0
- data/spec/github/pull_requests/files_spec.rb +4 -0
- data/spec/github/pull_requests/get_spec.rb +3 -3
- data/spec/github/pull_requests/list_spec.rb +3 -3
- data/spec/github/pull_requests/merge_spec.rb +2 -0
- data/spec/github/pull_requests/merged_spec.rb +3 -1
- data/spec/github/pull_requests/update_spec.rb +4 -0
- data/spec/github/repos/collaborators/add_spec.rb +3 -1
- data/spec/github/repos/collaborators/get_spec.rb +1 -3
- data/spec/github/repos/collaborators/list_spec.rb +5 -1
- data/spec/github/repos/collaborators/remove_spec.rb +3 -1
- data/spec/github/repos/comments/create_spec.rb +4 -0
- data/spec/github/repos/comments/delete_spec.rb +2 -2
- data/spec/github/repos/comments/get_spec.rb +6 -2
- data/spec/github/repos/commits/compare_spec.rb +3 -3
- data/spec/github/repos/commits/get_spec.rb +3 -3
- data/spec/github/repos/commits/list_spec.rb +3 -3
- data/spec/github/repos/contents/archive_spec.rb +12 -0
- data/spec/github/repos/contents/get_spec.rb +5 -0
- data/spec/github/repos/contributors_spec.rb +7 -2
- data/spec/github/repos/downloads/create_spec.rb +4 -0
- data/spec/github/repos/downloads/delete_spec.rb +5 -1
- data/spec/github/repos/downloads/get_spec.rb +3 -1
- data/spec/github/repos/downloads/list_spec.rb +3 -1
- data/spec/github/repos/forks/create_spec.rb +2 -0
- data/spec/github/repos/forks/list_spec.rb +3 -1
- data/spec/github/repos/hooks/edit_spec.rb +1 -1
- data/spec/github/repos/keys/delete_spec.rb +1 -1
- data/spec/github/repos/keys/edit_spec.rb +2 -0
- data/spec/github/repos/keys/get_spec.rb +3 -1
- data/spec/github/repos/keys/list_spec.rb +4 -2
- data/spec/github/repos/list_spec.rb +6 -1
- data/spec/github/repos/pub_sub_hubbub/subscribe_service_spec.rb +27 -0
- data/spec/github/repos/pub_sub_hubbub/subscribe_spec.rb +51 -0
- data/spec/github/repos/pub_sub_hubbub/unsubscribe_service_spec.rb +21 -0
- data/spec/github/repos/pub_sub_hubbub/unsubscribe_spec.rb +58 -0
- data/spec/github/repos/statuses/create_spec.rb +2 -0
- data/spec/github/search_spec.rb +25 -10
- data/spec/github/users/followers/follow_spec.rb +1 -1
- data/spec/github/users/followers/is_following_spec.rb +1 -1
- data/spec/github/users/followers/unfollow_spec.rb +1 -1
- data/spec/github/users/keys/delete_spec.rb +1 -1
- data/spec/github/users/keys/get_spec.rb +1 -1
- data/spec/github/users/keys/update_spec.rb +1 -1
- data/spec/github/users/update_spec.rb +1 -1
- data/spec/integration/arguments_spec.rb +76 -0
- data/spec/{github → integration}/authorizations_spec.rb +0 -0
- metadata +44 -35
- data/spec/github/repos/pub_sub_hubbub_spec.rb +0 -78
data/README.md
CHANGED
|
@@ -18,13 +18,13 @@ Supports all the API methods(nearly 200). It's build in a modular way, that is,
|
|
|
18
18
|
* Modular design allows for working with parts of API.
|
|
19
19
|
* Fully customizable including advanced middleware stack construction.
|
|
20
20
|
* Its comprehensive, you can request all GitHub API resources.
|
|
21
|
+
* Flexible arguments parsing, you can write expressive and natural queries.
|
|
21
22
|
* Requests pagination with convenient DSL.
|
|
22
23
|
* Easy error handling split for client and server type errors.
|
|
23
24
|
* Supports multithreaded environment.
|
|
24
|
-
* Custom mime types specification (Status:
|
|
25
|
-
* Flexible arguments parsing (Status: In progress).
|
|
25
|
+
* Custom mime types specification (Status: In Progess)
|
|
26
26
|
* Request results caching (Status: TODO)
|
|
27
|
-
* Fully tested with test coverage above 90% with over 1,
|
|
27
|
+
* Fully tested with test coverage above 90% with over 1,500 specs and 700 features.
|
|
28
28
|
|
|
29
29
|
## Installation
|
|
30
30
|
|
|
@@ -60,11 +60,12 @@ At this stage you can also supply various configuration parameters, such as `:us
|
|
|
60
60
|
github = Github.new oauth_token: 'token'
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
Alternatively, you can configure the Github settings by passing a block, for instance, with custom enterprise endpoint like
|
|
63
|
+
Alternatively, you can configure the Github settings by passing a block, for instance, with custom enterprise endpoint and website like
|
|
64
64
|
|
|
65
65
|
```ruby
|
|
66
66
|
github = Github.new do |config|
|
|
67
67
|
config.endpoint = 'https://github.company.com/api/v3'
|
|
68
|
+
config.site = 'https://github.company.com'
|
|
68
69
|
config.oauth_token = 'token'
|
|
69
70
|
config.adapter = :net_http
|
|
70
71
|
config.ssl = {:verify => false}
|
|
@@ -110,7 +111,51 @@ repos.branches do |branch|
|
|
|
110
111
|
end
|
|
111
112
|
```
|
|
112
113
|
|
|
113
|
-
##
|
|
114
|
+
## Arguments & Parameters
|
|
115
|
+
|
|
116
|
+
The library allows for flexible arguments parsing. Therefore arguments can be passed during instance creation:
|
|
117
|
+
|
|
118
|
+
```ruby
|
|
119
|
+
issues = Github::Issues.new user: 'peter-murach', repo: 'github'
|
|
120
|
+
issues.milestones.list state: 'open'
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Further, arguments can be passed directly inside method called but then the order of parameters matters and hence please consult the method documentation or GitHub specification. For instance:
|
|
124
|
+
|
|
125
|
+
```ruby
|
|
126
|
+
issues = Github::Issues.new
|
|
127
|
+
issues.milestones.list 'peter-murach', 'github', state: 'open'
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Similarly, the arguments for the request can be passed inside the current scope such as:
|
|
131
|
+
|
|
132
|
+
```ruby
|
|
133
|
+
issues = Github::Issues.new
|
|
134
|
+
issues.milestones(user: 'peter-murach', repo: 'github').list
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
But why limit ourselves? You can mix and match arguments, for example:
|
|
138
|
+
|
|
139
|
+
```ruby
|
|
140
|
+
issues = Github::Issues.new user: 'peter-murach'
|
|
141
|
+
issues.milestones(repo: 'github').list
|
|
142
|
+
issues.milestones(repo: 'tty').list
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Finally, you can use a bit of syntactic sugar common among ruby libraries whereby "username/repository" can be passed as well:
|
|
146
|
+
|
|
147
|
+
```ruby
|
|
148
|
+
issues = Github::Issues.new
|
|
149
|
+
issues.milestones('peter-murach/github').list
|
|
150
|
+
issues.milestones.list 'peter-murach/github'
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Finally, use `with` scope to clearly denote your requests
|
|
154
|
+
|
|
155
|
+
```ruby
|
|
156
|
+
issues = Github::Issues.new
|
|
157
|
+
issues.milestones.with(user:'peter-murach', repo: 'github').list
|
|
158
|
+
```
|
|
114
159
|
|
|
115
160
|
Some API methods apart from required parameters such as username, repository name
|
|
116
161
|
or organisation name, allow you to switch the way the data is returned to you, for instance
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://<BASIC_AUTH>@api.github.com/repos/boyan/github/git/commits/aca2a25d442a9545b01f42574c46f59035993b02?access_token=<TOKEN>
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept:
|
|
11
|
+
- application/vnd.github.v3.full+json,application/vnd.github.beta.full+json;q=0.7,application/vnd.github+json;q=0.5,application/json;q=0.1
|
|
12
|
+
Accept-Charset:
|
|
13
|
+
- utf-8
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Github Ruby Gem 0.9.0
|
|
16
|
+
Content-Type:
|
|
17
|
+
- application/json
|
|
18
|
+
Accept-Encoding:
|
|
19
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 200
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Server:
|
|
26
|
+
- GitHub.com
|
|
27
|
+
Date:
|
|
28
|
+
- Tue, 19 Feb 2013 22:32:05 GMT
|
|
29
|
+
Content-Type:
|
|
30
|
+
- application/json; charset=utf-8
|
|
31
|
+
Transfer-Encoding:
|
|
32
|
+
- chunked
|
|
33
|
+
Connection:
|
|
34
|
+
- keep-alive
|
|
35
|
+
Status:
|
|
36
|
+
- 200 OK
|
|
37
|
+
X-Ratelimit-Limit:
|
|
38
|
+
- '5000'
|
|
39
|
+
X-Ratelimit-Remaining:
|
|
40
|
+
- '4999'
|
|
41
|
+
Vary:
|
|
42
|
+
- Accept, Authorization, Cookie
|
|
43
|
+
Cache-Control:
|
|
44
|
+
- private, max-age=60, s-maxage=60
|
|
45
|
+
Last-Modified:
|
|
46
|
+
- Thu, 14 Feb 2013 13:30:02 GMT
|
|
47
|
+
Etag:
|
|
48
|
+
- ! '"ebbd81db82247bdc737b6bed8b3a8f14"'
|
|
49
|
+
X-Github-Media-Type:
|
|
50
|
+
- github.v3; param=full; format=json
|
|
51
|
+
X-Content-Type-Options:
|
|
52
|
+
- nosniff
|
|
53
|
+
Content-Encoding:
|
|
54
|
+
- gzip
|
|
55
|
+
body:
|
|
56
|
+
encoding: ASCII-8BIT
|
|
57
|
+
string: !binary |-
|
|
58
|
+
H4sIAAAAAAAAA7WSwW7cIBRFfwWxapVkDBh7jFdtpar9gK7a6eJhHgbFxhbg
|
|
59
|
+
NtFo/r04SaMs00hdIb3H5VwdcabJAe0pDCBANEZKAaqRjWbcStEc5SBb2yhW
|
|
60
|
+
N0rVmgl6Tbc4lYDLeU19VcHqD6PPbtOHYZmriOuSKr3cQ6gex/tRldXsc6r+
|
|
61
|
+
AQNbdkuk/ZkGmLEQP+2Pko8T3kEwcflVquAMfi/zwPsAz6uDz2VrIO85wXh9
|
|
62
|
+
w8QNl9943desZ+I7vVzTx04Z/ycjRywVzk+S1WD0YJUWrBlQ1Nx23HDbCoO6
|
|
63
|
+
xc7KGgDKDN8oeYel6tWQomDGlGDcJa2QElkhO+JDygiGLJakweGMV25J+eph
|
|
64
|
+
V2YrxISmHKMPkP0SyOTDbTqFU8gOI+p7Yv2dD+PLKz6QLz5/3TT5HIrwNfqE
|
|
65
|
+
5N1v5yckYclER4TbPeNz4Z9CxHGbID6F3hcfBYshJ9r/eJZpOsWUNkfbSVsf
|
|
66
|
+
eddJOTSqbg0b2hZFwy3jSvA3yvz7Y9VrMZeflz8/MxWrTQMAAA==
|
|
67
|
+
http_version: !!null
|
|
68
|
+
recorded_at: Tue, 19 Feb 2013 22:32:05 GMT
|
|
69
|
+
recorded_with: VCR 2.4.0
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Feature: GitData Commits API
|
|
2
|
+
|
|
3
|
+
Background:
|
|
4
|
+
Given I have "Github::GitData::Commits" instance
|
|
5
|
+
|
|
6
|
+
Scenario: Gets a single commit
|
|
7
|
+
|
|
8
|
+
Given I want to get resource with the following params:
|
|
9
|
+
| user | repo | sha |
|
|
10
|
+
| boyan | github | aca2a25d442a9545b01f42574c46f59035993b02 |
|
|
11
|
+
When I make request within a cassette named "git_data/commits/get"
|
|
12
|
+
Then the response status should be 200
|
|
13
|
+
And the response type should be JSON
|
|
14
|
+
And the response should not be empty
|
data/lib/github_api.rb
CHANGED
|
@@ -10,10 +10,10 @@ module Github
|
|
|
10
10
|
# github.activity.events.public
|
|
11
11
|
# github.activity.events.public { |event| ... }
|
|
12
12
|
#
|
|
13
|
-
def public(
|
|
14
|
-
|
|
13
|
+
def public(*args)
|
|
14
|
+
arguments(args)
|
|
15
15
|
|
|
16
|
-
response = get_request("/events", params)
|
|
16
|
+
response = get_request("/events", arguments.params)
|
|
17
17
|
return response unless block_given?
|
|
18
18
|
response.each { |el| yield el }
|
|
19
19
|
end
|
|
@@ -28,12 +28,13 @@ module Github
|
|
|
28
28
|
# github.activity.events.repository 'user-name', 'repo-name'
|
|
29
29
|
# github.activity.events.repository 'user-name', 'repo-name' { |event| ... }
|
|
30
30
|
#
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
# github.events.repository user: 'user-name', repo: 'repo-name'
|
|
32
|
+
# github.events.repository user: 'user-name', repo: 'repo-name' {|event| ... }
|
|
33
|
+
#
|
|
34
|
+
def repository(*args)
|
|
35
|
+
arguments(args, :required => [:user, :repo])
|
|
35
36
|
|
|
36
|
-
response = get_request("/repos/#{user}/#{repo}/events", params)
|
|
37
|
+
response = get_request("/repos/#{user}/#{repo}/events", arguments.params)
|
|
37
38
|
return response unless block_given?
|
|
38
39
|
response.each { |el| yield el }
|
|
39
40
|
end
|
|
@@ -49,10 +50,12 @@ module Github
|
|
|
49
50
|
# github.activity.events.issue 'user-name', 'repo-name'
|
|
50
51
|
# github.activity.events.issue 'user-name', 'repo-name' { |event| ... }
|
|
51
52
|
#
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
# github.events.issue user: 'user-name', repo: 'repo-name'
|
|
54
|
+
# github.events.issue user: 'user-name', repo: 'repo-name' { |event| ... }
|
|
55
|
+
#
|
|
56
|
+
def issue(*args)
|
|
57
|
+
arguments(args, :required => [:user, :repo])
|
|
58
|
+
params = arguments.params
|
|
56
59
|
|
|
57
60
|
response = get_request("/repos/#{user}/#{repo}/issues/events", params)
|
|
58
61
|
return response unless block_given?
|
|
@@ -69,12 +72,13 @@ module Github
|
|
|
69
72
|
# github.activity.events.network 'user-name', 'repo-name'
|
|
70
73
|
# github.activity.events.network 'user-name', 'repo-name' { |event| ... }
|
|
71
74
|
#
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
# github.events.network user: 'user-name', repo: 'repo-name'
|
|
76
|
+
# github.events.network user: 'user-name', repo: 'repo-name' { |event| ... }
|
|
77
|
+
#
|
|
78
|
+
def network(*args)
|
|
79
|
+
arguments(args, :required => [:user, :repo])
|
|
76
80
|
|
|
77
|
-
response = get_request("/networks/#{user}/#{repo}/events", params)
|
|
81
|
+
response = get_request("/networks/#{user}/#{repo}/events", arguments.params)
|
|
78
82
|
return response unless block_given?
|
|
79
83
|
response.each { |el| yield el }
|
|
80
84
|
end
|
|
@@ -90,11 +94,13 @@ module Github
|
|
|
90
94
|
# github.activity.events.org 'org-name'
|
|
91
95
|
# github.activity.events.org 'org-name' { |event| ... }
|
|
92
96
|
#
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
# github.events.org org: 'org-name'
|
|
98
|
+
# github.events.org org: 'org-name' { |event| ... }
|
|
99
|
+
#
|
|
100
|
+
def org(*args)
|
|
101
|
+
arguments(args, :required => [:org_name])
|
|
96
102
|
|
|
97
|
-
response = get_request("/orgs/#{org_name}/events", params)
|
|
103
|
+
response = get_request("/orgs/#{org_name}/events", arguments.params)
|
|
98
104
|
return response unless block_given?
|
|
99
105
|
response.each { |el| yield el }
|
|
100
106
|
end
|
|
@@ -121,16 +127,16 @@ module Github
|
|
|
121
127
|
# github.activity.events.received 'user-name', :public => true
|
|
122
128
|
# github.activity.events.received 'user-name', :public => true { |event| ... }
|
|
123
129
|
#
|
|
124
|
-
def received(
|
|
125
|
-
|
|
126
|
-
|
|
130
|
+
def received(*args)
|
|
131
|
+
arguments(args, :required => [:user])
|
|
132
|
+
params = arguments.params
|
|
127
133
|
|
|
128
134
|
public_events = if params['public']
|
|
129
135
|
params.delete('public')
|
|
130
136
|
'/public'
|
|
131
137
|
end
|
|
132
138
|
|
|
133
|
-
response = get_request("/users/#{
|
|
139
|
+
response = get_request("/users/#{user}/received_events#{public_events}", params)
|
|
134
140
|
return response unless block_given?
|
|
135
141
|
response.each { |el| yield el }
|
|
136
142
|
end
|
|
@@ -154,16 +160,16 @@ module Github
|
|
|
154
160
|
# github.activity.events.performed 'user-name', :public => true
|
|
155
161
|
# github.activity.events.performed 'user-name', :public => true { |event| ... }
|
|
156
162
|
#
|
|
157
|
-
def performed(
|
|
158
|
-
|
|
159
|
-
|
|
163
|
+
def performed(*args)
|
|
164
|
+
arguments(args, :required => [:user])
|
|
165
|
+
params = arguments.params
|
|
160
166
|
|
|
161
167
|
public_events = if params['public']
|
|
162
168
|
params.delete('public')
|
|
163
169
|
'/public'
|
|
164
170
|
end
|
|
165
171
|
|
|
166
|
-
response = get_request("/users/#{
|
|
172
|
+
response = get_request("/users/#{user}/events#{public_events}", params)
|
|
167
173
|
return response unless block_given?
|
|
168
174
|
response.each { |el| yield el }
|
|
169
175
|
end
|
|
@@ -180,11 +186,14 @@ module Github
|
|
|
180
186
|
# github.activity.events.user_org 'user-name', 'org-name'
|
|
181
187
|
# github.activity.events.user_org 'user-name', 'org-name' { |event| ... }
|
|
182
188
|
#
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
189
|
+
# github.events.user_org user: 'user-name', org_name: 'org-name'
|
|
190
|
+
# github.events.user_org user: 'user-name', org_name: 'org-name' {|event| ...}
|
|
191
|
+
#
|
|
192
|
+
def user_org(*args)
|
|
193
|
+
arguments(args, :required => [:user, :org_name])
|
|
194
|
+
params = arguments.params
|
|
186
195
|
|
|
187
|
-
response = get_request("/users/#{
|
|
196
|
+
response = get_request("/users/#{user}/events/orgs/#{org_name}", params)
|
|
188
197
|
return response unless block_given?
|
|
189
198
|
response.each { |el| yield el }
|
|
190
199
|
end
|
|
@@ -28,9 +28,9 @@ module Github
|
|
|
28
28
|
# github.activity.notifications.list user: 'user-name', repo: 'repo-name'
|
|
29
29
|
#
|
|
30
30
|
def list(*args)
|
|
31
|
-
params = args
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
params = arguments(args) do
|
|
32
|
+
sift %w[ all participating since user repo]
|
|
33
|
+
end.params
|
|
34
34
|
|
|
35
35
|
response = if ( (user_name = params.delete("user")) &&
|
|
36
36
|
(repo_name = params.delete("repo")) )
|
|
@@ -50,10 +50,10 @@ module Github
|
|
|
50
50
|
# github.activity.notifications.get 'thread_id'
|
|
51
51
|
# github.activity.notifications.get 'thread_id' { |thread| ... }
|
|
52
52
|
#
|
|
53
|
-
def get(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
response = get_request("/notifications/threads/#{thread_id}", params)
|
|
53
|
+
def get(*args)
|
|
54
|
+
arguments(args, :required => [:thread_id])
|
|
55
|
+
|
|
56
|
+
response = get_request("/notifications/threads/#{thread_id}", arguments.params)
|
|
57
57
|
return response unless block_given?
|
|
58
58
|
response.each { |el| yield el }
|
|
59
59
|
end
|
|
@@ -89,9 +89,9 @@ module Github
|
|
|
89
89
|
# github.activity.notifications.mark thread_id: 'id', read: true
|
|
90
90
|
#
|
|
91
91
|
def mark(*args)
|
|
92
|
-
params = args
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
params = arguments(args) do
|
|
93
|
+
sift %w[ unread read last_read_at user repo thread_id]
|
|
94
|
+
end.params
|
|
95
95
|
|
|
96
96
|
if ( (user_name = params.delete("user")) &&
|
|
97
97
|
(repo_name = params.delete("repo")) )
|
|
@@ -110,10 +110,10 @@ module Github
|
|
|
110
110
|
# github = Github.new oauth_token: 'token'
|
|
111
111
|
# github.activity.notifications.subscribed? 'thread-id'
|
|
112
112
|
#
|
|
113
|
-
def subscribed?(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
get_request("/notifications/threads/#{thread_id}/subscription", params)
|
|
113
|
+
def subscribed?(*args)
|
|
114
|
+
arguments(args, :required => [:thread_id])
|
|
115
|
+
|
|
116
|
+
get_request("/notifications/threads/#{thread_id}/subscription", arguments.params)
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
# Create a thread subscription
|
|
@@ -134,10 +134,10 @@ module Github
|
|
|
134
134
|
# 'subscribed': true
|
|
135
135
|
# 'ignored': false
|
|
136
136
|
#
|
|
137
|
-
def create(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
put_request("/notifications/threads/#{thread_id}/subscription", params)
|
|
137
|
+
def create(*args)
|
|
138
|
+
arguments(args, :required => [:thread_id])
|
|
139
|
+
|
|
140
|
+
put_request("/notifications/threads/#{thread_id}/subscription", arguments.params)
|
|
141
141
|
end
|
|
142
142
|
|
|
143
143
|
# Delete a thread subscription
|
|
@@ -146,10 +146,10 @@ module Github
|
|
|
146
146
|
# github = Github.new oauth_token: 'token'
|
|
147
147
|
# github.activity.notifications.delete 'thread_id'
|
|
148
148
|
#
|
|
149
|
-
def delete(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
delete_request("/notifications/threads/#{thread_id}/subscription", params)
|
|
149
|
+
def delete(*args)
|
|
150
|
+
arguments(args, :required => [:thread_id])
|
|
151
|
+
|
|
152
|
+
delete_request("/notifications/threads/#{thread_id}/subscription", arguments.params)
|
|
153
153
|
end
|
|
154
154
|
alias :remove :delete
|
|
155
155
|
|
|
@@ -12,12 +12,10 @@ module Github
|
|
|
12
12
|
# github.activity.starring.list
|
|
13
13
|
# github.activity.starring.list { |star| ... }
|
|
14
14
|
#
|
|
15
|
-
def list(
|
|
16
|
-
|
|
17
|
-
assert_presence_of user, repo
|
|
18
|
-
normalize! params
|
|
15
|
+
def list(*args)
|
|
16
|
+
arguments(args, :required => [:user, :repo])
|
|
19
17
|
|
|
20
|
-
response = get_request("/repos/#{user}/#{repo}/stargazers", params)
|
|
18
|
+
response = get_request("/repos/#{user}/#{repo}/stargazers", arguments.params)
|
|
21
19
|
return response unless block_given?
|
|
22
20
|
response.each { |el| yield el }
|
|
23
21
|
end
|
|
@@ -36,8 +34,7 @@ module Github
|
|
|
36
34
|
# github.activity.starring.starred
|
|
37
35
|
#
|
|
38
36
|
def starred(*args)
|
|
39
|
-
params = args.
|
|
40
|
-
normalize! params
|
|
37
|
+
params = arguments(args).params
|
|
41
38
|
|
|
42
39
|
response = if (user_name = params.delete('user'))
|
|
43
40
|
get_request("/users/#{user_name}/starred", params)
|
|
@@ -56,10 +53,10 @@ module Github
|
|
|
56
53
|
# github = Github.new
|
|
57
54
|
# github.activity.starring.starring? 'user-name', 'repo-name'
|
|
58
55
|
#
|
|
59
|
-
def starring?(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
get_request("/user/starred/#{
|
|
56
|
+
def starring?(*args)
|
|
57
|
+
arguments(args, :required => [:user, :repo])
|
|
58
|
+
|
|
59
|
+
get_request("/user/starred/#{user}/#{repo}", arguments.params)
|
|
63
60
|
true
|
|
64
61
|
rescue Github::Error::NotFound
|
|
65
62
|
false
|
|
@@ -73,11 +70,10 @@ module Github
|
|
|
73
70
|
# github = Github.new
|
|
74
71
|
# github.activity.starring.star 'user-name', 'repo-name'
|
|
75
72
|
#
|
|
76
|
-
def star(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
put_request("/user/starred/#{user_name}/#{repo_name}", params)
|
|
73
|
+
def star(*args)
|
|
74
|
+
arguments(args, :required => [:user, :repo])
|
|
75
|
+
|
|
76
|
+
put_request("/user/starred/#{user}/#{repo}", arguments.params)
|
|
81
77
|
end
|
|
82
78
|
|
|
83
79
|
# Unstar a repository
|
|
@@ -88,11 +84,10 @@ module Github
|
|
|
88
84
|
# github = Github.new
|
|
89
85
|
# github.activity.starring.unstar 'user-name', 'repo-name'
|
|
90
86
|
#
|
|
91
|
-
def unstar(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
delete_request("/user/starred/#{user_name}/#{repo_name}", params)
|
|
87
|
+
def unstar(*args)
|
|
88
|
+
arguments(args, :required => [:user, :repo])
|
|
89
|
+
|
|
90
|
+
delete_request("/user/starred/#{user}/#{repo}", arguments.params)
|
|
96
91
|
end
|
|
97
92
|
|
|
98
93
|
end # Activity::Starring
|