github_api 0.15.0 → 0.19.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.
Files changed (113) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +770 -0
  3. data/README.md +25 -8
  4. data/lib/github_api.rb +37 -76
  5. data/lib/github_api/api.rb +46 -19
  6. data/lib/github_api/api/arguments.rb +6 -1
  7. data/lib/github_api/api/config.rb +3 -5
  8. data/lib/github_api/api/config/property_set.rb +1 -0
  9. data/lib/github_api/authorization.rb +2 -0
  10. data/lib/github_api/client.rb +5 -0
  11. data/lib/github_api/client/activity.rb +2 -0
  12. data/lib/github_api/client/activity/events.rb +2 -0
  13. data/lib/github_api/client/activity/feeds.rb +2 -0
  14. data/lib/github_api/client/activity/notifications.rb +2 -0
  15. data/lib/github_api/client/activity/starring.rb +3 -1
  16. data/lib/github_api/client/activity/watching.rb +3 -1
  17. data/lib/github_api/client/authorizations.rb +2 -0
  18. data/lib/github_api/client/authorizations/app.rb +3 -1
  19. data/lib/github_api/client/emojis.rb +2 -0
  20. data/lib/github_api/client/gists.rb +4 -2
  21. data/lib/github_api/client/gists/comments.rb +3 -1
  22. data/lib/github_api/client/git_data.rb +2 -0
  23. data/lib/github_api/client/git_data/blobs.rb +2 -1
  24. data/lib/github_api/client/git_data/commits.rb +2 -0
  25. data/lib/github_api/client/git_data/references.rb +6 -2
  26. data/lib/github_api/client/git_data/tags.rb +2 -0
  27. data/lib/github_api/client/git_data/trees.rb +2 -0
  28. data/lib/github_api/client/gitignore.rb +2 -0
  29. data/lib/github_api/client/issues.rb +2 -0
  30. data/lib/github_api/client/issues/assignees.rb +35 -0
  31. data/lib/github_api/client/issues/comments.rb +2 -0
  32. data/lib/github_api/client/issues/events.rb +2 -0
  33. data/lib/github_api/client/issues/labels.rb +2 -0
  34. data/lib/github_api/client/issues/milestones.rb +2 -0
  35. data/lib/github_api/client/markdown.rb +4 -2
  36. data/lib/github_api/client/meta.rb +2 -0
  37. data/lib/github_api/client/orgs.rb +6 -0
  38. data/lib/github_api/client/orgs/hooks.rb +2 -0
  39. data/lib/github_api/client/orgs/members.rb +2 -0
  40. data/lib/github_api/client/orgs/memberships.rb +2 -0
  41. data/lib/github_api/client/orgs/projects.rb +57 -0
  42. data/lib/github_api/client/orgs/teams.rb +5 -3
  43. data/lib/github_api/client/projects.rb +83 -0
  44. data/lib/github_api/client/projects/cards.rb +158 -0
  45. data/lib/github_api/client/projects/columns.rb +146 -0
  46. data/lib/github_api/client/pull_requests.rb +2 -0
  47. data/lib/github_api/client/pull_requests/comments.rb +2 -0
  48. data/lib/github_api/client/pull_requests/reviews.rb +2 -0
  49. data/lib/github_api/client/repos.rb +27 -15
  50. data/lib/github_api/client/repos/branches.rb +48 -0
  51. data/lib/github_api/client/repos/branches/protections.rb +75 -0
  52. data/lib/github_api/client/repos/collaborators.rb +2 -1
  53. data/lib/github_api/client/repos/comments.rb +2 -1
  54. data/lib/github_api/client/repos/commits.rb +2 -0
  55. data/lib/github_api/client/repos/contents.rb +26 -4
  56. data/lib/github_api/client/repos/deployments.rb +3 -1
  57. data/lib/github_api/client/repos/downloads.rb +2 -0
  58. data/lib/github_api/client/repos/forks.rb +6 -2
  59. data/lib/github_api/client/repos/hooks.rb +2 -0
  60. data/lib/github_api/client/repos/invitations.rb +41 -0
  61. data/lib/github_api/client/repos/keys.rb +2 -0
  62. data/lib/github_api/client/repos/merging.rb +2 -0
  63. data/lib/github_api/client/repos/pages.rb +2 -0
  64. data/lib/github_api/client/repos/projects.rb +62 -0
  65. data/lib/github_api/client/repos/pub_sub_hubbub.rb +6 -6
  66. data/lib/github_api/client/repos/releases.rb +2 -0
  67. data/lib/github_api/client/repos/releases/assets.rb +3 -1
  68. data/lib/github_api/client/repos/releases/tags.rb +2 -0
  69. data/lib/github_api/client/repos/statistics.rb +2 -0
  70. data/lib/github_api/client/repos/statuses.rb +2 -0
  71. data/lib/github_api/client/say.rb +2 -0
  72. data/lib/github_api/client/scopes.rb +2 -0
  73. data/lib/github_api/client/search.rb +3 -0
  74. data/lib/github_api/client/search/legacy.rb +2 -0
  75. data/lib/github_api/client/users.rb +2 -0
  76. data/lib/github_api/client/users/emails.rb +3 -0
  77. data/lib/github_api/client/users/followers.rb +3 -1
  78. data/lib/github_api/client/users/keys.rb +2 -0
  79. data/lib/github_api/configuration.rb +4 -1
  80. data/lib/github_api/connection.rb +5 -1
  81. data/lib/github_api/error.rb +1 -4
  82. data/lib/github_api/error/client_error.rb +4 -2
  83. data/lib/github_api/error/service_error.rb +9 -2
  84. data/lib/github_api/ext/faraday.rb +3 -1
  85. data/lib/github_api/mash.rb +7 -0
  86. data/lib/github_api/middleware.rb +8 -6
  87. data/lib/github_api/normalizer.rb +3 -5
  88. data/lib/github_api/page_iterator.rb +4 -1
  89. data/lib/github_api/page_links.rb +4 -0
  90. data/lib/github_api/paged_request.rb +2 -0
  91. data/lib/github_api/pagination.rb +10 -7
  92. data/lib/github_api/parameter_filter.rb +4 -1
  93. data/lib/github_api/params_hash.rb +4 -4
  94. data/lib/github_api/request.rb +8 -9
  95. data/lib/github_api/request/basic_auth.rb +1 -1
  96. data/lib/github_api/request/jsonize.rb +0 -1
  97. data/lib/github_api/request/oauth2.rb +2 -0
  98. data/lib/github_api/request/verbs.rb +3 -0
  99. data/lib/github_api/response/follow_redirects.rb +140 -0
  100. data/lib/github_api/response/header.rb +6 -1
  101. data/lib/github_api/response/mashify.rb +2 -3
  102. data/lib/github_api/response/raise_error.rb +2 -1
  103. data/lib/github_api/response_wrapper.rb +5 -0
  104. data/lib/github_api/utils/url.rb +2 -0
  105. data/lib/github_api/validations.rb +5 -8
  106. data/lib/github_api/validations/format.rb +2 -0
  107. data/lib/github_api/validations/presence.rb +3 -1
  108. data/lib/github_api/validations/required.rb +2 -0
  109. data/lib/github_api/version.rb +2 -2
  110. metadata +100 -36
  111. data/lib/github_api/core_ext/ordered_hash.rb +0 -107
  112. data/lib/github_api/requestable.rb +0 -67
  113. 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
- [![Code Climate](https://codeclimate.com/github/piotrmurach/github/badges/gpa.svg)][codeclimate]
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 ones in `features` folder and they simply exercise the GitHub API by making live requests and then being cached with VCR in directory named `features\cassettes`. For details on how to get set up, please navigate to the `features` folder.
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
- The `mock` tests are in the `spec` directory and their primary concern is to test the gem internals without the hindrance of external calls.
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-2016 Piotr Murach. See LICENSE.txt for further details.
739
+ Copyright (c) 2011 Piotr Murach. See LICENSE.txt for further details.
@@ -1,16 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'pp' if ENV['DEBUG']
4
+
4
5
  require 'faraday'
5
- require 'github_api/version'
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
- def included(base)
22
- base.extend ClassMethods
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'
@@ -1,32 +1,29 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'github_api/configuration'
4
- require 'github_api/mime_type'
5
- require 'github_api/rate_limit'
6
- require 'github_api/core_ext/hash'
7
- require 'github_api/core_ext/array'
8
- require 'github_api/null_encoder'
9
-
10
- require 'github_api/request/verbs'
11
-
12
- require 'github_api/api/actions'
13
- require 'github_api/api/factory'
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 *Github.configuration.property_names
24
+ attr_reader(*Github.configuration.property_names)
28
25
 
29
- attr_accessor *Validations::VALID_API_KEYS
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
- matched_callbacks = self.class.send("#{kind}_callbacks").select do |callback|
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
- # @apram [Symbol] action_name
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 handilng request arguments
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
- require 'github_api/api/config/property'
4
- require 'github_api/api/config/property_set'
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
- # Fetach all the properties and their values
76
+ # Fetch all the properties and their values
79
77
  #
80
78
  # @return [Hash[Symbol]]
81
79
  #
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require 'set'
3
4
 
4
5
  module Github
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'oauth2'
4
+
3
5
  module Github
4
6
  module Authorization
5
7
 
@@ -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
  class Client::Activity < API
5
7
 
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::Activity::Events < API
5
7
  # List all public events
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::Activity::Feeds < API
5
7
  # List all the feeds available to the authenticated user.
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::Activity::Notifications < API
5
7
  # List your notifications
@@ -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.activit.starring.unstar user: 'user-name', repo: 'repo-name'
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-naem', repo: 'repo-name' { |watcher| ... }
16
+ # github.activity.watching.list user: 'user-name', repo: 'repo-name' { |watcher| ... }
15
17
  #
16
18
  # @api public
17
19
  def list(*args)