lingfennan-github_api 0.18.2
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.
- checksums.yaml +7 -0
- data/LICENSE.txt +20 -0
- data/README.md +741 -0
- data/lib/github_api.rb +93 -0
- data/lib/github_api/api.rb +398 -0
- data/lib/github_api/api/actions.rb +60 -0
- data/lib/github_api/api/arguments.rb +253 -0
- data/lib/github_api/api/config.rb +105 -0
- data/lib/github_api/api/config/property.rb +30 -0
- data/lib/github_api/api/config/property_set.rb +120 -0
- data/lib/github_api/api/factory.rb +33 -0
- data/lib/github_api/authorization.rb +75 -0
- data/lib/github_api/client.rb +77 -0
- data/lib/github_api/client/activity.rb +31 -0
- data/lib/github_api/client/activity/events.rb +233 -0
- data/lib/github_api/client/activity/feeds.rb +50 -0
- data/lib/github_api/client/activity/notifications.rb +181 -0
- data/lib/github_api/client/activity/starring.rb +130 -0
- data/lib/github_api/client/activity/watching.rb +176 -0
- data/lib/github_api/client/authorizations.rb +142 -0
- data/lib/github_api/client/authorizations/app.rb +98 -0
- data/lib/github_api/client/emojis.rb +19 -0
- data/lib/github_api/client/gists.rb +289 -0
- data/lib/github_api/client/gists/comments.rb +100 -0
- data/lib/github_api/client/git_data.rb +31 -0
- data/lib/github_api/client/git_data/blobs.rb +51 -0
- data/lib/github_api/client/git_data/commits.rb +101 -0
- data/lib/github_api/client/git_data/references.rb +150 -0
- data/lib/github_api/client/git_data/tags.rb +95 -0
- data/lib/github_api/client/git_data/trees.rb +113 -0
- data/lib/github_api/client/gitignore.rb +57 -0
- data/lib/github_api/client/issues.rb +248 -0
- data/lib/github_api/client/issues/assignees.rb +77 -0
- data/lib/github_api/client/issues/comments.rb +146 -0
- data/lib/github_api/client/issues/events.rb +50 -0
- data/lib/github_api/client/issues/labels.rb +189 -0
- data/lib/github_api/client/issues/milestones.rb +146 -0
- data/lib/github_api/client/markdown.rb +62 -0
- data/lib/github_api/client/meta.rb +19 -0
- data/lib/github_api/client/orgs.rb +127 -0
- data/lib/github_api/client/orgs/hooks.rb +182 -0
- data/lib/github_api/client/orgs/members.rb +142 -0
- data/lib/github_api/client/orgs/memberships.rb +131 -0
- data/lib/github_api/client/orgs/projects.rb +57 -0
- data/lib/github_api/client/orgs/teams.rb +407 -0
- 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 +195 -0
- data/lib/github_api/client/pull_requests/comments.rb +140 -0
- data/lib/github_api/client/pull_requests/reviews.rb +158 -0
- data/lib/github_api/client/repos.rb +468 -0
- 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 +84 -0
- data/lib/github_api/client/repos/comments.rb +125 -0
- data/lib/github_api/client/repos/commits.rb +80 -0
- data/lib/github_api/client/repos/contents.rb +246 -0
- data/lib/github_api/client/repos/deployments.rb +138 -0
- data/lib/github_api/client/repos/downloads.rb +62 -0
- data/lib/github_api/client/repos/forks.rb +48 -0
- data/lib/github_api/client/repos/hooks.rb +214 -0
- data/lib/github_api/client/repos/keys.rb +104 -0
- data/lib/github_api/client/repos/merging.rb +47 -0
- data/lib/github_api/client/repos/pages.rb +48 -0
- data/lib/github_api/client/repos/projects.rb +62 -0
- data/lib/github_api/client/repos/pub_sub_hubbub.rb +133 -0
- data/lib/github_api/client/repos/releases.rb +189 -0
- data/lib/github_api/client/repos/releases/assets.rb +136 -0
- data/lib/github_api/client/repos/releases/tags.rb +24 -0
- data/lib/github_api/client/repos/statistics.rb +89 -0
- data/lib/github_api/client/repos/statuses.rb +91 -0
- data/lib/github_api/client/say.rb +25 -0
- data/lib/github_api/client/scopes.rb +46 -0
- data/lib/github_api/client/search.rb +133 -0
- data/lib/github_api/client/search/legacy.rb +111 -0
- data/lib/github_api/client/users.rb +117 -0
- data/lib/github_api/client/users/emails.rb +65 -0
- data/lib/github_api/client/users/followers.rb +115 -0
- data/lib/github_api/client/users/keys.rb +104 -0
- data/lib/github_api/configuration.rb +70 -0
- data/lib/github_api/connection.rb +82 -0
- data/lib/github_api/constants.rb +61 -0
- data/lib/github_api/core_ext/array.rb +25 -0
- data/lib/github_api/core_ext/hash.rb +91 -0
- data/lib/github_api/core_ext/ordered_hash.rb +107 -0
- data/lib/github_api/deprecation.rb +39 -0
- data/lib/github_api/error.rb +32 -0
- data/lib/github_api/error/client_error.rb +89 -0
- data/lib/github_api/error/service_error.rb +223 -0
- data/lib/github_api/ext/faraday.rb +38 -0
- data/lib/github_api/mash.rb +7 -0
- data/lib/github_api/middleware.rb +37 -0
- data/lib/github_api/mime_type.rb +33 -0
- data/lib/github_api/normalizer.rb +23 -0
- data/lib/github_api/null_encoder.rb +25 -0
- data/lib/github_api/page_iterator.rb +138 -0
- data/lib/github_api/page_links.rb +63 -0
- data/lib/github_api/paged_request.rb +42 -0
- data/lib/github_api/pagination.rb +115 -0
- data/lib/github_api/parameter_filter.rb +35 -0
- data/lib/github_api/params_hash.rb +115 -0
- data/lib/github_api/rate_limit.rb +25 -0
- data/lib/github_api/request.rb +85 -0
- data/lib/github_api/request/basic_auth.rb +36 -0
- data/lib/github_api/request/jsonize.rb +54 -0
- data/lib/github_api/request/oauth2.rb +44 -0
- data/lib/github_api/request/verbs.rb +63 -0
- data/lib/github_api/response.rb +48 -0
- data/lib/github_api/response/atom_parser.rb +22 -0
- data/lib/github_api/response/follow_redirects.rb +140 -0
- data/lib/github_api/response/header.rb +87 -0
- data/lib/github_api/response/jsonize.rb +28 -0
- data/lib/github_api/response/mashify.rb +24 -0
- data/lib/github_api/response/raise_error.rb +22 -0
- data/lib/github_api/response/xmlize.rb +27 -0
- data/lib/github_api/response_wrapper.rb +161 -0
- data/lib/github_api/ssl_certs/cacerts.pem +2183 -0
- data/lib/github_api/utils/url.rb +63 -0
- data/lib/github_api/validations.rb +22 -0
- data/lib/github_api/validations/format.rb +26 -0
- data/lib/github_api/validations/presence.rb +32 -0
- data/lib/github_api/validations/required.rb +21 -0
- data/lib/github_api/validations/token.rb +41 -0
- data/lib/github_api/version.rb +5 -0
- metadata +338 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative 'api/config'
|
|
4
|
+
require_relative 'version'
|
|
5
|
+
|
|
6
|
+
module Github
|
|
7
|
+
# Stores the configuration
|
|
8
|
+
class Configuration < API::Config
|
|
9
|
+
|
|
10
|
+
# Other adapters are :typhoeus, :patron, :em_synchrony, :excon, :test
|
|
11
|
+
property :adapter, default: :net_http
|
|
12
|
+
|
|
13
|
+
# By default, don't traverse the page links
|
|
14
|
+
property :auto_pagination, default: false
|
|
15
|
+
|
|
16
|
+
property :follow_redirects, default: true
|
|
17
|
+
|
|
18
|
+
# Basic authentication
|
|
19
|
+
property :basic_auth
|
|
20
|
+
|
|
21
|
+
# By default, don't set an application key
|
|
22
|
+
property :client_id
|
|
23
|
+
|
|
24
|
+
# By default, don't set an application secret
|
|
25
|
+
property :client_secret
|
|
26
|
+
|
|
27
|
+
# By default, don't set a user oauth access token
|
|
28
|
+
property :oauth_token
|
|
29
|
+
|
|
30
|
+
# The api endpoint used to connect to GitHub if none is set
|
|
31
|
+
property :endpoint, default: 'https://api.github.com'.freeze
|
|
32
|
+
|
|
33
|
+
# The web endpoint used to connect to GitHub if none is set
|
|
34
|
+
property :site, default: 'https://github.com'.freeze
|
|
35
|
+
|
|
36
|
+
# The web endpoint used to upload release assets to GitHub if none is set
|
|
37
|
+
property :upload_endpoint, default: 'https://uploads.github.com'.freeze
|
|
38
|
+
|
|
39
|
+
# The default SSL configuration
|
|
40
|
+
property :ssl, default: {
|
|
41
|
+
:ca_file => File.expand_path('../ssl_certs/cacerts.pem', __FILE__)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# By default the Accept header will make a request for JSON
|
|
45
|
+
property :mime_type
|
|
46
|
+
|
|
47
|
+
# The value sent in the http header for 'User-Agent' if none is set
|
|
48
|
+
property :user_agent, default: "Github API Ruby Gem #{Github::VERSION}".freeze
|
|
49
|
+
|
|
50
|
+
# By default uses the Faraday connection options if none is set
|
|
51
|
+
property :connection_options, default: {}
|
|
52
|
+
|
|
53
|
+
# Global repository name
|
|
54
|
+
property :repo
|
|
55
|
+
|
|
56
|
+
property :user
|
|
57
|
+
|
|
58
|
+
property :org
|
|
59
|
+
|
|
60
|
+
property :login
|
|
61
|
+
|
|
62
|
+
property :password
|
|
63
|
+
|
|
64
|
+
# By default display 30 resources
|
|
65
|
+
property :per_page, default: 30
|
|
66
|
+
|
|
67
|
+
# Add Faraday::RackBuilder to overwrite middleware
|
|
68
|
+
property :stack
|
|
69
|
+
end # Configuration
|
|
70
|
+
end # Github
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'faraday'
|
|
4
|
+
|
|
5
|
+
require_relative 'constants'
|
|
6
|
+
|
|
7
|
+
module Github
|
|
8
|
+
# Specifies Http connection options
|
|
9
|
+
module Connection
|
|
10
|
+
extend self
|
|
11
|
+
include Github::Constants
|
|
12
|
+
|
|
13
|
+
ALLOWED_OPTIONS = [
|
|
14
|
+
:headers,
|
|
15
|
+
:url,
|
|
16
|
+
:params,
|
|
17
|
+
:request,
|
|
18
|
+
:ssl
|
|
19
|
+
].freeze
|
|
20
|
+
|
|
21
|
+
# Default requets header information
|
|
22
|
+
#
|
|
23
|
+
# @return [Hash[String]]
|
|
24
|
+
#
|
|
25
|
+
# @api private
|
|
26
|
+
def default_headers
|
|
27
|
+
{
|
|
28
|
+
ACCEPT => 'application/vnd.github.v3+json,' \
|
|
29
|
+
'application/vnd.github.beta+json;q=0.5,' \
|
|
30
|
+
'application/json;q=0.1',
|
|
31
|
+
ACCEPT_CHARSET => 'utf-8'
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Create default connection options
|
|
36
|
+
#
|
|
37
|
+
# @return [Hash[Symbol]]
|
|
38
|
+
# the default options
|
|
39
|
+
#
|
|
40
|
+
# @api private
|
|
41
|
+
def default_options(options = {})
|
|
42
|
+
headers = default_headers.merge(options[:headers] || {})
|
|
43
|
+
headers.merge!({USER_AGENT => options[:user_agent]})
|
|
44
|
+
{
|
|
45
|
+
headers: headers,
|
|
46
|
+
ssl: options[:ssl],
|
|
47
|
+
url: options[:endpoint]
|
|
48
|
+
}
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Exposes middleware builder to facilitate custom stacks and easy
|
|
52
|
+
# addition of new extensions such as cache adapter.
|
|
53
|
+
#
|
|
54
|
+
# @api public
|
|
55
|
+
def stack(options = {})
|
|
56
|
+
@stack ||= begin
|
|
57
|
+
builder_class = if defined?(Faraday::RackBuilder)
|
|
58
|
+
Faraday::RackBuilder
|
|
59
|
+
else
|
|
60
|
+
Faraday::Builder
|
|
61
|
+
end
|
|
62
|
+
builder_class.new(&Github.default_middleware(options))
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Creates http connection
|
|
67
|
+
#
|
|
68
|
+
# Returns a Fraday::Connection object
|
|
69
|
+
def connection(api, options = {})
|
|
70
|
+
connection_options = default_options(options)
|
|
71
|
+
connection_options.merge!(builder: stack(options.merge!(api: api)))
|
|
72
|
+
if options[:connection_options]
|
|
73
|
+
connection_options.deep_merge!(options[:connection_options])
|
|
74
|
+
end
|
|
75
|
+
if ENV['DEBUG']
|
|
76
|
+
p "Connection options : \n"
|
|
77
|
+
pp connection_options
|
|
78
|
+
end
|
|
79
|
+
Faraday.new(connection_options)
|
|
80
|
+
end
|
|
81
|
+
end # Connection
|
|
82
|
+
end # Github
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
module Github
|
|
2
|
+
module Constants
|
|
3
|
+
extend self
|
|
4
|
+
|
|
5
|
+
# Response headers
|
|
6
|
+
RATELIMIT_REMAINING = 'X-RateLimit-Remaining'.freeze
|
|
7
|
+
|
|
8
|
+
RATELIMIT_LIMIT = 'X-RateLimit-Limit'.freeze
|
|
9
|
+
|
|
10
|
+
RATELIMIT_RESET = 'X-RateLimit-Reset'.freeze
|
|
11
|
+
|
|
12
|
+
CONTENT_TYPE = 'Content-Type'.freeze
|
|
13
|
+
|
|
14
|
+
CONTENT_LENGTH = 'content-length'.freeze
|
|
15
|
+
|
|
16
|
+
CACHE_CONTROL = 'cache-control'.freeze
|
|
17
|
+
|
|
18
|
+
ETAG = 'ETag'.freeze
|
|
19
|
+
|
|
20
|
+
SERVER = 'Server'.freeze
|
|
21
|
+
|
|
22
|
+
DATE = 'Date'.freeze
|
|
23
|
+
|
|
24
|
+
LOCATION = 'Location'.freeze
|
|
25
|
+
|
|
26
|
+
USER_AGENT = 'User-Agent'.freeze
|
|
27
|
+
|
|
28
|
+
ACCEPT = 'Accept'.freeze
|
|
29
|
+
|
|
30
|
+
ACCEPT_CHARSET = 'Accept-Charset'.freeze
|
|
31
|
+
|
|
32
|
+
OAUTH_SCOPES = 'X-OAuth-Scopes'.freeze
|
|
33
|
+
|
|
34
|
+
ACCEPTED_OAUTH_SCOPES = 'X-Accepted-Oauth-Scopes'.freeze
|
|
35
|
+
|
|
36
|
+
# Link headers
|
|
37
|
+
HEADER_LINK = "Link".freeze
|
|
38
|
+
|
|
39
|
+
HEADER_NEXT = "X-Next".freeze
|
|
40
|
+
|
|
41
|
+
HEADER_LAST = "X-Last".freeze
|
|
42
|
+
|
|
43
|
+
META_REL = "rel".freeze
|
|
44
|
+
|
|
45
|
+
META_LAST = "last".freeze
|
|
46
|
+
|
|
47
|
+
META_NEXT = "next".freeze
|
|
48
|
+
|
|
49
|
+
META_FIRST = "first".freeze
|
|
50
|
+
|
|
51
|
+
META_PREV = "prev".freeze
|
|
52
|
+
|
|
53
|
+
PARAM_PAGE = "page".freeze
|
|
54
|
+
|
|
55
|
+
PARAM_PER_PAGE = "per_page".freeze
|
|
56
|
+
|
|
57
|
+
PARAM_START_PAGE = "start_page".freeze
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
end # Constants
|
|
61
|
+
end # Github
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Array # :nodoc:
|
|
4
|
+
|
|
5
|
+
# Returns a new arrray with keys removed
|
|
6
|
+
#
|
|
7
|
+
def except(*keys)
|
|
8
|
+
self.dup.except!(*keys)
|
|
9
|
+
end unless method_defined? :except
|
|
10
|
+
|
|
11
|
+
# Similar to except but modifies self
|
|
12
|
+
#
|
|
13
|
+
def except!(*items)
|
|
14
|
+
copy = self.dup
|
|
15
|
+
copy.reject! { |item| items.include? item }
|
|
16
|
+
copy
|
|
17
|
+
end unless method_defined? :except!
|
|
18
|
+
|
|
19
|
+
# Selects a hash from the arguments list
|
|
20
|
+
#
|
|
21
|
+
def extract_options!
|
|
22
|
+
last.is_a?(::Hash) ? pop : {}
|
|
23
|
+
end unless method_defined? :extract_options!
|
|
24
|
+
|
|
25
|
+
end # Array
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Hash # :nodoc:
|
|
4
|
+
|
|
5
|
+
# Returns a new hash with keys removed
|
|
6
|
+
#
|
|
7
|
+
def except(*items)
|
|
8
|
+
self.dup.except!(*items)
|
|
9
|
+
end unless method_defined? :except
|
|
10
|
+
|
|
11
|
+
# Similar to except but modifies self
|
|
12
|
+
#
|
|
13
|
+
def except!(*keys)
|
|
14
|
+
keys.each { |key| delete(key) }
|
|
15
|
+
self
|
|
16
|
+
end unless method_defined? :except!
|
|
17
|
+
|
|
18
|
+
# Returns a new hash with all the keys converted to symbols
|
|
19
|
+
#
|
|
20
|
+
def symbolize_keys
|
|
21
|
+
inject({}) do |hash, (key, value)|
|
|
22
|
+
hash[(key.to_sym rescue key) || key] = value
|
|
23
|
+
hash
|
|
24
|
+
end
|
|
25
|
+
end unless method_defined? :symbolize_keys
|
|
26
|
+
|
|
27
|
+
# Similar to symbolize_keys but modifies self
|
|
28
|
+
#
|
|
29
|
+
def symbolize_keys!
|
|
30
|
+
hash = symbolize_keys
|
|
31
|
+
hash.each do |key, val|
|
|
32
|
+
hash[key] = case val
|
|
33
|
+
when Hash
|
|
34
|
+
val.symbolize_keys!
|
|
35
|
+
when Array
|
|
36
|
+
val.map do |item|
|
|
37
|
+
item.is_a?(Hash) ? item.symbolize_keys! : item
|
|
38
|
+
end
|
|
39
|
+
else
|
|
40
|
+
val
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
return hash
|
|
44
|
+
end unless method_defined? :symbolize_keys!
|
|
45
|
+
|
|
46
|
+
# Returns hash collapsed into a query string
|
|
47
|
+
#
|
|
48
|
+
def serialize
|
|
49
|
+
self.map { |key, val| [key, val].join("=") }.join("&")
|
|
50
|
+
end unless method_defined? :serialize
|
|
51
|
+
|
|
52
|
+
# Searches for all deeply nested keys
|
|
53
|
+
#
|
|
54
|
+
def deep_keys
|
|
55
|
+
keys = self.keys
|
|
56
|
+
keys.each do |key|
|
|
57
|
+
if self[key].is_a?(Hash)
|
|
58
|
+
keys << self[key].deep_keys.compact.flatten
|
|
59
|
+
next
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
keys.flatten
|
|
63
|
+
end unless method_defined? :deep_keys
|
|
64
|
+
|
|
65
|
+
# Returns true if the given key is present inside deeply nested hash
|
|
66
|
+
#
|
|
67
|
+
def deep_key?(key)
|
|
68
|
+
self.deep_keys.include? key
|
|
69
|
+
end unless method_defined? :deep_key?
|
|
70
|
+
|
|
71
|
+
# Recursively merges self with other hash and returns new hash.
|
|
72
|
+
#
|
|
73
|
+
def deep_merge(other, &block)
|
|
74
|
+
dup.deep_merge!(other, &block)
|
|
75
|
+
end unless method_defined? :deep_merge
|
|
76
|
+
|
|
77
|
+
# Similar as deep_merge but modifies self
|
|
78
|
+
#
|
|
79
|
+
def deep_merge!(other, &block)
|
|
80
|
+
other.each_pair do |key, val|
|
|
81
|
+
tval = self[key]
|
|
82
|
+
if tval.is_a?(Hash) && val.is_a?(Hash)
|
|
83
|
+
self[key] = tval.deep_merge(val)
|
|
84
|
+
else
|
|
85
|
+
self[key] = block && tval ? block.call(k, tval, val) : val
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
self
|
|
89
|
+
end unless method_defined? :deep_merge!
|
|
90
|
+
|
|
91
|
+
end # Hash
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
module Github
|
|
4
|
+
module CoreExt #:nodoc:
|
|
5
|
+
|
|
6
|
+
if RUBY_VERSION >= '1.9'
|
|
7
|
+
class OrderedHash < ::Hash; end
|
|
8
|
+
else
|
|
9
|
+
class OrderedHash < ::Hash
|
|
10
|
+
attr_accessor :order
|
|
11
|
+
|
|
12
|
+
class << self
|
|
13
|
+
def [](*args)
|
|
14
|
+
hsh = OrderedHash.new
|
|
15
|
+
if Hash == args[0]
|
|
16
|
+
hsh.replace args[0]
|
|
17
|
+
elsif (args.size % 2) != 0
|
|
18
|
+
pp args if ENV['DEBUG']
|
|
19
|
+
raise ArgumentError, "odd number of elements for Hash"
|
|
20
|
+
else
|
|
21
|
+
0.step(args.size - 1, 2) do |a|
|
|
22
|
+
b = a + 1
|
|
23
|
+
hsh[args[a]] = args[b]
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
hsh
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def initialize(*args, &block)
|
|
31
|
+
super
|
|
32
|
+
@order = []
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def []=(key, value)
|
|
36
|
+
@order.push key unless member?(key)
|
|
37
|
+
super key, value
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def ==(hsh2)
|
|
41
|
+
return false if @order != hsh2.order
|
|
42
|
+
super hsh2
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def clear
|
|
46
|
+
@order = []
|
|
47
|
+
super
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def delete(key)
|
|
51
|
+
@order.delete key
|
|
52
|
+
super
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def each_key
|
|
56
|
+
@order.each { |k| yield k }
|
|
57
|
+
self
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def each_value
|
|
61
|
+
@order.each { |k| yield self[k] }
|
|
62
|
+
self
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def each
|
|
66
|
+
@order.each { |k| yield k, self[k] }
|
|
67
|
+
self
|
|
68
|
+
end
|
|
69
|
+
alias :each_pair :each
|
|
70
|
+
|
|
71
|
+
def delete_if
|
|
72
|
+
@order.clone.each { |k| delete k if yield }
|
|
73
|
+
self
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def values
|
|
77
|
+
ary = []
|
|
78
|
+
@order.each { |k| ary.push self[k] }
|
|
79
|
+
ary
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def keys
|
|
83
|
+
@order
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def replace(hsh2)
|
|
87
|
+
@order = hsh2.keys
|
|
88
|
+
super hsh2
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def shift
|
|
92
|
+
key = @order.first
|
|
93
|
+
key ? [key, delete(key)] : super
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def class
|
|
97
|
+
Hash
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def __class__
|
|
101
|
+
OrderedHash
|
|
102
|
+
end
|
|
103
|
+
end # OrderedHash
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end # CoreExt
|
|
107
|
+
end # Github
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
module Github
|
|
4
|
+
|
|
5
|
+
DEPRECATION_PREFIX = "[GithubAPI] Deprecation warning:"
|
|
6
|
+
|
|
7
|
+
class << self
|
|
8
|
+
|
|
9
|
+
attr_writer :deprecation_tracker
|
|
10
|
+
|
|
11
|
+
def deprecation_tracker
|
|
12
|
+
@deprecation_tracker ||= []
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Displays deprecation message to the user.
|
|
16
|
+
# Each message is printed once.
|
|
17
|
+
def deprecate(method, alternate_method=nil)
|
|
18
|
+
return if deprecation_tracker.include? method
|
|
19
|
+
deprecation_tracker << method
|
|
20
|
+
|
|
21
|
+
message = <<-NOTICE
|
|
22
|
+
#{DEPRECATION_PREFIX}
|
|
23
|
+
|
|
24
|
+
* #{method} is deprecated.
|
|
25
|
+
NOTICE
|
|
26
|
+
if alternate_method
|
|
27
|
+
message << <<-ADDITIONAL
|
|
28
|
+
* please use #{alternate_method} instead.
|
|
29
|
+
ADDITIONAL
|
|
30
|
+
end
|
|
31
|
+
warn_deprecation(message)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def warn_deprecation(message)
|
|
35
|
+
send :warn, message
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end # Github
|