github_api 0.1.0.pre → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +21 -3
- data/lib/github_api/api.rb +22 -2
- data/lib/github_api/client.rb +6 -1
- data/lib/github_api/configuration.rb +1 -1
- data/lib/github_api/git_data/blobs.rb +42 -0
- data/lib/github_api/git_data/commits.rb +69 -0
- data/lib/github_api/git_data/references.rb +104 -0
- data/lib/github_api/git_data/tags.rb +69 -0
- data/lib/github_api/git_data/trees.rb +80 -0
- data/lib/github_api/issues/comments.rb +1 -0
- data/lib/github_api/orgs/members.rb +1 -0
- data/lib/github_api/repos/keys.rb +68 -17
- data/lib/github_api/repos/watching.rb +68 -24
- data/lib/github_api/request/oauth2.rb +3 -3
- data/lib/github_api/version.rb +1 -1
- data/spec/fixtures/repos/key.json +6 -0
- data/spec/fixtures/repos/keys.json +8 -0
- data/spec/fixtures/repos/watched.json +29 -0
- data/spec/fixtures/repos/watchers.json +8 -0
- data/spec/github/api_spec.rb +21 -2
- data/spec/github/repos/keys_spec.rb +202 -2
- data/spec/github/repos/watching_spec.rb +209 -2
- data/spec/github/repos_spec.rb +5 -2
- data/spec/github_spec.rb +89 -1
- data/spec/spec_helper.rb +52 -1
- metadata +32 -17
data/spec/github_spec.rb
CHANGED
@@ -1,5 +1,93 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe Github do
|
4
|
-
|
4
|
+
|
5
|
+
it "should respond to 'new' message" do
|
6
|
+
Github.should respond_to :new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should receive 'new' and initialize Github::Client instance" do
|
10
|
+
Github.new.should be_a Github::Client
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should respond to 'configure' message" do
|
14
|
+
Github.should respond_to :configure
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "setting configuration options" do
|
18
|
+
|
19
|
+
it "should return default adapter" do
|
20
|
+
Github.adapter.should == Github::Configuration::DEFAULT_ADAPTER
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should allow to set adapter" do
|
24
|
+
Github.adapter = :typhoeus
|
25
|
+
Github.adapter.should == :typhoeus
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should return the default end point" do
|
29
|
+
Github.endpoint.should == Github::Configuration::DEFAULT_ENDPOINT
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should allow to set endpoint" do
|
33
|
+
Github.endpoint = 'http://linkedin.com'
|
34
|
+
Github.endpoint.should == 'http://linkedin.com'
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should return the default user agent" do
|
38
|
+
Github.user_agent.should == Github::Configuration::DEFAULT_USER_AGENT
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should allow to set new user agent" do
|
42
|
+
Github.user_agent = 'New User Agent'
|
43
|
+
Github.user_agent.should == 'New User Agent'
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should have not set oauth token" do
|
47
|
+
Github.oauth_token.should be_nil
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should allow to set oauth token" do
|
51
|
+
Github.oauth_token = ''
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should have not set default user" do
|
55
|
+
Github.user.should be_nil
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should allow to set new user" do
|
59
|
+
Github.user = 'github'
|
60
|
+
Github.user.should == 'github'
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should have not set default repository" do
|
64
|
+
Github.repo.should be_nil
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should allow to set new repository" do
|
68
|
+
Github.repo = 'github'
|
69
|
+
Github.repo.should == 'github'
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should have faraday options as hash" do
|
73
|
+
Github.faraday_options.should be_a Hash
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should initialize faraday options to empty hash" do
|
77
|
+
Github.faraday_options.should be_empty
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
describe ".configure" do
|
83
|
+
Github::Configuration::VALID_OPTIONS_KEYS.each do |key|
|
84
|
+
it "should set the #{key}" do
|
85
|
+
Github.configure do |config|
|
86
|
+
config.send("#{key}=", key)
|
87
|
+
Github.send(key).should == key
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
5
93
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,6 +4,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
4
4
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
5
5
|
|
6
6
|
require 'rspec'
|
7
|
+
require 'webmock/rspec'
|
7
8
|
require 'github_api'
|
8
9
|
|
9
10
|
# Requires supporting files with custom matchers and macros, etc,
|
@@ -11,5 +12,55 @@ require 'github_api'
|
|
11
12
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
12
13
|
|
13
14
|
RSpec.configure do |config|
|
14
|
-
|
15
|
+
config.include WebMock::API
|
15
16
|
end
|
17
|
+
|
18
|
+
def stub_get(path, endpoint = Github.endpoint)
|
19
|
+
stub_request(:get, endpoint + path)
|
20
|
+
end
|
21
|
+
|
22
|
+
def stub_post(path, endpoint = Github.endpoint)
|
23
|
+
stub_request(:post, endpoint + path)
|
24
|
+
end
|
25
|
+
|
26
|
+
def stub_patch(path, endpoint = Github.endpoint)
|
27
|
+
stub_request(:patch, endpoint + path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def stub_put(path, endpoint = Github.endpoint)
|
31
|
+
stub_request(:put, endpoint + path)
|
32
|
+
end
|
33
|
+
|
34
|
+
def stub_delete(path, endpoint = Github.endpoint)
|
35
|
+
stub_request(:delete, endpoint + path)
|
36
|
+
end
|
37
|
+
|
38
|
+
def a_get(path, endpoint = Github.endpoint)
|
39
|
+
a_request(:get, endpoint + path)
|
40
|
+
end
|
41
|
+
|
42
|
+
def a_post(path, endpoint = Github.endpoint)
|
43
|
+
a_request(:post, endpoint + path)
|
44
|
+
end
|
45
|
+
|
46
|
+
def a_patch(path, endpoint = Github.endpoint)
|
47
|
+
a_request(:patch, endpoint + path)
|
48
|
+
end
|
49
|
+
|
50
|
+
def a_put(path, endpoint = Github.endpoint)
|
51
|
+
a_request(:put, endpoint + path)
|
52
|
+
end
|
53
|
+
|
54
|
+
def a_delete(path, endpoint = Github.endpoint)
|
55
|
+
a_request(:delete, endpoint + path)
|
56
|
+
end
|
57
|
+
|
58
|
+
def fixture_path
|
59
|
+
File.expand_path("../fixtures", __FILE__)
|
60
|
+
end
|
61
|
+
|
62
|
+
def fixture(file)
|
63
|
+
File.new(File.join(fixture_path, '/', file))
|
64
|
+
end
|
65
|
+
|
66
|
+
OAUTH_TOKEN = 'bafec72922f31fe86aacc8aca4261117f3bd62cf'
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
|
10
|
-
version: 0.1.0.pre
|
9
|
+
version: 0.1.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Piotr Murach
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2011-10-
|
17
|
+
date: 2011-10-16 00:00:00 +01:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -101,9 +100,23 @@ dependencies:
|
|
101
100
|
type: :development
|
102
101
|
version_requirements: *id006
|
103
102
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
103
|
+
name: yajl-ruby
|
105
104
|
prerelease: false
|
106
105
|
requirement: &id007 !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
segments:
|
110
|
+
- 0
|
111
|
+
- 8
|
112
|
+
- 2
|
113
|
+
version: 0.8.2
|
114
|
+
type: :development
|
115
|
+
version_requirements: *id007
|
116
|
+
- !ruby/object:Gem::Dependency
|
117
|
+
name: bundler
|
118
|
+
prerelease: false
|
119
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
107
120
|
requirements:
|
108
121
|
- - ~>
|
109
122
|
- !ruby/object:Gem::Version
|
@@ -113,11 +126,11 @@ dependencies:
|
|
113
126
|
- 0
|
114
127
|
version: 1.0.0
|
115
128
|
type: :development
|
116
|
-
version_requirements: *
|
129
|
+
version_requirements: *id008
|
117
130
|
- !ruby/object:Gem::Dependency
|
118
131
|
name: jeweler
|
119
132
|
prerelease: false
|
120
|
-
requirement: &
|
133
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
121
134
|
requirements:
|
122
135
|
- - ~>
|
123
136
|
- !ruby/object:Gem::Version
|
@@ -127,11 +140,11 @@ dependencies:
|
|
127
140
|
- 4
|
128
141
|
version: 1.6.4
|
129
142
|
type: :development
|
130
|
-
version_requirements: *
|
143
|
+
version_requirements: *id009
|
131
144
|
- !ruby/object:Gem::Dependency
|
132
145
|
name: webmock
|
133
146
|
prerelease: false
|
134
|
-
requirement: &
|
147
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
135
148
|
requirements:
|
136
149
|
- - ~>
|
137
150
|
- !ruby/object:Gem::Version
|
@@ -141,11 +154,11 @@ dependencies:
|
|
141
154
|
- 6
|
142
155
|
version: 1.7.6
|
143
156
|
type: :development
|
144
|
-
version_requirements: *
|
157
|
+
version_requirements: *id010
|
145
158
|
- !ruby/object:Gem::Dependency
|
146
159
|
name: simplecov
|
147
160
|
prerelease: false
|
148
|
-
requirement: &
|
161
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
149
162
|
requirements:
|
150
163
|
- - ~>
|
151
164
|
- !ruby/object:Gem::Version
|
@@ -154,7 +167,7 @@ dependencies:
|
|
154
167
|
- 4
|
155
168
|
version: "0.4"
|
156
169
|
type: :development
|
157
|
-
version_requirements: *
|
170
|
+
version_requirements: *id011
|
158
171
|
description: " Ruby wrapper that supports all of the GitHub 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. "
|
159
172
|
email: ""
|
160
173
|
executables: []
|
@@ -216,6 +229,10 @@ files:
|
|
216
229
|
- lib/github_api.rb
|
217
230
|
- spec/fixtures/collaborators_list.json
|
218
231
|
- spec/fixtures/commits_list.json
|
232
|
+
- spec/fixtures/repos/key.json
|
233
|
+
- spec/fixtures/repos/keys.json
|
234
|
+
- spec/fixtures/repos/watched.json
|
235
|
+
- spec/fixtures/repos/watchers.json
|
219
236
|
- spec/fixtures/repos_branches_list.json
|
220
237
|
- spec/fixtures/repos_list.json
|
221
238
|
- spec/github/api_spec.rb
|
@@ -266,13 +283,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
266
283
|
version: "0"
|
267
284
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
268
285
|
requirements:
|
269
|
-
- - "
|
286
|
+
- - ">="
|
270
287
|
- !ruby/object:Gem::Version
|
271
288
|
segments:
|
272
|
-
-
|
273
|
-
|
274
|
-
- 1
|
275
|
-
version: 1.3.1
|
289
|
+
- 0
|
290
|
+
version: "0"
|
276
291
|
requirements: []
|
277
292
|
|
278
293
|
rubyforge_project:
|