github_api 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. data/LICENSE.txt +20 -0
  2. data/README.rdoc +228 -0
  3. data/Rakefile +52 -0
  4. data/features/github_api.feature +50 -0
  5. data/features/options.feature +4 -0
  6. data/features/pagination.feature +4 -0
  7. data/features/step_definitions/github_api_steps.rb +11 -0
  8. data/features/support/env.rb +13 -0
  9. data/lib/github_api.rb +73 -0
  10. data/lib/github_api/api.rb +175 -0
  11. data/lib/github_api/api/utils.rb +9 -0
  12. data/lib/github_api/authorization.rb +73 -0
  13. data/lib/github_api/authorizations.rb +119 -0
  14. data/lib/github_api/cache_control.rb +19 -0
  15. data/lib/github_api/client.rb +55 -0
  16. data/lib/github_api/compatibility.rb +23 -0
  17. data/lib/github_api/configuration.rb +96 -0
  18. data/lib/github_api/connection.rb +75 -0
  19. data/lib/github_api/core_ext/array.rb +14 -0
  20. data/lib/github_api/core_ext/hash.rb +42 -0
  21. data/lib/github_api/error.rb +35 -0
  22. data/lib/github_api/events.rb +202 -0
  23. data/lib/github_api/gists.rb +200 -0
  24. data/lib/github_api/gists/comments.rb +86 -0
  25. data/lib/github_api/git_data.rb +26 -0
  26. data/lib/github_api/git_data/blobs.rb +51 -0
  27. data/lib/github_api/git_data/commits.rb +78 -0
  28. data/lib/github_api/git_data/references.rb +113 -0
  29. data/lib/github_api/git_data/tags.rb +78 -0
  30. data/lib/github_api/git_data/trees.rb +89 -0
  31. data/lib/github_api/issues.rb +215 -0
  32. data/lib/github_api/issues/comments.rb +123 -0
  33. data/lib/github_api/issues/events.rb +54 -0
  34. data/lib/github_api/issues/labels.rb +191 -0
  35. data/lib/github_api/issues/milestones.rb +140 -0
  36. data/lib/github_api/mime_type.rb +55 -0
  37. data/lib/github_api/orgs.rb +95 -0
  38. data/lib/github_api/orgs/members.rb +120 -0
  39. data/lib/github_api/orgs/teams.rb +245 -0
  40. data/lib/github_api/pull_requests.rb +224 -0
  41. data/lib/github_api/pull_requests/comments.rb +144 -0
  42. data/lib/github_api/repos.rb +286 -0
  43. data/lib/github_api/repos/collaborators.rb +81 -0
  44. data/lib/github_api/repos/commits.rb +180 -0
  45. data/lib/github_api/repos/downloads.rb +155 -0
  46. data/lib/github_api/repos/forks.rb +48 -0
  47. data/lib/github_api/repos/hooks.rb +174 -0
  48. data/lib/github_api/repos/keys.rb +104 -0
  49. data/lib/github_api/repos/pub_sub_hubbub.rb +102 -0
  50. data/lib/github_api/repos/watching.rb +94 -0
  51. data/lib/github_api/request.rb +84 -0
  52. data/lib/github_api/request/basic_auth.rb +31 -0
  53. data/lib/github_api/request/caching.rb +33 -0
  54. data/lib/github_api/request/oauth2.rb +33 -0
  55. data/lib/github_api/response.rb +28 -0
  56. data/lib/github_api/response/helpers.rb +14 -0
  57. data/lib/github_api/response/jsonize.rb +26 -0
  58. data/lib/github_api/response/mashify.rb +24 -0
  59. data/lib/github_api/response/raise_error.rb +33 -0
  60. data/lib/github_api/result.rb +42 -0
  61. data/lib/github_api/users.rb +84 -0
  62. data/lib/github_api/users/emails.rb +49 -0
  63. data/lib/github_api/users/followers.rb +98 -0
  64. data/lib/github_api/users/keys.rb +84 -0
  65. data/lib/github_api/version.rb +12 -0
  66. data/spec/README.rdoc +22 -0
  67. data/spec/coverage_adapter.rb +15 -0
  68. data/spec/fixtures/auths/authorization.json +14 -0
  69. data/spec/fixtures/auths/authorizations.json +16 -0
  70. data/spec/fixtures/events/events.json +29 -0
  71. data/spec/fixtures/issues/comment.json +13 -0
  72. data/spec/fixtures/issues/comments.json +15 -0
  73. data/spec/fixtures/issues/event.json +13 -0
  74. data/spec/fixtures/issues/events.json +15 -0
  75. data/spec/fixtures/issues/issue.json +56 -0
  76. data/spec/fixtures/issues/issues.json +58 -0
  77. data/spec/fixtures/issues/milestone.json +18 -0
  78. data/spec/fixtures/issues/milestones.json +20 -0
  79. data/spec/fixtures/orgs/members.json +9 -0
  80. data/spec/fixtures/orgs/org.json +18 -0
  81. data/spec/fixtures/orgs/orgs.json +8 -0
  82. data/spec/fixtures/orgs/team.json +8 -0
  83. data/spec/fixtures/orgs/team_repos.json +29 -0
  84. data/spec/fixtures/orgs/teams.json +7 -0
  85. data/spec/fixtures/repos/branches.json +9 -0
  86. data/spec/fixtures/repos/collaborators.json +8 -0
  87. data/spec/fixtures/repos/commit.json +53 -0
  88. data/spec/fixtures/repos/commit_comment.json +16 -0
  89. data/spec/fixtures/repos/commit_comments.json +18 -0
  90. data/spec/fixtures/repos/commits.json +27 -0
  91. data/spec/fixtures/repos/contributors.json +8 -0
  92. data/spec/fixtures/repos/download.json +10 -0
  93. data/spec/fixtures/repos/download_s3.json +21 -0
  94. data/spec/fixtures/repos/downloads.json +12 -0
  95. data/spec/fixtures/repos/fork.json +27 -0
  96. data/spec/fixtures/repos/forks.json +29 -0
  97. data/spec/fixtures/repos/hook.json +15 -0
  98. data/spec/fixtures/repos/hooks.json +10 -0
  99. data/spec/fixtures/repos/key.json +6 -0
  100. data/spec/fixtures/repos/keys.json +8 -0
  101. data/spec/fixtures/repos/languages.json +4 -0
  102. data/spec/fixtures/repos/repo.json +90 -0
  103. data/spec/fixtures/repos/repo_comments.json +18 -0
  104. data/spec/fixtures/repos/repos.json +29 -0
  105. data/spec/fixtures/repos/tags.json +11 -0
  106. data/spec/fixtures/repos/teams.json +7 -0
  107. data/spec/fixtures/repos/watched.json +29 -0
  108. data/spec/fixtures/repos/watchers.json +8 -0
  109. data/spec/fixtures/users/user.json +32 -0
  110. data/spec/github/api_spec.rb +25 -0
  111. data/spec/github/authorization_spec.rb +176 -0
  112. data/spec/github/authorizations_spec.rb +242 -0
  113. data/spec/github/client_spec.rb +50 -0
  114. data/spec/github/core_ext/hash_spec.rb +44 -0
  115. data/spec/github/events_spec.rb +491 -0
  116. data/spec/github/gists/comments_spec.rb +5 -0
  117. data/spec/github/gists_spec.rb +5 -0
  118. data/spec/github/git_data/blobs_spec.rb +5 -0
  119. data/spec/github/git_data/commits_spec.rb +5 -0
  120. data/spec/github/git_data/references_spec.rb +5 -0
  121. data/spec/github/git_data/tags_spec.rb +5 -0
  122. data/spec/github/git_data/trees_spec.rb +5 -0
  123. data/spec/github/git_data_spec.rb +5 -0
  124. data/spec/github/issues/comments_spec.rb +254 -0
  125. data/spec/github/issues/events_spec.rb +153 -0
  126. data/spec/github/issues/labels_spec.rb +5 -0
  127. data/spec/github/issues/milestones_spec.rb +260 -0
  128. data/spec/github/issues_spec.rb +287 -0
  129. data/spec/github/mime_type_spec.rb +70 -0
  130. data/spec/github/orgs/members_spec.rb +275 -0
  131. data/spec/github/orgs/teams_spec.rb +563 -0
  132. data/spec/github/orgs_spec.rb +160 -0
  133. data/spec/github/repos/collaborators_spec.rb +169 -0
  134. data/spec/github/repos/commits_spec.rb +424 -0
  135. data/spec/github/repos/downloads_spec.rb +247 -0
  136. data/spec/github/repos/forks_spec.rb +108 -0
  137. data/spec/github/repos/hooks_spec.rb +333 -0
  138. data/spec/github/repos/keys_spec.rb +217 -0
  139. data/spec/github/repos/pub_sub_hubbub_spec.rb +83 -0
  140. data/spec/github/repos/watching_spec.rb +222 -0
  141. data/spec/github/repos_spec.rb +571 -0
  142. data/spec/github/result_spec.rb +43 -0
  143. data/spec/github/users_spec.rb +140 -0
  144. data/spec/github_spec.rb +109 -0
  145. data/spec/spec_helper.rb +86 -0
  146. data/spec/support/base.rb +13 -0
  147. metadata +149 -4
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Piotr Murach
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,228 @@
1
+ = GithubAPI {<img src="http://travis-ci.org/peter-murach/github.png?branch=master" />}[http://travis-ci.org/peter-murach/github] {<img src="https://gemnasium.com/peter-murach/github.png?travis" />}[https://gemnasium.com/peter-murach/github]
2
+
3
+ Wiki[https://github.com/peter-murach/github/wiki] | RDocs[http://rubydoc.info/github/peter-murach/github/master/frames]
4
+
5
+ A Ruby wrapper for the GitHub REST API v3.
6
+
7
+ Supports all the API methods(nearly 200). It's build in a modular way, that is, you can either instantiate the whole api wrapper Github.new or use parts of it e.i. Github::Repos.new if working solely with repositories is your main concern.
8
+
9
+ == Installation
10
+
11
+ Grab the gem by issuing
12
+
13
+ gem install github_api
14
+
15
+ or in your Gemfile
16
+
17
+ gem "github_api"
18
+
19
+ == Usage
20
+
21
+ Create a new client instance
22
+
23
+ @github = Github.new
24
+
25
+ At this stage you can also supply various configuration parameters, such as :user, :repo, :org, :oauth_token, :login, :password or :basic_auth which are used throughout the API
26
+
27
+ @github = Github.new :user => 'peter-murach', :repo => 'github-api'
28
+
29
+ You can authenticate either using OAuth authentication convenience methods(see section OAuth) or through basic authentication by passing your login and password credentials
30
+
31
+ @github = Github.new :login => 'peter-murach', :password => '...'
32
+
33
+ or use convenience method:
34
+
35
+ @github = Github.new :basic_auth => 'login:password'
36
+
37
+ You can interact with GitHub interface, for example repositories, by issueing following calls
38
+
39
+ @github.repos.commits
40
+ @github.repos.branches
41
+ @github.repos.contributors
42
+
43
+ The code base is modular and allows for you to work specifically with a given part of GitHub API e.g. repositories
44
+
45
+ @repos = Github::Repos.new
46
+ @repos.branches 'peter-murach', 'github'
47
+
48
+ or
49
+
50
+ @repos = Github::Repos.new :user => 'peter-murach', :repo => 'github'
51
+ @repos.branches
52
+
53
+ The response is of type [Hashie::Mash] and allows to traverse all the json response attributes like method calls e.i.
54
+
55
+ @repos = Github::Repos.new :user => 'peter-murach', :repo => 'github'
56
+ @repos.branches do |branch|
57
+ puts branch.name
58
+ end
59
+
60
+ == API
61
+
62
+ Main API methods are grouped into the following classes that can be instantiated on their own
63
+
64
+ Github - full API access
65
+ Github::Gists
66
+ Github::GitData
67
+ Github::Issues
68
+ Github::Orgs
69
+ Github::PullRequests
70
+ Github::Repos
71
+ Github::Users
72
+ Github::Events
73
+ Github::Authorizations
74
+
75
+ Some parts of GitHub API v3 require you to be autheticated, for instance the following are examples of APIs only for the authenticated user
76
+
77
+ Github::Users::Emails
78
+ Github::Users::Keys
79
+
80
+ All method calls form ruby like sentences and allow for intuitive api navigation, for instance
81
+
82
+ @github = Github.new :oauth_token => '...'
83
+ @github.users.following 'wycats' # => returns users that 'wycats' is following
84
+ @github.users.following 'wycats' # => returns true if following, otherwise false
85
+
86
+ For specification on all available methods go to http://developer.github.com/v3/ or
87
+ read the rdoc, all methods are documented there with examples of usage.
88
+
89
+ == Inputs
90
+
91
+ Some API methods apart from required parameters such as username, repository name
92
+ or organisation name, allow you to switch the way the data is returned to you, for instance
93
+
94
+ @github = Github.new
95
+ @github.git_data.tree 'peter-murach', 'github', 'c18647b75d72f19c1e0cc8af031e5d833b7f12ea' # => gets a tree
96
+
97
+ @github.git_data.tree 'peter-murach', 'github', 'c18647b75d72f19c1e0cc8af031e5d833b7f12ea', :recursive => true # => gets a whole tree recursively
98
+
99
+ by passing a block you can iterate over the file tree
100
+
101
+ @github.git_data.tree 'peter-murach', 'github', 'c18647b75d72f19c1e0cc8af031e5d833b7f12ea', :recursive => true do |file|
102
+ puts file.path
103
+ end
104
+
105
+ == OAuth
106
+
107
+ In order to authenticate the user through OAuth2 on GitHub you need to
108
+
109
+ * visit https://github.com/account/applications/ and register your app
110
+
111
+ * authorize your credentials https://github.com/login/oauth/authorize
112
+ You can use convenience methods to help you achieve this that come with this gem:
113
+
114
+ @github = Github.new :client_id => '...', :client_secret => '...'
115
+ @github.authorize_url :redirect_uri => 'http://localhost', :scope => 'repo'
116
+ # => "https://github.com/login/oauth/authorize?scope=repo&response_type=code&client_id='...'&redirect_uri=http%3A%2F%2Flocalhost"
117
+
118
+ After you get your authorization code, call to receive your access_token
119
+
120
+ token = github.get_token( authorization_code )
121
+
122
+ Once you have your access token, configure your github instance following instructions under Configuration.
123
+
124
+ Alternatively you can use OAuth Authorizations API. For instance, to create access token through GitHub API do following
125
+
126
+ @github = Github.new :basic_auth => 'login:password'
127
+ @github.oauth.create_authorization 'scopes' => ['repo']
128
+
129
+ You can add more than one scope from the <tt>user</tt>, <tt>public_repo</tt>, <tt>repo</tt>, <tt>gist</tt> or leave the scopes parameter out, in which case, the default read-only access will be assumed(includes public user profile info, public repo info, and gists).
130
+
131
+ == MIME Types
132
+
133
+ 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.
134
+
135
+ In order to pass a mime type with your request do
136
+
137
+ @github = Github.new
138
+ @github.pull_requests.pull_requests 'peter-murach', 'github', :mime_type => :full
139
+
140
+ Your header will contain 'Accept: "application/vnd.github-pull.full+json"' which in turn returns raw, text and html representations in response body.
141
+
142
+ == Configuration
143
+
144
+ Certain methods require authentication. To get your GitHub OAuth v2 credentials,
145
+ register an app at https://github.com/account/applications/
146
+
147
+ Github.configure do |config|
148
+ config.oauth_token = YOUR_OAUTH_ACCESS_TOKEN
149
+ config.basic_auth = 'login:password'
150
+ end
151
+
152
+ or
153
+
154
+ Github.new(:oauth_token => YOUR_OAUTH_TOKEN)
155
+ Github.new(:basic_auth => 'login:password)
156
+
157
+ All parameters can be overwirtten as per method call. By passing parameters hash...
158
+
159
+ == Caching
160
+
161
+ Each <tt>get</tt> request by default is not going to be cached. In order to set the cache do... If no cache type is provided a default memoization is done.
162
+
163
+ Github.cache do...
164
+
165
+ == Examples
166
+
167
+ Some api methods require input parameters, these are added simply as a hash properties, for instance
168
+
169
+ @issues = Github::Issues.new :user => 'peter-murach', :repo => 'github-api'
170
+ @issues.milestones :state => 'open', :sort => 'due_date', :direction => 'asc'
171
+
172
+ Other methods may require inputs as an array of strings
173
+
174
+ @users = Github::Users.new :oauth_token => '...'
175
+ @users.add_email 'email1', 'email2', ..., 'emailn' # => Adds emails to the authenticated user
176
+
177
+ If a method returns a collection, you can iterator over it by supplying a block parameter,
178
+
179
+ @issues = Github::Issues.new :user => 'peter-murach', :repo => 'github-api'
180
+ @issues.events do |event|
181
+ puts event.actor.login
182
+ end
183
+
184
+ Query requests instead of http responses return boolean values
185
+
186
+ @github = Github.new
187
+ @github.orgs.public_member? 'github', 'technoweenie' # => true
188
+
189
+ == Rails Example
190
+
191
+ A Rails controller that allows a user to authorize their GitHub account and then perform request.
192
+
193
+ class GithubController < ApplicationController
194
+
195
+ def authorize
196
+ github = Github.new :client_id => '...', :client_secret => '...'
197
+ address = github.authorize_url :redirect_uri => 'http://...', :scope => 'repo'
198
+ redirect_to address
199
+ end
200
+
201
+ def callback
202
+ authorization_code = params[:code]
203
+ token = github.get_token authorization_code
204
+ access_token = token.token
205
+ end
206
+ end
207
+
208
+ == TODO
209
+
210
+ * Add request caching - local filestore?, http caching?.
211
+ * Add response processing methods
212
+ * Add response set helper methods e.i. pagination.
213
+ * Add DSL falvoured api access
214
+
215
+ == Contributing to github
216
+
217
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
218
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
219
+ * Fork the project
220
+ * Start a feature/bugfix branch
221
+ * Commit and push until you are happy with your contribution
222
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
223
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
224
+
225
+ == Copyright
226
+
227
+ Copyright (c) 2011 Piotr Murach. See LICENSE.txt for
228
+ further details.
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "github"
18
+ gem.homepage = "http://github.com/peter-murach/github"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{TODO: one-line summary of your gem}
21
+ gem.description = %Q{TODO: longer description of your gem}
22
+ gem.email = ""
23
+ gem.authors = ["Piotr Murach"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ require 'cucumber/rake/task'
40
+ Cucumber::Rake::Task.new(:features)
41
+
42
+ task :default => :spec
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "github #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
@@ -0,0 +1,50 @@
1
+ Feature: Github API components
2
+
3
+ In order to interact with full Github API
4
+ A user needs to request a Github class instance
5
+
6
+ Scenario: Accessing repositories API
7
+ Given I have github instance
8
+ When I fetch "repos"
9
+ Then I will have access to "Github::Repos" API
10
+
11
+ Scenario: Accessing organizations API
12
+ Given I have github instance
13
+ When I fetch "orgs"
14
+ Then I will have access to "Github::Orgs" API
15
+
16
+ Scenario: Accessing gists API
17
+ Given I have github instance
18
+ When I fetch "gists"
19
+ Then I will have access to "Github::Gists" API
20
+
21
+ Scenario: Accessing issues API
22
+ Given I have github instance
23
+ When I fetch "issues"
24
+ Then I will have access to "Github::Issues" API
25
+
26
+ Scenario: Accessing pull requests API
27
+ Given I have github instance
28
+ When I fetch "pull_requests"
29
+ Then I will have access to "Github::PullRequests" API
30
+
31
+ Scenario: Accessing git data API
32
+ Given I have github instance
33
+ When I fetch "git_data"
34
+ Then I will have access to "Github::GitData" API
35
+
36
+ Scenario: Accessing users API
37
+ Given I have github instance
38
+ When I fetch "users"
39
+ Then I will have access to "Github::Users" API
40
+
41
+ Scenario: Accessing users API
42
+ Given I have github instance
43
+ When I fetch "events"
44
+ Then I will have access to "Github::Events" API
45
+
46
+ Scenario: Accessing authorizations API
47
+ Given I have github instance
48
+ When I fetch "oauth"
49
+ Then I will have access to "Github::Authorizations" API
50
+
@@ -0,0 +1,4 @@
1
+ Feature: Github API options setting
2
+ In order to customize options used
3
+ As a user
4
+ I want to be able to set them easily
@@ -0,0 +1,4 @@
1
+ Feature: Githu API pagination
2
+ In order to paginate number of received records
3
+ As a user
4
+ I want to be able to view them in butches
@@ -0,0 +1,11 @@
1
+ Given /^I have github instance$/ do
2
+ @github = Github.new
3
+ end
4
+
5
+ When /^I fetch "([^"]*)"$/ do |method|
6
+ @response = @github.send(method.to_sym)
7
+ end
8
+
9
+ When /^I will have access to "([^"]*)" API$/ do |api|
10
+ @response.class.to_s.should match api
11
+ end
@@ -0,0 +1,13 @@
1
+ require 'bundler'
2
+ begin
3
+ Bundler.setup(:default, :development)
4
+ rescue Bundler::BundlerError => e
5
+ $stderr.puts e.message
6
+ $stderr.puts "Run `bundle install` to install missing gems"
7
+ exit e.status_code
8
+ end
9
+
10
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
11
+ require 'github_api'
12
+
13
+ require 'rspec/expectations'
@@ -0,0 +1,73 @@
1
+ # encoding: utf-8
2
+
3
+ require 'github_api/version'
4
+ require 'github_api/configuration'
5
+ require 'github_api/connection'
6
+
7
+ module Github
8
+ extend Configuration
9
+
10
+ class << self
11
+ # Alias for Github::Client.new
12
+ #
13
+ # @return [Github::Client]
14
+ def new(options = {})
15
+ Github::Client.new(options)
16
+ end
17
+
18
+ # Delegate to Github::Client
19
+ #
20
+ def method_missing(method, *args, &block)
21
+ return super unless new.respond_to?(method)
22
+ new.send(method, *args, &block)
23
+ end
24
+
25
+ def respond_to?(method, include_private = false)
26
+ new.respond_to?(method, include_private) || super(method, include_private)
27
+ end
28
+
29
+ end
30
+
31
+ module AutoloadHelper
32
+
33
+ def autoload_all(prefix, options)
34
+ options.each do |const_name, path|
35
+ autoload const_name, File.join(prefix, path)
36
+ end
37
+ end
38
+
39
+ def register_constant(options)
40
+ options.each do |const_name, value|
41
+ const_set const_name.upcase.to_s, value
42
+ end
43
+ end
44
+
45
+ def lookup_constant(const_name)
46
+ const_get const_name.upcase.to_s
47
+ end
48
+
49
+ end
50
+
51
+ extend AutoloadHelper
52
+
53
+ autoload_all 'github_api',
54
+ :API => 'api',
55
+ :Client => 'client',
56
+ :Repos => 'repos',
57
+ :Request => 'request',
58
+ :Response => 'response',
59
+ :Result => 'result',
60
+ :Error => 'error',
61
+ :Issues => 'issues',
62
+ :Gists => 'gists',
63
+ :GitData => 'git_data',
64
+ :Orgs => 'orgs',
65
+ :PullRequests => 'pull_requests',
66
+ :Users => 'users',
67
+ :Events => 'events',
68
+ :CoreExt => 'core_ext',
69
+ :MimeType => 'mime_type',
70
+ :Authorization => 'authorization',
71
+ :Authorizations => 'authorizations'
72
+
73
+ end # Github