github_api 0.18.2 → 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.
data/README.md CHANGED
@@ -6,18 +6,16 @@
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
 
14
13
  [gitter]: https://gitter.im/piotrmurach/github_api
15
14
  [gem]: http://badge.fury.io/rb/github_api
16
15
  [travis]: http://travis-ci.org/piotrmurach/github
17
- [codeclimate]: https://codeclimate.com/github/piotrmurach/github
16
+ [codeclimate]: https://codeclimate.com/github/piotrmurach/github/maintainability
18
17
  [coverage]: https://coveralls.io/r/piotrmurach/github
19
18
  [inchpages]: http://inch-ci.org/github/piotrmurach/github
20
- [gemnasium]: https://gemnasium.com/piotrmurach/github
21
19
 
22
20
  [Website](http://piotrmurach.github.io/github/) | [Wiki](https://github.com/piotrmurach/github/wiki) | [RDocs](http://rubydoc.info/github/piotrmurach/github/master/frames)
23
21
 
@@ -738,4 +736,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/piotrm
738
736
 
739
737
  ## Copyright
740
738
 
741
- Copyright (c) 2011-2017 Piotr Murach. See LICENSE.txt for further details.
739
+ Copyright (c) 2011 Piotr Murach. See LICENSE.txt for further details.
@@ -88,6 +88,5 @@ require_relative 'github_api/configuration'
88
88
  require_relative 'github_api/deprecation'
89
89
  require_relative 'github_api/core_ext/array'
90
90
  require_relative 'github_api/core_ext/hash'
91
- require_relative 'github_api/core_ext/ordered_hash'
92
91
  require_relative 'github_api/middleware'
93
92
  require_relative 'github_api/version'
@@ -229,7 +229,7 @@ module Github
229
229
 
230
230
  # Run all callbacks associated with this action
231
231
  #
232
- # @apram [Symbol] action_name
232
+ # @param [Symbol] action_name
233
233
  #
234
234
  # @api private
235
235
  def run_callbacks(action_name, &block)
@@ -7,7 +7,7 @@ require_relative '../validations'
7
7
 
8
8
  module Github
9
9
  class API
10
- # A class responsible for handilng request arguments
10
+ # A class responsible for handling request arguments
11
11
  class Arguments
12
12
  include Normalizer
13
13
  include ParameterFilter
@@ -73,7 +73,7 @@ module Github
73
73
  property_set.properties.map(&:name)
74
74
  end
75
75
 
76
- # Fetach all the properties and their values
76
+ # Fetch all the properties and their values
77
77
  #
78
78
  # @return [Hash[Symbol]]
79
79
  #
@@ -118,7 +118,7 @@ module Github
118
118
  # github.activity.starring.unstar 'user-name', 'repo-name'
119
119
  #
120
120
  # @example
121
- # github.activit.starring.unstar user: 'user-name', repo: 'repo-name'
121
+ # github.activity.starring.unstar user: 'user-name', repo: 'repo-name'
122
122
  #
123
123
  # @api public
124
124
  def unstar(*args)
@@ -13,7 +13,7 @@ module Github
13
13
  # @example
14
14
  # github = Github.new
15
15
  # github.activity.watching.list user: 'user-name', repo: 'repo-name'
16
- # github.activity.watching.list user: 'user-naem', repo: 'repo-name' { |watcher| ... }
16
+ # github.activity.watching.list user: 'user-name', repo: 'repo-name' { |watcher| ... }
17
17
  #
18
18
  # @api public
19
19
  def list(*args)
@@ -143,7 +143,7 @@ module Github
143
143
  # Optional string
144
144
  # @option [Hash] :files
145
145
  # Optional hash - Files that make up this gist.
146
- # The key of which should be a optional string filename and
146
+ # The key of which should be a optional string filename and
147
147
  # the value another optional hash with parameters:
148
148
  # @option [String] :content
149
149
  # Updated string - Update file contents.
@@ -213,7 +213,7 @@ module Github
213
213
  #
214
214
  # @see https://developer.github.com/v3/gists/#unstar-a-gist
215
215
  #
216
- # @xample
216
+ # @example
217
217
  # github = Github.new
218
218
  # github.gists.unstar 'gist-id'
219
219
  #
@@ -85,7 +85,7 @@ module Github
85
85
  #
86
86
  # @see https://developer.github.com/v3/gists/comments/#delete-a-comment
87
87
  #
88
- # @xample
88
+ # @example
89
89
  # github = Github.new
90
90
  # github.gists.comments.delete 'gist-id', 'comment-id'
91
91
  #
@@ -35,8 +35,8 @@ module Github
35
35
  repo = arguments.repo
36
36
 
37
37
  response = if (ref = params.delete('ref'))
38
- validate_reference ref
39
- get_request("/repos/#{user}/#{repo}/git/refs/#{ref}", params)
38
+ formatted_ref = validate_reference ref
39
+ get_request("/repos/#{user}/#{repo}/git/#{formatted_ref}", params)
40
40
  else
41
41
  get_request("/repos/#{user}/#{repo}/git/refs", params)
42
42
  end
@@ -143,6 +143,8 @@ module Github
143
143
  unless VALID_REF_PARAM_VALUES['ref'] =~ refs
144
144
  raise ArgumentError, "Provided 'reference' is invalid"
145
145
  end
146
+
147
+ refs
146
148
  end
147
149
  end # GitData::References
148
150
  end # Github
@@ -5,7 +5,7 @@ require_relative '../api'
5
5
  module Github
6
6
  class Client::Markdown < API
7
7
 
8
- # Render an arbritrary Markdown document
8
+ # Render an arbitrary Markdown document
9
9
  #
10
10
  # = Parameters
11
11
  # <tt>:text</tt> - Required string - The Markdown text to render
@@ -79,7 +79,7 @@ module Github
79
79
  # * pull - team members can pull, but not push or
80
80
  # administor this repositories.
81
81
  # * push - team members can pull and push,
82
- # but not administor this repositores.
82
+ # but not administer this repositores.
83
83
  # * admin - team members can pull, push and
84
84
  # administor these repositories.
85
85
  # Default: pull
@@ -125,9 +125,9 @@ module Github
125
125
  # * pull - team members can pull, but not push or
126
126
  # administor this repositories.
127
127
  # * push - team members can pull and push,
128
- # but not administor this repositores.
128
+ # but not administer this repositores.
129
129
  # * admin - team members can pull, push and
130
- # administor these repositories.
130
+ # administer these repositories.
131
131
  # Default: pull
132
132
  #
133
133
  # @example
@@ -66,8 +66,8 @@ module Github
66
66
  # github.projects.cards.create :column_id, note: 'Card Note'
67
67
  #
68
68
  # @example
69
- # github = Github.new
70
- # github.projects.cards.create :column_id, content_id: <content-id>, content_type: 'content-type'
69
+ # github = Github.new
70
+ # github.projects.cards.create :column_id, content_id: <content-id>, content_type: 'content-type'
71
71
  #
72
72
  # @see https://developer.github.com/v3/projects/cards/#create-a-project-card
73
73
  #
@@ -15,6 +15,7 @@ module Github
15
15
  'downloads',
16
16
  'forks',
17
17
  'hooks',
18
+ 'invitations',
18
19
  'keys',
19
20
  'merging',
20
21
  'pages',
@@ -32,6 +33,7 @@ module Github
32
33
  homepage
33
34
  private
34
35
  has_issues
36
+ has_projects
35
37
  has_wiki
36
38
  has_downloads
37
39
  team_id
@@ -66,6 +68,9 @@ module Github
66
68
  # Access to Repos::Hooks API
67
69
  namespace :hooks
68
70
 
71
+ # Access to Repos::Invitations API
72
+ namespace :invitations
73
+
69
74
  # Access to Repos::Keys API
70
75
  namespace :keys
71
76
 
@@ -183,7 +188,7 @@ module Github
183
188
  end
184
189
  alias :find_by_id :get_by_id
185
190
 
186
- # Create a new repository for the autheticated user.
191
+ # Create a new repository for the authenticated user.
187
192
  #
188
193
  # @param [Hash] params
189
194
  # @option params [String] :name
@@ -40,7 +40,7 @@ module Github
40
40
  # Required.
41
41
  # @input params [String] :required_pull_request_reviews
42
42
  # Required.
43
- # Look to the branch protection API t see how to use these
43
+ # Look to the branch protection API to see how to use these
44
44
  # https://developer.github.com/v3/repos/branches/#update-branch-protection
45
45
  #
46
46
  # @example
@@ -33,6 +33,23 @@ module Github
33
33
  get_request("/repos/#{arguments.user}/#{arguments.repo}/readme", arguments.params)
34
34
  end
35
35
 
36
+ # Get the LICENSE
37
+ #
38
+ # This method returns the contents of the repository's license file, if one is detected.
39
+ #
40
+ # @param [Hash] params
41
+ #
42
+ # @example
43
+ # github = Github.new
44
+ # github.repos.contents.license 'user-name', 'repo-name'
45
+ #
46
+ # @api public
47
+ def license(*args)
48
+ arguments(args, required: [:user, :repo])
49
+
50
+ get_request("/repos/#{arguments.user}/#{arguments.repo}/license", arguments.params)
51
+ end
52
+
36
53
  # Get contents
37
54
  #
38
55
  # This method returns the contents of any file or directory in a repository.
@@ -66,12 +83,12 @@ module Github
66
83
  #
67
84
  # @param [Hash] params
68
85
  # @option params [String] :path
69
- # Requried string. The content path
86
+ # Required string. The content path
70
87
  # @option params [String]
71
88
  # @option params [String] :message
72
- # Requried string. The commit message.
89
+ # Required string. The commit message.
73
90
  # @option params [String] :content
74
- # Requried string. The new file content, which will be Base64 encoded
91
+ # Required string. The new file content, which will be Base64 encoded
75
92
  # @option params [String] :branch
76
93
  # The branch name. If not provided, uses the repository’s
77
94
  # default branch (usually master)
@@ -24,7 +24,7 @@ module Github
24
24
 
25
25
  # List deployments on a repository
26
26
  #
27
- # @xample
27
+ # @example
28
28
  # github = Github.new
29
29
  # github.repos.deployments.list 'user-name', 'repo-name'
30
30
  # github.repos.deployments.list 'user-name', 'repo-name' { |deployment| ... }
@@ -13,8 +13,10 @@ module Github
13
13
  #
14
14
  # @example
15
15
  # github = Github.new
16
- # github.repos.forks.list 'user-name', 'repo-name'
17
- # github.repos.forks.list 'user-name', 'repo-name' { |fork| ... }
16
+ # github.repos.forks.list('user-name', 'repo-name')
17
+ # github.repos.forks.list('user-name', 'repo-name') { |fork|
18
+ # #...
19
+ # }
18
20
  #
19
21
  # @api public
20
22
  def list(*args)
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../api'
4
+
5
+ module Github
6
+ class Client::Repos::Invitations < API
7
+ # List repo invitations
8
+ #
9
+ # @example
10
+ # github = Github.new
11
+ # github.repos.invitations.list 'user-name', 'repo-name'
12
+ #
13
+ # @example
14
+ # github.repos.invitations.list 'user-name', 'repo-name' { |cbr| .. }
15
+ #
16
+ # @return [Array]
17
+ #
18
+ # @api public
19
+ def list(*args)
20
+ arguments(args, required: [:user, :repo])
21
+
22
+ response = get_request("/repos/#{arguments.user}/#{arguments.repo}/invitations", arguments.params)
23
+ return response unless block_given?
24
+ response.each { |el| yield el }
25
+ end
26
+ alias :all :list
27
+
28
+ # Deletes a repo invitation
29
+ #
30
+ # @example
31
+ # github = Github.new
32
+ # github.repos.invitations.delete 'user-name', 'repo-name', 'invitation-id'
33
+ #
34
+ # @api public
35
+ def delete(*args)
36
+ arguments(args, required: [:user, :repo, :id])
37
+
38
+ delete_request("/repos/#{arguments.user}/#{arguments.repo}/invitations/#{arguments.id}", arguments.params)
39
+ end
40
+ end
41
+ end
@@ -65,7 +65,7 @@ module Github
65
65
 
66
66
  # Creates http connection
67
67
  #
68
- # Returns a Fraday::Connection object
68
+ # Returns a Faraday::Connection object
69
69
  def connection(api, options = {})
70
70
  connection_options = default_options(options)
71
71
  connection_options.merge!(builder: stack(options.merge!(api: api)))
@@ -33,7 +33,7 @@ module Github
33
33
 
34
34
  MIN_BODY_LENGTH = 2
35
35
 
36
- # Crate a ServiceError
36
+ # Create a ServiceError
37
37
  #
38
38
  # @param [Hash[Symbol]] response
39
39
  #
@@ -17,6 +17,8 @@ module Faraday
17
17
  end
18
18
  end
19
19
 
20
+ module_function
21
+
20
22
  def build_nested_query(value, prefix = nil, encoder = nil)
21
23
  case value
22
24
  when Array
@@ -14,7 +14,7 @@ module Github
14
14
  @links = Github::PageLinks.new(env[:response_headers])
15
15
  end
16
16
 
17
- # Retrive number of total pages base on current :per_page parameter
17
+ # Retrieve number of total pages base on current :per_page parameter
18
18
  def count_pages
19
19
  page_iterator.count.to_i
20
20
  end
@@ -43,7 +43,7 @@ module Github
43
43
  end
44
44
  end
45
45
 
46
- # Retrives the result of the first page. Returns <tt>nil</tt> if there is
46
+ # Retrieves the result of the first page. Returns <tt>nil</tt> if there is
47
47
  # no first page - either because you are already on the first page
48
48
  # or there are no pages at all in the result.
49
49
  def first_page
@@ -52,7 +52,7 @@ module Github
52
52
  first_request
53
53
  end
54
54
 
55
- # Retrives the result of the next page. Returns <tt>nil</tt> if there is
55
+ # Retrieves the result of the next page. Returns <tt>nil</tt> if there is
56
56
  # no next page or no pages at all.
57
57
  def next_page
58
58
  next_request = page_iterator.next
@@ -60,7 +60,7 @@ module Github
60
60
  next_request
61
61
  end
62
62
 
63
- # Retrives the result of the previous page. Returns <tt>nil</tt> if there is
63
+ # Retrieves the result of the previous page. Returns <tt>nil</tt> if there is
64
64
  # no previous page or no pages at all.
65
65
  def prev_page
66
66
  prev_request = page_iterator.prev
@@ -69,7 +69,7 @@ module Github
69
69
  end
70
70
  alias :previous_page :prev_page
71
71
 
72
- # Retrives the result of the last page. Returns <tt>nil</tt> if there is
72
+ # Retrieves the result of the last page. Returns <tt>nil</tt> if there is
73
73
  # no last page - either because you are already on the last page,
74
74
  # there is only one page or there are no pages at all in the result.
75
75
  def last_page
@@ -78,7 +78,7 @@ module Github
78
78
  last_request
79
79
  end
80
80
 
81
- # Retrives a specific result for a page given page number.
81
+ # Retrieves a specific result for a page given page number.
82
82
  # The <tt>page_number</tt> parameter is not validate, hitting a page
83
83
  # that does not exist will return Github API error. Consequently, if
84
84
  # there is only one page, this method returns nil
@@ -43,8 +43,7 @@ module Github
43
43
 
44
44
  # Performs a request
45
45
  #
46
- # @param [Symbol] method - The Symbol the HTTP verb
47
- # @param [String] path - String relative URL to access
46
+ # @param current_options [Hash]
48
47
  # @param [ParamsHash] params - ParamsHash to configure the request API
49
48
  #
50
49
  # @return [Github::ResponseWrapper]
@@ -52,7 +51,7 @@ module Github
52
51
  # @api private
53
52
  def call(current_options, params)
54
53
  unless HTTP_METHODS.include?(action)
55
- raise ArgumentError, "unknown http method: #{method}"
54
+ raise ArgumentError, "unknown http method: #{action}"
56
55
  end
57
56
 
58
57
  puts "EXECUTED: #{action} - #{path} with PARAMS: #{params.request_params}" if ENV['DEBUG']
@@ -8,7 +8,7 @@ require 'set'
8
8
 
9
9
  module Github
10
10
  # Public: Exception thrown when the maximum amount of requests is exceeded.
11
- class RedirectLimitReached < Faraday::Error::ClientError
11
+ class RedirectLimitReached < Faraday::ClientError
12
12
  attr_reader :response
13
13
 
14
14
  def initialize(response)
@@ -7,7 +7,7 @@ module Github
7
7
  # A mixin to help validate presence of non-empty values
8
8
  module Presence
9
9
 
10
- # Ensure that esential arguments are present before request is made.
10
+ # Ensure that essential arguments are present before request is made.
11
11
  #
12
12
  # == Parameters
13
13
  # Hash/Array of arguments to be checked against nil and empty string