github_api 0.15.0 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +770 -0
- data/README.md +25 -8
- data/lib/github_api.rb +37 -76
- data/lib/github_api/api.rb +46 -19
- data/lib/github_api/api/arguments.rb +6 -1
- data/lib/github_api/api/config.rb +3 -5
- data/lib/github_api/api/config/property_set.rb +1 -0
- data/lib/github_api/authorization.rb +2 -0
- data/lib/github_api/client.rb +5 -0
- data/lib/github_api/client/activity.rb +2 -0
- data/lib/github_api/client/activity/events.rb +2 -0
- data/lib/github_api/client/activity/feeds.rb +2 -0
- data/lib/github_api/client/activity/notifications.rb +2 -0
- data/lib/github_api/client/activity/starring.rb +3 -1
- data/lib/github_api/client/activity/watching.rb +3 -1
- data/lib/github_api/client/authorizations.rb +2 -0
- data/lib/github_api/client/authorizations/app.rb +3 -1
- data/lib/github_api/client/emojis.rb +2 -0
- data/lib/github_api/client/gists.rb +4 -2
- data/lib/github_api/client/gists/comments.rb +3 -1
- data/lib/github_api/client/git_data.rb +2 -0
- data/lib/github_api/client/git_data/blobs.rb +2 -1
- data/lib/github_api/client/git_data/commits.rb +2 -0
- data/lib/github_api/client/git_data/references.rb +6 -2
- data/lib/github_api/client/git_data/tags.rb +2 -0
- data/lib/github_api/client/git_data/trees.rb +2 -0
- data/lib/github_api/client/gitignore.rb +2 -0
- data/lib/github_api/client/issues.rb +2 -0
- data/lib/github_api/client/issues/assignees.rb +35 -0
- data/lib/github_api/client/issues/comments.rb +2 -0
- data/lib/github_api/client/issues/events.rb +2 -0
- data/lib/github_api/client/issues/labels.rb +2 -0
- data/lib/github_api/client/issues/milestones.rb +2 -0
- data/lib/github_api/client/markdown.rb +4 -2
- data/lib/github_api/client/meta.rb +2 -0
- data/lib/github_api/client/orgs.rb +6 -0
- data/lib/github_api/client/orgs/hooks.rb +2 -0
- data/lib/github_api/client/orgs/members.rb +2 -0
- data/lib/github_api/client/orgs/memberships.rb +2 -0
- data/lib/github_api/client/orgs/projects.rb +57 -0
- data/lib/github_api/client/orgs/teams.rb +5 -3
- data/lib/github_api/client/projects.rb +83 -0
- data/lib/github_api/client/projects/cards.rb +158 -0
- data/lib/github_api/client/projects/columns.rb +146 -0
- data/lib/github_api/client/pull_requests.rb +2 -0
- data/lib/github_api/client/pull_requests/comments.rb +2 -0
- data/lib/github_api/client/pull_requests/reviews.rb +2 -0
- data/lib/github_api/client/repos.rb +27 -15
- data/lib/github_api/client/repos/branches.rb +48 -0
- data/lib/github_api/client/repos/branches/protections.rb +75 -0
- data/lib/github_api/client/repos/collaborators.rb +2 -1
- data/lib/github_api/client/repos/comments.rb +2 -1
- data/lib/github_api/client/repos/commits.rb +2 -0
- data/lib/github_api/client/repos/contents.rb +26 -4
- data/lib/github_api/client/repos/deployments.rb +3 -1
- data/lib/github_api/client/repos/downloads.rb +2 -0
- data/lib/github_api/client/repos/forks.rb +6 -2
- data/lib/github_api/client/repos/hooks.rb +2 -0
- data/lib/github_api/client/repos/invitations.rb +41 -0
- data/lib/github_api/client/repos/keys.rb +2 -0
- data/lib/github_api/client/repos/merging.rb +2 -0
- data/lib/github_api/client/repos/pages.rb +2 -0
- data/lib/github_api/client/repos/projects.rb +62 -0
- data/lib/github_api/client/repos/pub_sub_hubbub.rb +6 -6
- data/lib/github_api/client/repos/releases.rb +2 -0
- data/lib/github_api/client/repos/releases/assets.rb +3 -1
- data/lib/github_api/client/repos/releases/tags.rb +2 -0
- data/lib/github_api/client/repos/statistics.rb +2 -0
- data/lib/github_api/client/repos/statuses.rb +2 -0
- data/lib/github_api/client/say.rb +2 -0
- data/lib/github_api/client/scopes.rb +2 -0
- data/lib/github_api/client/search.rb +3 -0
- data/lib/github_api/client/search/legacy.rb +2 -0
- data/lib/github_api/client/users.rb +2 -0
- data/lib/github_api/client/users/emails.rb +3 -0
- data/lib/github_api/client/users/followers.rb +3 -1
- data/lib/github_api/client/users/keys.rb +2 -0
- data/lib/github_api/configuration.rb +4 -1
- data/lib/github_api/connection.rb +5 -1
- data/lib/github_api/error.rb +1 -4
- data/lib/github_api/error/client_error.rb +4 -2
- data/lib/github_api/error/service_error.rb +9 -2
- data/lib/github_api/ext/faraday.rb +3 -1
- data/lib/github_api/mash.rb +7 -0
- data/lib/github_api/middleware.rb +8 -6
- data/lib/github_api/normalizer.rb +3 -5
- data/lib/github_api/page_iterator.rb +4 -1
- data/lib/github_api/page_links.rb +4 -0
- data/lib/github_api/paged_request.rb +2 -0
- data/lib/github_api/pagination.rb +10 -7
- data/lib/github_api/parameter_filter.rb +4 -1
- data/lib/github_api/params_hash.rb +4 -4
- data/lib/github_api/request.rb +8 -9
- data/lib/github_api/request/basic_auth.rb +1 -1
- data/lib/github_api/request/jsonize.rb +0 -1
- data/lib/github_api/request/oauth2.rb +2 -0
- data/lib/github_api/request/verbs.rb +3 -0
- data/lib/github_api/response/follow_redirects.rb +140 -0
- data/lib/github_api/response/header.rb +6 -1
- data/lib/github_api/response/mashify.rb +2 -3
- data/lib/github_api/response/raise_error.rb +2 -1
- data/lib/github_api/response_wrapper.rb +5 -0
- data/lib/github_api/utils/url.rb +2 -0
- data/lib/github_api/validations.rb +5 -8
- data/lib/github_api/validations/format.rb +2 -0
- data/lib/github_api/validations/presence.rb +3 -1
- data/lib/github_api/validations/required.rb +2 -0
- data/lib/github_api/version.rb +2 -2
- metadata +100 -36
- data/lib/github_api/core_ext/ordered_hash.rb +0 -107
- data/lib/github_api/requestable.rb +0 -67
- data/lib/github_api/resource.rb +0 -13
data/README.md
CHANGED
@@ -2,21 +2,20 @@
|
|
2
2
|
<a href="http://piotrmurach.github.io/github/"><img width="136" src="https://github.com/piotrmurach/github/raw/master/icons/github_api.png" alt="github api logo" /></a>
|
3
3
|
</div>
|
4
4
|
|
5
|
-
# GithubAPI
|
5
|
+
# GithubAPI [![Gitter](https://badges.gitter.im/Join%20Chat.svg)][gitter]
|
6
6
|
|
7
7
|
[![Gem Version](https://badge.fury.io/rb/github_api.svg)][gem]
|
8
8
|
[![Build Status](https://secure.travis-ci.org/piotrmurach/github.svg?branch=master)][travis]
|
9
|
-
[![
|
9
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/7dc798db81a62774f99b/maintainability)][codeclimate]
|
10
10
|
[![Coverage Status](https://coveralls.io/repos/piotrmurach/github/badge.svg?branch=master)][coverage]
|
11
11
|
[![Inline docs](http://inch-ci.org/github/piotrmurach/github.svg)][inchpages]
|
12
|
-
[![Dependency Status](https://gemnasium.com/piotrmurach/github.svg?travis)][gemnasium]
|
13
12
|
|
13
|
+
[gitter]: https://gitter.im/piotrmurach/github_api
|
14
14
|
[gem]: http://badge.fury.io/rb/github_api
|
15
15
|
[travis]: http://travis-ci.org/piotrmurach/github
|
16
|
-
[codeclimate]: https://codeclimate.com/github/piotrmurach/github
|
16
|
+
[codeclimate]: https://codeclimate.com/github/piotrmurach/github/maintainability
|
17
17
|
[coverage]: https://coveralls.io/r/piotrmurach/github
|
18
18
|
[inchpages]: http://inch-ci.org/github/piotrmurach/github
|
19
|
-
[gemnasium]: https://gemnasium.com/piotrmurach/github
|
20
19
|
|
21
20
|
[Website](http://piotrmurach.github.io/github/) | [Wiki](https://github.com/piotrmurach/github/wiki) | [RDocs](http://rubydoc.info/github/piotrmurach/github/master/frames)
|
22
21
|
|
@@ -705,9 +704,27 @@ github.delete 'username', 'tome-of-knowledge', 'full_path_to/file.ext',
|
|
705
704
|
|
706
705
|
The test suite is split into two groups, `live` and `mock`.
|
707
706
|
|
708
|
-
The `live` tests are the
|
707
|
+
The `live` tests are in the `features` folder and exercise the GitHub API directly by making live requests and then caching responses with VCR in directory named `features\cassettes`. For details on how to get set up, please navigate to the `features` folder.
|
709
708
|
|
710
|
-
|
709
|
+
To run all feature tests do:
|
710
|
+
|
711
|
+
```ruby
|
712
|
+
bundle exec rake features
|
713
|
+
```
|
714
|
+
|
715
|
+
The `mock` tests are in the `spec` folder and their primary concern is to test the gem internals without the hindrance of external calls.
|
716
|
+
|
717
|
+
To run all specs do:
|
718
|
+
|
719
|
+
```ruby
|
720
|
+
bundle exec rake spec
|
721
|
+
```
|
722
|
+
|
723
|
+
Finally to run all tests do:
|
724
|
+
|
725
|
+
```ruby
|
726
|
+
bundle exec rake
|
727
|
+
```
|
711
728
|
|
712
729
|
## Development
|
713
730
|
|
@@ -719,4 +736,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/piotrm
|
|
719
736
|
|
720
737
|
## Copyright
|
721
738
|
|
722
|
-
Copyright (c) 2011
|
739
|
+
Copyright (c) 2011 Piotr Murach. See LICENSE.txt for further details.
|
data/lib/github_api.rb
CHANGED
@@ -1,16 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'pp' if ENV['DEBUG']
|
4
|
+
|
4
5
|
require 'faraday'
|
5
|
-
|
6
|
-
require 'github_api/configuration'
|
7
|
-
require 'github_api/constants'
|
8
|
-
require 'github_api/utils/url'
|
9
|
-
require 'github_api/connection'
|
10
|
-
require 'github_api/deprecation'
|
11
|
-
require 'github_api/core_ext/ordered_hash'
|
12
|
-
require 'github_api/ext/faraday'
|
13
|
-
require 'github_api/middleware'
|
6
|
+
require_relative 'github_api/ext/faraday'
|
14
7
|
|
15
8
|
module Github
|
16
9
|
LIBNAME = 'github_api'
|
@@ -18,8 +11,32 @@ module Github
|
|
18
11
|
LIBDIR = File.expand_path("../#{LIBNAME}", __FILE__)
|
19
12
|
|
20
13
|
class << self
|
21
|
-
|
22
|
-
|
14
|
+
# The client configuration
|
15
|
+
#
|
16
|
+
# @return [Configuration]
|
17
|
+
#
|
18
|
+
# @api public
|
19
|
+
def configuration
|
20
|
+
@configuration ||= Configuration.new
|
21
|
+
end
|
22
|
+
alias_method :config, :configuration
|
23
|
+
|
24
|
+
# Configure options
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# Github.configure do |c|
|
28
|
+
# c.some_option = true
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# @yield the configuration block
|
32
|
+
# @yieldparam configuration [Github::Configuration]
|
33
|
+
# the configuration instance
|
34
|
+
#
|
35
|
+
# @return [nil]
|
36
|
+
#
|
37
|
+
# @api public
|
38
|
+
def configure
|
39
|
+
yield configuration
|
23
40
|
end
|
24
41
|
|
25
42
|
# Alias for Github::Client.new
|
@@ -63,69 +80,13 @@ module Github
|
|
63
80
|
super(method_name, include_private)
|
64
81
|
end
|
65
82
|
end
|
66
|
-
|
67
|
-
module ClassMethods
|
68
|
-
# Requires internal libraries
|
69
|
-
#
|
70
|
-
# @param [String] prefix
|
71
|
-
# the relative path prefix
|
72
|
-
# @param [Array[String]] libs
|
73
|
-
# the array of libraries to require
|
74
|
-
#
|
75
|
-
# @return [self]
|
76
|
-
def require_all(prefix, *libs)
|
77
|
-
libs.each do |lib|
|
78
|
-
require "#{File.join(prefix, lib)}"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# The client configuration
|
83
|
-
#
|
84
|
-
# @return [Configuration]
|
85
|
-
#
|
86
|
-
# @api public
|
87
|
-
def configuration
|
88
|
-
@configuration ||= Configuration.new
|
89
|
-
end
|
90
|
-
alias_method :config, :configuration
|
91
|
-
|
92
|
-
# Configure options
|
93
|
-
#
|
94
|
-
# @example
|
95
|
-
# Github.configure do |c|
|
96
|
-
# c.some_option = true
|
97
|
-
# end
|
98
|
-
#
|
99
|
-
# @yield the configuration block
|
100
|
-
# @yieldparam configuration [Github::Configuration]
|
101
|
-
# the configuration instance
|
102
|
-
#
|
103
|
-
# @return [nil]
|
104
|
-
#
|
105
|
-
# @api public
|
106
|
-
def configure
|
107
|
-
yield configuration
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
extend ClassMethods
|
112
|
-
|
113
|
-
require_all LIBDIR,
|
114
|
-
'authorization',
|
115
|
-
'validations',
|
116
|
-
'normalizer',
|
117
|
-
'parameter_filter',
|
118
|
-
'api',
|
119
|
-
'client',
|
120
|
-
'pagination',
|
121
|
-
'request',
|
122
|
-
'response',
|
123
|
-
'response_wrapper',
|
124
|
-
'error',
|
125
|
-
'mime_type',
|
126
|
-
'page_links',
|
127
|
-
'paged_request',
|
128
|
-
'page_iterator',
|
129
|
-
'params_hash'
|
130
|
-
|
131
83
|
end # Github
|
84
|
+
|
85
|
+
require_relative 'github_api/api'
|
86
|
+
require_relative 'github_api/client'
|
87
|
+
require_relative 'github_api/configuration'
|
88
|
+
require_relative 'github_api/deprecation'
|
89
|
+
require_relative 'github_api/core_ext/array'
|
90
|
+
require_relative 'github_api/core_ext/hash'
|
91
|
+
require_relative 'github_api/middleware'
|
92
|
+
require_relative 'github_api/version'
|
data/lib/github_api/api.rb
CHANGED
@@ -1,32 +1,29 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
require 'github_api/api/arguments'
|
3
|
+
require_relative 'authorization'
|
4
|
+
require_relative 'api/actions'
|
5
|
+
require_relative 'api/factory'
|
6
|
+
require_relative 'api/arguments'
|
7
|
+
require_relative 'configuration'
|
8
|
+
require_relative 'constants'
|
9
|
+
require_relative 'mime_type'
|
10
|
+
require_relative 'null_encoder'
|
11
|
+
require_relative 'rate_limit'
|
12
|
+
require_relative 'request/verbs'
|
13
|
+
require_relative 'validations'
|
15
14
|
|
16
15
|
module Github
|
17
16
|
# Core class responsible for api interface operations
|
18
17
|
class API
|
19
|
-
extend Github::ClassMethods
|
20
|
-
|
21
18
|
include Constants
|
22
19
|
include Authorization
|
23
20
|
include MimeType
|
24
|
-
include Request::Verbs
|
25
21
|
include RateLimit
|
22
|
+
include Request::Verbs
|
26
23
|
|
27
|
-
attr_reader
|
24
|
+
attr_reader(*Github.configuration.property_names)
|
28
25
|
|
29
|
-
attr_accessor
|
26
|
+
attr_accessor(*Validations::VALID_API_KEYS)
|
30
27
|
|
31
28
|
attr_accessor :current_options
|
32
29
|
|
@@ -40,6 +37,22 @@ module Github
|
|
40
37
|
end
|
41
38
|
end
|
42
39
|
|
40
|
+
# Requires internal libraries
|
41
|
+
#
|
42
|
+
# @param [String] prefix
|
43
|
+
# the relative path prefix
|
44
|
+
# @param [Array[String]] libs
|
45
|
+
# the array of libraries to require
|
46
|
+
#
|
47
|
+
# @return [self]
|
48
|
+
#
|
49
|
+
# @api public
|
50
|
+
def self.require_all(prefix, *libs)
|
51
|
+
libs.each do |lib|
|
52
|
+
require "#{File.join(prefix, lib)}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
43
56
|
# Create new API
|
44
57
|
#
|
45
58
|
# @api public
|
@@ -79,6 +92,16 @@ module Github
|
|
79
92
|
end
|
80
93
|
end
|
81
94
|
|
95
|
+
# Disable following redirects inside a block
|
96
|
+
#
|
97
|
+
# @api public
|
98
|
+
def disable_redirects
|
99
|
+
self.follow_redirects = false
|
100
|
+
yield
|
101
|
+
ensure
|
102
|
+
self.follow_redirects = true
|
103
|
+
end
|
104
|
+
|
82
105
|
# List of before callbacks
|
83
106
|
#
|
84
107
|
# @api public
|
@@ -199,14 +222,14 @@ module Github
|
|
199
222
|
#
|
200
223
|
# @api private
|
201
224
|
def filter_callbacks(kind, action_name)
|
202
|
-
|
225
|
+
self.class.send("#{kind}_callbacks").select do |callback|
|
203
226
|
callback[:only].nil? || callback[:only].include?(action_name)
|
204
227
|
end
|
205
228
|
end
|
206
229
|
|
207
230
|
# Run all callbacks associated with this action
|
208
231
|
#
|
209
|
-
# @
|
232
|
+
# @param [Symbol] action_name
|
210
233
|
#
|
211
234
|
# @api private
|
212
235
|
def run_callbacks(action_name, &block)
|
@@ -243,6 +266,10 @@ module Github
|
|
243
266
|
end
|
244
267
|
end
|
245
268
|
|
269
|
+
def respond_to?(method_name, include_private = false)
|
270
|
+
method_name.to_s.start_with?('clear_') || super
|
271
|
+
end
|
272
|
+
|
246
273
|
# Acts as setter and getter for api requests arguments parsing.
|
247
274
|
#
|
248
275
|
# Returns Arguments instance.
|
@@ -1,8 +1,13 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require_relative '../normalizer'
|
4
|
+
require_relative '../parameter_filter'
|
5
|
+
require_relative '../params_hash'
|
6
|
+
require_relative '../validations'
|
7
|
+
|
3
8
|
module Github
|
4
9
|
class API
|
5
|
-
# A class responsible for
|
10
|
+
# A class responsible for handling request arguments
|
6
11
|
class Arguments
|
7
12
|
include Normalizer
|
8
13
|
include ParameterFilter
|
@@ -1,14 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
require_relative 'config/property'
|
4
|
+
require_relative 'config/property_set'
|
5
5
|
|
6
6
|
module Github
|
7
|
-
|
8
7
|
class API
|
9
8
|
# A base class for constructing api configuration
|
10
9
|
class Config
|
11
|
-
|
12
10
|
# Defines a property on an object's class or instance
|
13
11
|
#
|
14
12
|
# @example
|
@@ -75,7 +73,7 @@ module Github
|
|
75
73
|
property_set.properties.map(&:name)
|
76
74
|
end
|
77
75
|
|
78
|
-
#
|
76
|
+
# Fetch all the properties and their values
|
79
77
|
#
|
80
78
|
# @return [Hash[Symbol]]
|
81
79
|
#
|
data/lib/github_api/client.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require_relative 'api'
|
4
|
+
|
3
5
|
module Github
|
4
6
|
class Client < API
|
5
7
|
require_all 'github_api/client',
|
@@ -13,6 +15,7 @@ module Github
|
|
13
15
|
'markdown',
|
14
16
|
'meta',
|
15
17
|
'orgs',
|
18
|
+
'projects',
|
16
19
|
'pull_requests',
|
17
20
|
'repos',
|
18
21
|
'say',
|
@@ -52,6 +55,8 @@ module Github
|
|
52
55
|
namespace :orgs
|
53
56
|
alias :organizations :orgs
|
54
57
|
|
58
|
+
namespace :projects
|
59
|
+
|
55
60
|
namespace :pull_requests
|
56
61
|
alias :pulls :pull_requests
|
57
62
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require_relative '../../api'
|
4
|
+
|
3
5
|
module Github
|
4
6
|
# Repository Starring is a feature that lets users bookmark repositories.
|
5
7
|
# Stars are shown next to repositories to show an approximate level of interest.
|
@@ -116,7 +118,7 @@ module Github
|
|
116
118
|
# github.activity.starring.unstar 'user-name', 'repo-name'
|
117
119
|
#
|
118
120
|
# @example
|
119
|
-
# github.
|
121
|
+
# github.activity.starring.unstar user: 'user-name', repo: 'repo-name'
|
120
122
|
#
|
121
123
|
# @api public
|
122
124
|
def unstar(*args)
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require_relative '../../api'
|
4
|
+
|
3
5
|
module Github
|
4
6
|
# Watching a Repository registers the user to receive notificactions on new
|
5
7
|
# discussions, as well as events in the user's activity feed.
|
@@ -11,7 +13,7 @@ module Github
|
|
11
13
|
# @example
|
12
14
|
# github = Github.new
|
13
15
|
# github.activity.watching.list user: 'user-name', repo: 'repo-name'
|
14
|
-
# github.activity.watching.list user: 'user-
|
16
|
+
# github.activity.watching.list user: 'user-name', repo: 'repo-name' { |watcher| ... }
|
15
17
|
#
|
16
18
|
# @api public
|
17
19
|
def list(*args)
|