github_api 0.8.11 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. data/README.md +21 -14
  2. data/features/activity/notifications.feature +15 -0
  3. data/features/cassettes/activity/notifications/list_user.yml +54 -0
  4. data/features/step_definitions/common_steps.rb +8 -9
  5. data/lib/github_api.rb +3 -4
  6. data/lib/github_api/activity.rb +8 -13
  7. data/lib/github_api/activity/events.rb +0 -5
  8. data/lib/github_api/activity/notifications.rb +0 -5
  9. data/lib/github_api/api.rb +27 -22
  10. data/lib/github_api/api_factory.rb +13 -12
  11. data/lib/github_api/authorizations.rb +0 -5
  12. data/lib/github_api/client.rb +33 -33
  13. data/lib/github_api/configuration.rb +10 -2
  14. data/lib/github_api/connection.rb +2 -3
  15. data/lib/github_api/constants.rb +0 -3
  16. data/lib/github_api/gists.rb +2 -7
  17. data/lib/github_api/git_data.rb +10 -15
  18. data/lib/github_api/git_data/blobs.rb +0 -5
  19. data/lib/github_api/git_data/commits.rb +0 -5
  20. data/lib/github_api/git_data/references.rb +3 -7
  21. data/lib/github_api/git_data/tags.rb +0 -5
  22. data/lib/github_api/git_data/trees.rb +0 -5
  23. data/lib/github_api/gitignore.rb +0 -5
  24. data/lib/github_api/issues.rb +10 -15
  25. data/lib/github_api/issues/comments.rb +0 -5
  26. data/lib/github_api/issues/events.rb +0 -5
  27. data/lib/github_api/issues/labels.rb +0 -5
  28. data/lib/github_api/issues/milestones.rb +0 -5
  29. data/lib/github_api/markdown.rb +0 -5
  30. data/lib/github_api/meta.rb +0 -5
  31. data/lib/github_api/orgs.rb +4 -9
  32. data/lib/github_api/page_iterator.rb +44 -29
  33. data/lib/github_api/paged_request.rb +12 -12
  34. data/lib/github_api/{result.rb → pagination.rb} +19 -86
  35. data/lib/github_api/params_hash.rb +1 -1
  36. data/lib/github_api/pull_requests.rb +2 -7
  37. data/lib/github_api/repos.rb +22 -27
  38. data/lib/github_api/request.rb +7 -4
  39. data/lib/github_api/response/header.rb +76 -0
  40. data/lib/github_api/response_wrapper.rb +126 -0
  41. data/lib/github_api/scopes.rb +1 -1
  42. data/lib/github_api/search.rb +0 -5
  43. data/lib/github_api/users.rb +6 -11
  44. data/lib/github_api/version.rb +2 -2
  45. data/spec/github/activity/notifications/get_spec.rb +1 -1
  46. data/spec/github/activity/starring/starred_spec.rb +1 -1
  47. data/spec/github/activity/watching/watched_spec.rb +1 -1
  48. data/spec/github/api_factory_spec.rb +7 -8
  49. data/spec/github/api_spec.rb +0 -7
  50. data/spec/github/authorization_spec.rb +22 -32
  51. data/spec/github/authorizations/create_spec.rb +49 -0
  52. data/spec/github/authorizations/delete_spec.rb +39 -0
  53. data/spec/github/authorizations/get_spec.rb +49 -0
  54. data/spec/github/authorizations/list_spec.rb +55 -0
  55. data/spec/github/authorizations/update_spec.rb +50 -0
  56. data/spec/github/authorizations_spec.rb +2 -236
  57. data/spec/github/gists/comments/create_spec.rb +1 -1
  58. data/spec/github/gists/comments/edit_spec.rb +1 -1
  59. data/spec/github/gists/comments/get_spec.rb +1 -1
  60. data/spec/github/gists/create_spec.rb +1 -1
  61. data/spec/github/gists/edit_spec.rb +1 -1
  62. data/spec/github/gists/fork_spec.rb +1 -1
  63. data/spec/github/gists/get_spec.rb +1 -1
  64. data/spec/github/git_data/blobs/create_spec.rb +1 -1
  65. data/spec/github/git_data/blobs/get_spec.rb +1 -1
  66. data/spec/github/git_data/commits/create_spec.rb +1 -1
  67. data/spec/github/git_data/commits/get_spec.rb +1 -1
  68. data/spec/github/git_data/references/create_spec.rb +2 -2
  69. data/spec/github/git_data/references/get_spec.rb +1 -1
  70. data/spec/github/git_data/references/list_spec.rb +16 -6
  71. data/spec/github/git_data/tags/create_spec.rb +1 -1
  72. data/spec/github/git_data/tags/get_spec.rb +1 -1
  73. data/spec/github/git_data/trees/create_spec.rb +1 -1
  74. data/spec/github/git_data/trees/get_spec.rb +4 -4
  75. data/spec/github/issues/comments/create_spec.rb +1 -1
  76. data/spec/github/issues/comments/edit_spec.rb +1 -1
  77. data/spec/github/issues/comments/get_spec.rb +1 -1
  78. data/spec/github/issues/create_spec.rb +1 -1
  79. data/spec/github/issues/edit_spec.rb +1 -1
  80. data/spec/github/issues/events/get_spec.rb +1 -1
  81. data/spec/github/issues/get_spec.rb +1 -1
  82. data/spec/github/issues/labels/create_spec.rb +1 -1
  83. data/spec/github/issues/labels/get_spec.rb +1 -1
  84. data/spec/github/issues/labels/update_spec.rb +1 -1
  85. data/spec/github/issues/milestones/create_spec.rb +1 -1
  86. data/spec/github/issues/milestones/delete_spec.rb +1 -1
  87. data/spec/github/issues/milestones/get_spec.rb +1 -1
  88. data/spec/github/issues/milestones/update_spec.rb +1 -1
  89. data/spec/github/orgs/edit_spec.rb +1 -1
  90. data/spec/github/orgs/get_spec.rb +1 -1
  91. data/spec/github/orgs/teams/create_spec.rb +1 -1
  92. data/spec/github/orgs/teams/edit_spec.rb +1 -1
  93. data/spec/github/orgs/teams/get_spec.rb +1 -1
  94. data/spec/github/paged_request_spec.rb +34 -29
  95. data/spec/github/pagination/iterator/number_spec.rb +118 -0
  96. data/spec/github/pagination/iterator/sha_spec.rb +67 -0
  97. data/spec/github/pull_requests/comments/create_spec.rb +1 -1
  98. data/spec/github/pull_requests/comments/edit_spec.rb +1 -1
  99. data/spec/github/pull_requests/comments/get_spec.rb +1 -1
  100. data/spec/github/pull_requests/create_spec.rb +1 -1
  101. data/spec/github/pull_requests/get_spec.rb +1 -1
  102. data/spec/github/pull_requests/update_spec.rb +1 -1
  103. data/spec/github/repos/branch_spec.rb +1 -1
  104. data/spec/github/repos/comments/create_spec.rb +1 -1
  105. data/spec/github/repos/comments/get_spec.rb +1 -1
  106. data/spec/github/repos/comments/update_spec.rb +1 -1
  107. data/spec/github/repos/commits/get_spec.rb +1 -1
  108. data/spec/github/repos/create_spec.rb +1 -1
  109. data/spec/github/repos/downloads/create_spec.rb +1 -1
  110. data/spec/github/repos/downloads/get_spec.rb +1 -1
  111. data/spec/github/repos/edit_spec.rb +1 -1
  112. data/spec/github/repos/forks/create_spec.rb +1 -1
  113. data/spec/github/repos/get_spec.rb +1 -1
  114. data/spec/github/repos/hooks/create_spec.rb +1 -1
  115. data/spec/github/repos/hooks/edit_spec.rb +1 -1
  116. data/spec/github/repos/hooks/get_spec.rb +1 -1
  117. data/spec/github/repos/languages_spec.rb +1 -1
  118. data/spec/github/repos/merging/merge_spec.rb +1 -1
  119. data/spec/github/repos/statuses/create_spec.rb +1 -1
  120. data/spec/github/repos/tags_spec.rb +1 -1
  121. data/spec/github/repos/teams_spec.rb +1 -1
  122. data/spec/github/request/endpoint_spec.rb +24 -0
  123. data/spec/github/request/request_spec.rb +38 -0
  124. data/spec/github/{result_spec.rb → response_wrapper_spec.rb} +14 -13
  125. data/spec/github/users/emails/list_spec.rb +1 -1
  126. data/spec/github/users/get_spec.rb +2 -7
  127. data/spec/github/users/keys/create_spec.rb +1 -1
  128. data/spec/github/users/keys/get_spec.rb +1 -1
  129. data/spec/github/users/keys/update_spec.rb +1 -1
  130. data/spec/github/users/update_spec.rb +1 -1
  131. data/spec/github_spec.rb +1 -6
  132. data/spec/{github/activity → integration}/activity_spec.rb +0 -0
  133. data/spec/{github/gists → integration}/gists_spec.rb +2 -0
  134. data/spec/{github/git_data → integration}/git_data_spec.rb +0 -0
  135. data/spec/{github/issues → integration}/issues_spec.rb +2 -0
  136. data/spec/integration/options_spec.rb +103 -23
  137. data/spec/{github/orgs → integration}/orgs_spec.rb +0 -0
  138. data/spec/{github/pull_requests → integration}/pull_requests_spec.rb +0 -0
  139. data/spec/{github → integration}/repos_spec.rb +2 -0
  140. data/spec/{github/users → integration}/users_spec.rb +0 -0
  141. data/spec/shared/array_of_resources_behaviour.rb +1 -1
  142. metadata +55 -46
  143. data/lib/github_api/page_uri_processor.rb +0 -25
  144. data/lib/github_api/response/helpers.rb +0 -21
  145. data/spec/github/page_iterator_spec.rb +0 -260
  146. data/spec/github/response/helpers_spec.rb +0 -16
data/README.md CHANGED
@@ -18,12 +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
- * Requests pagination.
22
- * Easy error handling.
21
+ * Requests pagination with convenient DSL.
22
+ * Easy error handling split for client and server type errors.
23
+ * Supports multithreaded environment.
23
24
  * Custom mime types specification (Status: TODO)
24
25
  * Flexible arguments parsing (Status: In progress).
25
26
  * Request results caching (Status: TODO)
26
- * Fully tested with test coverage above 90% with over 1,300 specs and 700 features.
27
+ * Fully tested with test coverage above 90% with over 1,400 specs and 700 features.
27
28
 
28
29
  ## Installation
29
30
 
@@ -59,7 +60,7 @@ At this stage you can also supply various configuration parameters, such as `:us
59
60
  github = Github.new oauth_token: 'token'
60
61
  ```
61
62
 
62
- Alternatively, you can configure the Github settings by passing a block, for instance, with custom enteprise endpoint like
63
+ Alternatively, you can configure the Github settings by passing a block, for instance, with custom enterprise endpoint like
63
64
 
64
65
  ```ruby
65
66
  github = Github.new do |config|
@@ -254,7 +255,7 @@ To list the scopes that the particular Github API action checks for do:
254
255
  ```ruby
255
256
  repos = Github::Repos.new
256
257
  res = repos.list :user => 'peter-murach'
257
- res.accepted_oauth_scopes # => ['delete_repo', 'repo', 'public_repo', 'repo:status']
258
+ res.header.accepted_oauth_scopes # => ['delete_repo', 'repo', 'public_repo', 'repo:status']
258
259
  ```
259
260
 
260
261
  To understand what each scope means refer to [documentation](http://developer.github.com/v3/oauth/#scopes)
@@ -278,6 +279,9 @@ If your client fails to find CA certs you can pass other SSL options to specify
278
279
  }
279
280
  ```
280
281
 
282
+ For instance, download CA root certificates from Mozilla [cacert](http://curl.haxx.se/ca/cacert.pem) and point ca_file at your certificate bundle location.
283
+ This will allow the client to verify the github.com ssl certificate as authentic.
284
+
281
285
  ## MIME Types
282
286
 
283
287
  Issues, PullRequests and few other API leverage custom mime types which are <tt>:json</tt>, <tt>:blob</tt>, <tt>:raw</tt>, <tt>:text</tt>, <tt>:html</tt>, <tt>:full</tt>. By default <tt>:raw</tt> is used.
@@ -354,11 +358,12 @@ end
354
358
  One can also navigate straight to specific page by:
355
359
 
356
360
  ```ruby
357
- res.page 5 # Requests given page if it exists, nil otherwise
358
- res.first_page
359
- res.prev_page
360
- res.next_page
361
- res.last_page
361
+ res.count_pages # Number of pages
362
+ res.page 5 # Requests given page if it exists, nil otherwise
363
+ res.first_page # Get first page
364
+ res.next_page # Get next page
365
+ res.prev_page # Get previous page
366
+ res.last_page # Get last page
362
367
  ```
363
368
 
364
369
  ## Error Handling
@@ -385,10 +390,12 @@ Each response comes packaged with methods allowing for inspection of HTTP start
385
390
 
386
391
  ```ruby
387
392
  res = Github::Repos.new.branches 'peter-murach', 'github'
388
- res.ratelimit_limit # "5000"
389
- res.ratelimit_remainig # "4999"
390
- res.status # "200"
391
- res.content_type # "application/json; charset=utf-8"
393
+ res.headers.ratelimit_limit # "5000"
394
+ res.headers.ratelimit_remainig # "4999"
395
+ res.headers.status # "200"
396
+ res.headers.content_type # "application/json; charset=utf-8"
397
+ res.headers.etag # "\"2c5dfc54b3fe498779ef3a9ada9a0af9\""
398
+ res.headers.cache_control # "public, max-age=60, s-maxage=60"
392
399
  ```
393
400
 
394
401
  ## Examples
@@ -0,0 +1,15 @@
1
+ Feature: Notifications API
2
+
3
+ Background:
4
+ Given I have "Github::Activity::Notifications" instance
5
+
6
+ Scenario: List
7
+
8
+ Given I want to list resources
9
+ And I pass the following request options:
10
+ | user | repo |
11
+ | wycats | handlebars.js |
12
+ When I make request within a cassette named "activity/notifications/list_user"
13
+ Then the response status should be 200
14
+ And the response type should be JSON
15
+ And the response should be empty
@@ -0,0 +1,54 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://<BASIC_AUTH>@api.github.com/repos/wycats/handlebars.js/notifications?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.8.11
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
+ - Mon, 18 Feb 2013 22:03:48 GMT
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Connection:
32
+ - keep-alive
33
+ Status:
34
+ - 200 OK
35
+ X-Ratelimit-Limit:
36
+ - '5000'
37
+ X-Ratelimit-Remaining:
38
+ - '4999'
39
+ X-Github-Media-Type:
40
+ - github.v3; param=full; format=json
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ Content-Length:
44
+ - '2'
45
+ Etag:
46
+ - ! '"d751713988987e9331980363e24189ce"'
47
+ Cache-Control:
48
+ - max-age=0, private, must-revalidate
49
+ body:
50
+ encoding: US-ASCII
51
+ string: ! '[]'
52
+ http_version: !!null
53
+ recorded_at: Mon, 18 Feb 2013 22:03:48 GMT
54
+ recorded_with: VCR 2.4.0
@@ -30,27 +30,26 @@ end
30
30
  Then /^the response should be (.*)$/ do |expected_response|
31
31
  expected_response = case expected_response
32
32
  when /false/
33
- false
33
+ @response.should be_false
34
34
  when /true/
35
- true
35
+ @response.should be_true
36
36
  when /\d+/
37
- expected_response.to_i
37
+ @response.should eql expected_response.to_i
38
38
  when /empty/
39
- []
39
+ @response.should be_empty
40
40
  else
41
- expected_response
41
+ @response.should eql expected_response
42
42
  end
43
- @response.should eql expected_response
44
43
  end
45
44
 
46
45
  Then /^the response type should be (.*)$/ do |type|
47
46
  case type.downcase
48
47
  when 'json'
49
- @response.content_type.should =~ /application\/json/
48
+ @response.headers.content_type.should =~ /application\/json/
50
49
  when 'html'
51
- @response.content_type.should =~ /text\/html/
50
+ @response.headers.content_type.should =~ /text\/html/
52
51
  when 'raw'
53
- @response.content_type.should =~ /raw/
52
+ @response.headers.content_type.should =~ /raw/
54
53
  end
55
54
  end
56
55
 
@@ -13,14 +13,11 @@ module Github
13
13
 
14
14
  class << self
15
15
 
16
- # Handle for the client instance
17
- attr_accessor :api_client
18
-
19
16
  # Alias for Github::Client.new
20
17
  #
21
18
  # @return [Github::Client]
22
19
  def new(options = {}, &block)
23
- @api_client = Github::Client.new(options, &block)
20
+ Github::Client.new(options, &block)
24
21
  end
25
22
 
26
23
  # Delegate to Github::Client
@@ -66,6 +63,7 @@ module Github
66
63
  :Repos => 'repos',
67
64
  :Request => 'request',
68
65
  :Response => 'response',
66
+ :ResponseWrapper => 'response_wrapper',
69
67
  :Result => 'result',
70
68
  :Error => 'error',
71
69
  :Issues => 'issues',
@@ -85,6 +83,7 @@ module Github
85
83
  :MimeType => 'mime_type',
86
84
  :Authorization => 'authorization',
87
85
  :Authorizations => 'authorizations',
86
+ :Pagination => 'pagination',
88
87
  :PageLinks => 'page_links',
89
88
  :PageIterator => 'page_iterator',
90
89
  :PagedRequest => 'paged_request',
@@ -10,29 +10,24 @@ module Github
10
10
  :Starring => 'starring',
11
11
  :Watching => 'watching'
12
12
 
13
- # Create new Activity API
14
- def initialize(options = {})
15
- super(options)
16
- end
17
-
18
13
  # Access to Activity::Events API
19
- def events(options = {})
20
- @events ||= ApiFactory.new 'Activity::Events', options
14
+ def events(options={}, &block)
15
+ @events ||= ApiFactory.new('Activity::Events', current_options.merge(options), &block)
21
16
  end
22
17
 
23
18
  # Access to Activity::Notifications API
24
- def notifications
25
- @notifications ||= ApiFactory.new 'Activity::Notifications'
19
+ def notifications(options={}, &block)
20
+ @notifications ||= ApiFactory.new('Activity::Notifications', current_options.merge(options), &block)
26
21
  end
27
22
 
28
23
  # Access to Activity::Starring API
29
- def starring
30
- @starring ||= ApiFactory.new 'Activity::Starring'
24
+ def starring(options={}, &block)
25
+ @starring ||= ApiFactory.new('Activity::Starring', current_options.merge(options), &block)
31
26
  end
32
27
 
33
28
  # Access to Activity::Watching API
34
- def watching
35
- @watching ||= ApiFactory.new 'Activity::Watching'
29
+ def watching(options={}, &block)
30
+ @watching ||= ApiFactory.new('Activity::Watching', current_options.merge(options), &block)
36
31
  end
37
32
 
38
33
  end # Activity
@@ -3,11 +3,6 @@
3
3
  module Github
4
4
  class Activity::Events < API
5
5
 
6
- # Creates new Activity::Events API
7
- def initialize(options = {})
8
- super(options)
9
- end
10
-
11
6
  # List all public events
12
7
  #
13
8
  # = Examples
@@ -3,11 +3,6 @@
3
3
  module Github
4
4
  class Activity::Notifications < API
5
5
 
6
- # Creates new Activity::Notifications API
7
- def initialize(options = {})
8
- super(options)
9
- end
10
-
11
6
  # List your notifications
12
7
  #
13
8
  # List all notifications for the current user, grouped by repository.
@@ -21,45 +21,55 @@ module Github
21
21
  include Connection
22
22
  include Request
23
23
  include RateLimit
24
+ # include Configuration
24
25
 
25
26
  # TODO consider these optional in a stack
26
27
  include Validations
27
28
  include ParameterFilter
28
29
  include Normalizer
29
30
 
30
- attr_reader *Configuration::VALID_OPTIONS_KEYS
31
+ attr_reader *Configuration.keys
31
32
 
32
33
  attr_accessor *VALID_API_KEYS
33
34
 
34
- # Callback to update global configuration options
35
- class_eval do
36
- Configuration::VALID_OPTIONS_KEYS.each do |key|
37
- define_method "#{key}=" do |arg|
38
- self.instance_variable_set("@#{key}", arg)
39
- Github.send("#{key}=", arg)
40
- end
41
- end
42
- end
35
+ attr_accessor :current_options
36
+
37
+ # Callback to update current configuration options
38
+ class_eval do
39
+ Configuration.keys.each do |key|
40
+ define_method "#{key}=" do |arg|
41
+ self.instance_variable_set("@#{key}", arg)
42
+ self.current_options.merge!({:"#{key}" => arg})
43
+ end
44
+ end
45
+ end
43
46
 
44
- # Creates new API
47
+ # Create new API
48
+ #
45
49
  def initialize(options={}, &block)
46
- super()
47
- setup options
48
- set_api_client
49
- client if client_id? && client_secret?
50
+ setup(options)
51
+ client(options) if client_id? && client_secret?
52
+ yield_or_eval(&block) if block_given?
53
+ end
50
54
 
51
- self.instance_eval(&block) if block_given?
55
+ def yield_or_eval(&block)
56
+ return unless block
57
+ block.arity > 0 ? yield(self) : self.instance_eval(&block)
52
58
  end
53
59
 
60
+ # Configure options and process basic authorization
61
+ #
54
62
  def setup(options={})
55
63
  options = Github.options.merge(options)
56
- Configuration::VALID_OPTIONS_KEYS.each do |key|
64
+ self.current_options = options
65
+ Configuration.keys.each do |key|
57
66
  send("#{key}=", options[key])
58
67
  end
59
68
  process_basic_auth(options[:basic_auth])
60
69
  end
61
70
 
62
71
  # Extract login and password from basic_auth parameter
72
+ #
63
73
  def process_basic_auth(auth)
64
74
  case auth
65
75
  when String
@@ -70,11 +80,6 @@ module Github
70
80
  end
71
81
  end
72
82
 
73
- # Assigns current api class
74
- def set_api_client
75
- Github.api_client = self
76
- end
77
-
78
83
  # Responds to attribute query or attribute clear
79
84
  def method_missing(method, *args, &block) # :nodoc:
80
85
  case method.to_s
@@ -6,25 +6,26 @@ module Github
6
6
  class ApiFactory
7
7
 
8
8
  # Instantiates a new github api object
9
- def self.new(klass, options={})
10
- return create_instance(klass, options) if klass
11
- raise ArgumentError, 'must provied klass to be instantiated'
9
+ #
10
+ def self.new(klass, options={}, &block)
11
+ return create_instance(klass, options, &block) if klass
12
+ raise ArgumentError, 'must provide API class to be instantiated'
12
13
  end
13
14
 
14
15
  # Passes configuration options to instantiated class
15
- def self.create_instance(klass, options)
16
+ #
17
+ def self.create_instance(klass, options, &block)
16
18
  options.symbolize_keys!
17
- instance = convert_to_constant(klass.to_s).new options
18
- Github.api_client = instance
19
- instance
19
+ convert_to_constant(klass.to_s).new options, &block
20
20
  end
21
21
 
22
+ # Convert name to constant
23
+ #
22
24
  def self.convert_to_constant(classes)
23
- constant = Github
24
- classes.split('::').each do |klass|
25
- constant = constant.const_get klass
25
+ classes.split('::').inject(Github) do |constant, klass|
26
+ constant.const_get klass
26
27
  end
27
- return constant
28
28
  end
29
- end
29
+
30
+ end # ApiFactory
30
31
  end # Github
@@ -13,11 +13,6 @@ module Github
13
13
  client_secret
14
14
  ].freeze
15
15
 
16
- # Creates new OAuth Authorizations API
17
- def initialize(options = {})
18
- super(options)
19
- end
20
-
21
16
  # List authorizations
22
17
  #
23
18
  # = Examples
@@ -6,82 +6,82 @@ module Github
6
6
  # Serving up the ‘social’ in Social Coding™, the Activity APIs
7
7
  # provide access to notifications, subscriptions, and timelines.
8
8
  #
9
- def activity(options = {})
10
- @activity ||= ApiFactory.new 'Activity', options
9
+ def activity(options={}, &block)
10
+ @activity ||= ApiFactory.new('Activity', current_options.merge(options), &block)
11
11
  end
12
12
 
13
- def emojis(options = {})
14
- @emojis ||= ApiFactory.new 'Emojis', options
13
+ def emojis(options={}, &block)
14
+ @emojis ||= ApiFactory.new('Emojis', current_options.merge(options), &block)
15
15
  end
16
16
 
17
- def gists(options = {})
18
- @gists ||= ApiFactory.new 'Gists', options
17
+ def gists(options={}, &block)
18
+ @gists ||= ApiFactory.new('Gists', current_options.merge(options), &block)
19
19
  end
20
20
 
21
- def gitignore(options = {})
22
- @gitignore ||= ApiFactory.new 'Gitignore', options
21
+ def gitignore(options={}, &block)
22
+ @gitignore ||= ApiFactory.new('Gitignore', current_options.merge(options), &block)
23
23
  end
24
24
  alias :git_ignore :gitignore
25
25
 
26
26
  # The Git Database API gives you access to read and write raw Git objects
27
27
  # to your Git database on GitHub and to list and update your references
28
28
  # (branch heads and tags).
29
- def git_data(options = {})
30
- @git_data ||= ApiFactory.new 'GitData', options
29
+ def git_data(options={}, &block)
30
+ @git_data ||= ApiFactory.new('GitData', current_options.merge(options), &block)
31
31
  end
32
32
  alias :git :git_data
33
33
 
34
- def issues(options = {})
35
- @issues ||= ApiFactory.new 'Issues', options
34
+ def issues(options={}, &block)
35
+ @issues ||= ApiFactory.new('Issues', current_options.merge(options), &block)
36
36
  end
37
37
 
38
- def markdown(options = {})
39
- @markdown ||= ApiFactory.new 'Markdown', options
38
+ def markdown(options={}, &block)
39
+ @markdown ||= ApiFactory.new('Markdown', current_options.merge(options), &block)
40
40
  end
41
41
 
42
- def meta(options = {})
43
- @meta ||= ApiFactory.ew 'Meta', options
42
+ def meta(options={}, &block)
43
+ @meta ||= ApiFactory.new('Meta', current_options.merge(options), &block)
44
44
  end
45
45
 
46
46
  # An API for users to manage their own tokens. You can only access your own
47
47
  # tokens, and only through Basic Authentication.
48
- def oauth(options = {})
49
- @oauth ||= ApiFactory.new 'Authorizations', options
48
+ def oauth(options={}, &block)
49
+ @oauth ||= ApiFactory.new('Authorizations', current_options.merge(options), &block)
50
50
  end
51
51
  alias :authorizations :oauth
52
52
 
53
- def orgs(options = {})
54
- @orgs ||= ApiFactory.new 'Orgs', options
53
+ def orgs(options={}, &block)
54
+ @orgs ||= ApiFactory.new('Orgs', current_options.merge(options), &block)
55
55
  end
56
56
  alias :organizations :orgs
57
57
 
58
- def pull_requests(options = {})
59
- @pull_requests ||= ApiFactory.new 'PullRequests', options
58
+ def pull_requests(options={}, &block)
59
+ @pull_requests ||= ApiFactory.new('PullRequests', current_options.merge(options), &block)
60
60
  end
61
61
  alias :pulls :pull_requests
62
62
 
63
- def repos(options = {})
64
- @repos ||= ApiFactory.new 'Repos', options
63
+ def repos(options={}, &block)
64
+ @repos ||= ApiFactory.new('Repos', current_options.merge(options), &block)
65
65
  end
66
66
  alias :repositories :repos
67
67
 
68
- def octocat(options = {})
69
- @octocat ||= ApiFactory.new 'Say', options
68
+ def octocat(options={}, &block)
69
+ @octocat ||= ApiFactory.new('Say', current_options.merge(options), &block)
70
70
  end
71
71
 
72
- def scopes(options = {})
73
- @scopes ||= ApiFactory.new 'Scopes', options
72
+ def scopes(options={}, &block)
73
+ @scopes ||= ApiFactory.new('Scopes', current_options.merge(options), &block)
74
74
  end
75
75
 
76
- def search(options = {})
77
- @search ||= ApiFactory.new 'Search', options
76
+ def search(options={}, &block)
77
+ @search ||= ApiFactory.new('Search', current_options.merge(options), &block)
78
78
  end
79
79
 
80
- # Many of the resources on the users API provide a shortcut for getting
80
+ # Many of the resources on the users API provide a shortcut for getting
81
81
  # information about the currently authenticated user.
82
82
  #
83
- def users(options = {})
84
- @users ||= ApiFactory.new 'Users', options
83
+ def users(options={}, &block)
84
+ @users ||= ApiFactory.new('Users', current_options.merge(options), &block)
85
85
  end
86
86
 
87
87
  end # Client