githubris 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Rakefile +11 -1
- data/features/get_a_gist.feature +13 -0
- data/features/step_definitions/general_steps.rb +13 -0
- data/features/support/fakeweb_responses.rb +2 -0
- data/features/support/fixtures.rb +12 -0
- data/lib/githubris/api/gist.rb +18 -11
- data/lib/githubris/api/user.rb +0 -2
- data/lib/githubris/builder.rb +20 -7
- data/lib/githubris/gist.rb +21 -16
- data/lib/githubris/user.rb +3 -3
- data/lib/githubris/version.rb +1 -1
- data/lib/githubris.rb +6 -2
- data/spec/githubris/api/gist_spec.rb +17 -11
- data/spec/githubris/gist_spec.rb +57 -45
- data/spec/githubris_spec.rb +33 -3
- data/spec/support/fakeweb_responses.rb +2 -0
- data/spec/support/gist.json +335 -0
- metadata +6 -8
- data/lib/githubris/builder/gist.rb +0 -16
- data/lib/githubris/builder/user.rb +0 -15
- data/spec/githubris/builder/gist_spec.rb +0 -38
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rspec/core/rake_task'
|
3
3
|
require 'cucumber/rake/task'
|
4
|
+
require 'flay_task'
|
5
|
+
require 'flog_task'
|
4
6
|
|
5
7
|
RSpec::Core::RakeTask.new :spec do |t|
|
6
8
|
t.rspec_opts = '--color --format=documentation'
|
@@ -16,5 +18,13 @@ Cucumber::Rake::Task.new :features do |t|
|
|
16
18
|
t.cucumber_opts = '--tags ~@wip --tags ~@backlog'
|
17
19
|
end
|
18
20
|
|
19
|
-
|
21
|
+
FLAY_FLOG_OPTS_BLOCK = lambda do |t|
|
22
|
+
t.dirs = ['lib']
|
23
|
+
t.verbose = true
|
24
|
+
end
|
25
|
+
|
26
|
+
FlayTask.new &FLAY_FLOG_OPTS_BLOCK
|
27
|
+
FlogTask.new &FLAY_FLOG_OPTS_BLOCK
|
28
|
+
|
29
|
+
task :all => [:spec, :features, :flay, :flog]
|
20
30
|
task :default => :spec
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: Get a Gist
|
2
|
+
In order to retrieve the newest gist data for a given gist
|
3
|
+
As a developer
|
4
|
+
I want to be able to get a gist.
|
5
|
+
|
6
|
+
Scenario: Get a gist via the Githubris API
|
7
|
+
When I access "@githubris.find_gist(1)"
|
8
|
+
Then I have the first gist
|
9
|
+
|
10
|
+
Scenario: Reload a gist's information
|
11
|
+
Given @gist is a stale copy of the first gist
|
12
|
+
When I access "@gist.reload"
|
13
|
+
Then I have the newest version of the gist
|
@@ -2,6 +2,10 @@ Given /^@user is GithubrisTestUser$/ do
|
|
2
2
|
@user = @githubris.find_user('GithubrisTestUser')
|
3
3
|
end
|
4
4
|
|
5
|
+
Given /^@gist is a stale copy of the first gist$/ do
|
6
|
+
@gist = Githubris::Gist.new :id => 1
|
7
|
+
end
|
8
|
+
|
5
9
|
When /^I access "([^"]*)"$/ do |api_code|
|
6
10
|
@actual = binding.eval api_code
|
7
11
|
end
|
@@ -17,3 +21,12 @@ end
|
|
17
21
|
Then /^I have that user$/ do
|
18
22
|
@actual.should == test_user
|
19
23
|
end
|
24
|
+
|
25
|
+
Then /^I have the first gist$/ do
|
26
|
+
@actual.should == test_gist
|
27
|
+
end
|
28
|
+
|
29
|
+
Then /^I have the newest version of the gist$/ do
|
30
|
+
@actual.should == test_gist
|
31
|
+
end
|
32
|
+
|
@@ -8,3 +8,5 @@ FakeWeb.register_uri(:get, /users\/([^\/]*)\/gists\z/,
|
|
8
8
|
:body => File.open("spec/support/user_public_gists.json"){|f| f.read })
|
9
9
|
FakeWeb.register_uri(:get, /users\/\w+\z/,
|
10
10
|
:body => File.open("spec/support/user.json"){|f| f.read })
|
11
|
+
FakeWeb.register_uri(:get, /gists\/\d+/,
|
12
|
+
:body => File.open('spec/support/gist.json'){|f| f.read })
|
@@ -11,10 +11,18 @@ module Fixtures
|
|
11
11
|
build_user get_user_data
|
12
12
|
end
|
13
13
|
|
14
|
+
def test_gist
|
15
|
+
build_gist get_gist_data
|
16
|
+
end
|
17
|
+
|
14
18
|
def build_gists data
|
15
19
|
Githubris::Builder.new.build_gists data
|
16
20
|
end
|
17
21
|
|
22
|
+
def build_gist data
|
23
|
+
Githubris::Builder.new.build_gist data
|
24
|
+
end
|
25
|
+
|
18
26
|
def build_user data
|
19
27
|
Githubris::Builder.new.build_user data
|
20
28
|
end
|
@@ -30,6 +38,10 @@ module Fixtures
|
|
30
38
|
def get_user_data
|
31
39
|
MultiJson.decode(File.open('spec/support/user.json') {|f| f.read })
|
32
40
|
end
|
41
|
+
|
42
|
+
def get_gist_data
|
43
|
+
MultiJson.decode(File.open('spec/support/gist.json') {|f| f.read })
|
44
|
+
end
|
33
45
|
end
|
34
46
|
|
35
47
|
World(Fixtures)
|
data/lib/githubris/api/gist.rb
CHANGED
@@ -1,26 +1,29 @@
|
|
1
|
-
require 'githubris/builder/gist'
|
2
|
-
|
3
1
|
module Githubris::API::Gist
|
4
2
|
PUBLIC_GISTS_PATH = '/gists/public'
|
5
3
|
|
6
4
|
def get_user_public_gists(login)
|
7
|
-
|
8
|
-
gists = @builder.build_gists(data)
|
9
|
-
gists.map do |gist|
|
10
|
-
gist.set_attribute(:user, get_user(login))
|
11
|
-
gist
|
12
|
-
end
|
5
|
+
get user_gists_path(login)
|
13
6
|
end
|
14
7
|
|
15
8
|
def get_public_gists(options={})
|
16
9
|
login = options.delete(:user)
|
17
10
|
return get_user_public_gists(login) if login
|
18
11
|
|
19
|
-
|
20
|
-
|
12
|
+
get public_gists_path_for_page(options[:page])
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_gist(id)
|
16
|
+
get gist_path(id)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get(path)
|
20
|
+
@builder.build_gists attributes_from(path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def attributes_from(path)
|
24
|
+
self.class.get(path)
|
21
25
|
end
|
22
26
|
|
23
|
-
private
|
24
27
|
def public_gists_path_for_page page_number=1
|
25
28
|
"#{PUBLIC_GISTS_PATH}?page=#{page_number}"
|
26
29
|
end
|
@@ -28,4 +31,8 @@ module Githubris::API::Gist
|
|
28
31
|
def user_gists_path(login)
|
29
32
|
"/users/#{login}/gists"
|
30
33
|
end
|
34
|
+
|
35
|
+
def gist_path(id)
|
36
|
+
"/gists/#{id}"
|
37
|
+
end
|
31
38
|
end
|
data/lib/githubris/api/user.rb
CHANGED
data/lib/githubris/builder.rb
CHANGED
@@ -1,15 +1,28 @@
|
|
1
1
|
class Githubris::Builder
|
2
|
-
autoload :Gist, 'githubris/builder/gist'
|
3
|
-
autoload :User, 'githubris/builder/user'
|
4
|
-
|
5
2
|
def build_gists(data)
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
if data.is_a? Array
|
4
|
+
data = [data].flatten
|
5
|
+
data.map do |gist|
|
6
|
+
build_gist gist
|
7
|
+
end
|
8
|
+
else
|
9
|
+
build_gist data
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
13
|
+
def build_gist(data)
|
14
|
+
Githubris::Gist.new build(data)
|
15
|
+
end
|
16
|
+
|
12
17
|
def build_user(data)
|
13
|
-
Githubris::
|
18
|
+
Githubris::User.new build(data)
|
19
|
+
end
|
20
|
+
|
21
|
+
def build(data)
|
22
|
+
attributes = {}
|
23
|
+
data.each_pair do |key, value|
|
24
|
+
attributes[key.to_sym] = value
|
25
|
+
end
|
26
|
+
attributes
|
14
27
|
end
|
15
28
|
end
|
data/lib/githubris/gist.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
1
3
|
class Githubris::Gist
|
2
4
|
autoload :File, 'githubris/gist/file'
|
3
5
|
|
4
6
|
def self.default_attributes
|
5
7
|
{
|
6
|
-
files
|
7
|
-
created_at
|
8
|
-
updated_at
|
8
|
+
:files => {},
|
9
|
+
:created_at => DateTime.now.to_s,
|
10
|
+
:updated_at => DateTime.now.to_s,
|
9
11
|
}
|
10
12
|
end
|
11
13
|
|
@@ -20,19 +22,23 @@ class Githubris::Gist
|
|
20
22
|
end
|
21
23
|
|
22
24
|
def id
|
23
|
-
@attributes[:id]
|
25
|
+
Integer(@attributes[:id])
|
24
26
|
end
|
25
27
|
|
26
28
|
def user
|
27
|
-
@attributes[:user]
|
29
|
+
unless @attributes[:user].instance_of? Githubris::User
|
30
|
+
@attributes[:user] = Githubris::Builder.new.build_user @attributes[:user]
|
31
|
+
else
|
32
|
+
@attributes[:user]
|
33
|
+
end
|
28
34
|
end
|
29
35
|
|
30
36
|
def created_at
|
31
|
-
@attributes[:created_at]
|
37
|
+
DateTime.parse @attributes[:created_at]
|
32
38
|
end
|
33
39
|
|
34
40
|
def updated_at
|
35
|
-
@attributes[:updated_at]
|
41
|
+
DateTime.parse @attributes[:updated_at]
|
36
42
|
end
|
37
43
|
|
38
44
|
def description
|
@@ -40,11 +46,11 @@ class Githubris::Gist
|
|
40
46
|
end
|
41
47
|
|
42
48
|
def files
|
43
|
-
@attributes[:files]
|
49
|
+
@attributes[:files].values
|
44
50
|
end
|
45
51
|
|
46
52
|
def url
|
47
|
-
@attributes[:url]
|
53
|
+
URI.parse @attributes[:url]
|
48
54
|
end
|
49
55
|
|
50
56
|
def public?
|
@@ -52,17 +58,16 @@ class Githubris::Gist
|
|
52
58
|
end
|
53
59
|
|
54
60
|
def comments
|
55
|
-
@attributes[:comments]
|
61
|
+
Array.new @attributes[:comments], Githubris::Comment.new
|
56
62
|
end
|
57
63
|
|
58
64
|
def ==(other)
|
59
|
-
|
60
|
-
self.created_at == other.created_at &&
|
61
|
-
self.files == other.files &&
|
62
|
-
self.user == other.user
|
65
|
+
@attributes == other.instance_variable_get(:@attributes)
|
63
66
|
end
|
64
67
|
|
65
|
-
def
|
66
|
-
|
68
|
+
def reload
|
69
|
+
other = Githubris::API.new.get_gist id
|
70
|
+
instance_variable_set(:@attributes, other.instance_variable_get(:@attributes))
|
71
|
+
self
|
67
72
|
end
|
68
73
|
end
|
data/lib/githubris/user.rb
CHANGED
@@ -12,15 +12,15 @@ class Githubris::User
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def id
|
15
|
-
@attributes[:id]
|
15
|
+
Integer(@attributes[:id])
|
16
16
|
end
|
17
17
|
|
18
18
|
def avatar_url
|
19
|
-
@attributes[:avatar_url]
|
19
|
+
URI.parse @attributes[:avatar_url]
|
20
20
|
end
|
21
21
|
|
22
22
|
def url
|
23
|
-
@attributes[:url]
|
23
|
+
URI.parse @attributes[:url]
|
24
24
|
end
|
25
25
|
|
26
26
|
def gravatar_id
|
data/lib/githubris/version.rb
CHANGED
data/lib/githubris.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
$:.push File.expand_path("../../config", __FILE__)
|
2
|
-
require_relative "githubris/version"
|
3
2
|
|
4
3
|
class Githubris
|
5
4
|
autoload :API, 'githubris/api'
|
@@ -17,6 +16,7 @@ class Githubris
|
|
17
16
|
autoload :Tag, 'githubris/tag'
|
18
17
|
autoload :Tree, 'githubris/tree'
|
19
18
|
autoload :User, 'githubris/user'
|
19
|
+
autoload :Version, 'githubris/version'
|
20
20
|
|
21
21
|
attr_reader :authenticated_user
|
22
22
|
|
@@ -25,7 +25,7 @@ class Githubris
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def authenticate(login, password)
|
28
|
-
@api.authenticate! login
|
28
|
+
@api.authenticate! :login => login, :password => password
|
29
29
|
@authenticated_user = Githubris::User.new
|
30
30
|
end
|
31
31
|
|
@@ -33,6 +33,10 @@ class Githubris
|
|
33
33
|
@api.get_user(login)
|
34
34
|
end
|
35
35
|
|
36
|
+
def find_gist(id)
|
37
|
+
@api.get_gist(id)
|
38
|
+
end
|
39
|
+
|
36
40
|
def public_gists(options={})
|
37
41
|
@api.get_public_gists options
|
38
42
|
end
|
@@ -14,15 +14,9 @@ describe Githubris::API::Gist do
|
|
14
14
|
subject.should have_received(:user_gists_path).with(login)
|
15
15
|
end
|
16
16
|
|
17
|
-
it 'retrieves the full user' do
|
18
|
-
subject.stub(:get_user)
|
19
|
-
subject.get_public_gists(user: login)
|
20
|
-
subject.should have_received(:get_user).with(login)
|
21
|
-
end
|
22
|
-
|
23
17
|
context 'given a user with 2 gists' do
|
24
18
|
it 'returns 2 gists by the given user' do
|
25
|
-
user_public_gists = subject.get_public_gists(user
|
19
|
+
user_public_gists = subject.get_public_gists(:user => login)
|
26
20
|
user_public_gists.should have(2).items
|
27
21
|
user_public_gists.each do |gist|
|
28
22
|
gist.should be_instance_of Githubris::Gist
|
@@ -42,14 +36,14 @@ describe Githubris::API::Gist do
|
|
42
36
|
|
43
37
|
it 'accepts an options hash' do
|
44
38
|
lambda do
|
45
|
-
subject.get_public_gists({foo
|
39
|
+
subject.get_public_gists({:foo => 'bar'})
|
46
40
|
end.should_not raise_error
|
47
41
|
end
|
48
42
|
|
49
43
|
context 'given a page option' do
|
50
44
|
it 'returns an array of 30 gists from that page' do
|
51
|
-
page_one_gists = subject.get_public_gists(page
|
52
|
-
page_two_gists = subject.get_public_gists(page
|
45
|
+
page_one_gists = subject.get_public_gists(:page => 1)
|
46
|
+
page_two_gists = subject.get_public_gists(:page => 2)
|
53
47
|
page_one_gists.should have(30).items
|
54
48
|
page_two_gists.should have(30).items
|
55
49
|
end
|
@@ -59,8 +53,20 @@ describe Githubris::API::Gist do
|
|
59
53
|
it 'delegates to #get_user_public_gists' do
|
60
54
|
login = 'GithubrisTestUser'
|
61
55
|
subject.should_receive(:get_user_public_gists).with(login)
|
62
|
-
subject.get_public_gists(user
|
56
|
+
subject.get_public_gists(:user => login)
|
63
57
|
end
|
64
58
|
end
|
65
59
|
end
|
60
|
+
|
61
|
+
describe '#get_gist' do
|
62
|
+
let(:id) { 1 }
|
63
|
+
it 'uses GET' do
|
64
|
+
subject.should_receive(:get).with(subject.gist_path(id))
|
65
|
+
subject.get_gist(id)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'is a Githubris::Gist' do
|
69
|
+
subject.get_gist(id).should be_instance_of Githubris::Gist
|
70
|
+
end
|
71
|
+
end
|
66
72
|
end
|
data/spec/githubris/gist_spec.rb
CHANGED
@@ -2,79 +2,91 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Githubris::Gist do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
context 'the other\'s class is Githubris::Gist' do
|
10
|
-
let(:other) { Githubris::Gist.new }
|
11
|
-
|
12
|
-
context 'the gists have the same creation times' do
|
13
|
-
before { Githubris::Gist.any_instance.stub(created_at: stub) }
|
14
|
-
|
15
|
-
context 'the files are the same' do
|
16
|
-
before { Githubris::Gist.any_instance.stub(files: stub) }
|
17
|
-
|
18
|
-
context 'the user is the same' do
|
19
|
-
before { Githubris::Gist.any_instance.stub(user: stub) }
|
20
|
-
|
21
|
-
it { should be_true }
|
22
|
-
|
23
|
-
end
|
5
|
+
context 'when passed a specific gist' do
|
6
|
+
subject { Githubris::Gist.new gist_attributes }
|
7
|
+
let(:gist_attributes) { Githubris::Builder.new.build gist_data }
|
8
|
+
let(:gist_data) { Githubris::SpecHelper.gist_data }
|
24
9
|
|
25
|
-
context 'the user isn\'t the same' do
|
26
|
-
let(:this) { Githubris::Gist.new(user: :the_right_user) }
|
27
|
-
let(:other) { Githubris::Gist.new(user: :not_the_right_user) }
|
28
10
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
it { should be_true }
|
33
|
-
end
|
11
|
+
it 'is public' do
|
12
|
+
subject.should be_public
|
13
|
+
end
|
34
14
|
|
35
|
-
|
36
|
-
let(:other) { Githubris::Gist.new(files: stub) }
|
15
|
+
its(:id) { should eql 1 }
|
37
16
|
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
17
|
+
its(:description) { should eql 'the meaning of gist' }
|
41
18
|
|
42
|
-
|
43
|
-
|
44
|
-
|
19
|
+
it 'was created at 6:17:13 on July 15, 2008' do
|
20
|
+
subject.created_at.should eql DateTime.new(2008, 7, 15, 18, 17, 13)
|
21
|
+
end
|
45
22
|
|
46
|
-
|
47
|
-
|
23
|
+
it 'was updated at 2:58:22 on Feburary 22, 2011' do
|
24
|
+
subject.updated_at.should eql DateTime.new(2011, 2, 22, 2, 58, 22)
|
48
25
|
end
|
49
26
|
|
50
|
-
|
51
|
-
|
27
|
+
its(:url) { should be_kind_of URI }
|
28
|
+
its(:id) { should be_instance_of Fixnum }
|
29
|
+
its(:description) { should be_instance_of String }
|
30
|
+
it { should be_public }
|
31
|
+
its(:created_at) { should be_instance_of DateTime }
|
32
|
+
its(:updated_at) { should be_instance_of DateTime }
|
33
|
+
its(:comments) { should be_instance_of Array }
|
34
|
+
its(:files) { should be_instance_of Array }
|
52
35
|
|
53
|
-
it { should be_false }
|
54
|
-
end
|
55
36
|
end
|
56
37
|
|
57
38
|
it 'new gists are created now' do
|
58
|
-
DateTime.stub(now
|
39
|
+
DateTime.stub(:now => DateTime.new(2012))
|
59
40
|
subject.created_at.should eql DateTime.now
|
60
41
|
end
|
61
42
|
|
62
43
|
context 'Gist owned by Isaac' do
|
63
|
-
subject { Githubris::Gist.new user
|
44
|
+
subject { Githubris::Gist.new :user => user }
|
64
45
|
let(:user) { Githubris::User.new }
|
65
46
|
its(:user) { should eql user }
|
66
47
|
end
|
67
48
|
|
68
|
-
|
69
49
|
describe 'a gist without files' do
|
50
|
+
subject { Githubris::Gist.new }
|
70
51
|
its(:files) { should be_empty }
|
71
52
|
end
|
72
53
|
|
73
54
|
describe 'a gist created with a file' do
|
74
55
|
subject do
|
75
|
-
Githubris::Gist.new(files:
|
56
|
+
Githubris::Gist.new(:files => {:stub => stub})
|
76
57
|
end
|
77
58
|
|
78
59
|
its(:files) { should have(1).items }
|
79
60
|
end
|
61
|
+
|
62
|
+
describe '#==' do
|
63
|
+
it 'checks the attributes of each object' do
|
64
|
+
subject.should == Githubris::Gist.new
|
65
|
+
subject.should_not == stub
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#reload' do
|
70
|
+
|
71
|
+
it 'errors without an id' do
|
72
|
+
lambda do
|
73
|
+
subject.reload
|
74
|
+
end.should raise_error
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'on a gist with an id' do
|
78
|
+
subject { Githubris::Gist.new :id => id }
|
79
|
+
let(:id) { 1 }
|
80
|
+
|
81
|
+
it 'hits the API' do
|
82
|
+
Githubris::API.any_instance.should_receive(:get_gist).with(id)
|
83
|
+
subject.reload
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'returns the same object' do
|
87
|
+
obj_id = subject.object_id
|
88
|
+
subject.reload.object_id.should == obj_id
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
80
92
|
end
|
data/spec/githubris_spec.rb
CHANGED
@@ -18,7 +18,7 @@ describe Githubris do
|
|
18
18
|
|
19
19
|
describe '#find_user' do
|
20
20
|
it 'requests gets user from githubris api' do
|
21
|
-
user = Githubris::User.new(login
|
21
|
+
user = Githubris::User.new(:login => "frank")
|
22
22
|
Githubris::API.any_instance.stub(:get_user).and_return(user)
|
23
23
|
subject.find_user("frank").should == user
|
24
24
|
end
|
@@ -36,13 +36,43 @@ describe Githubris do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'can take an options hash' do
|
39
|
-
lambda { subject.public_gists(foo
|
39
|
+
lambda { subject.public_gists(:foo => 'bar') }.should_not raise_error
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'delegates and passes the options hash to the API' do
|
43
43
|
Githubris::API.any_instance.stub(:get_public_gists)
|
44
|
-
subject.public_gists({foo
|
44
|
+
subject.public_gists({:foo => 'bar'})
|
45
45
|
subject.instance_variable_get(:@api).should have_received(:get_public_gists).with({foo: 'bar'})
|
46
46
|
end
|
47
47
|
end
|
48
|
+
|
49
|
+
describe '#find_gist' do
|
50
|
+
let(:id) { 1 }
|
51
|
+
|
52
|
+
it 'takes a gist\'s id' do
|
53
|
+
lambda do
|
54
|
+
subject.find_gist(id)
|
55
|
+
end.should_not raise_error
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'hits the API' do
|
59
|
+
Githubris::API.any_instance.should_receive(:get_gist).with(id)
|
60
|
+
subject.find_gist(id)
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'the gist it returns' do
|
64
|
+
subject { Githubris.new.find_gist(id) }
|
65
|
+
|
66
|
+
it 'has the same id that was passed in' do
|
67
|
+
subject.should be_instance_of Githubris::Gist
|
68
|
+
subject.id.should == id
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'has a user' do
|
72
|
+
lambda do
|
73
|
+
subject.user.should be_instance_of Githubris::User
|
74
|
+
end.should_not raise_error
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
48
78
|
end
|
@@ -8,3 +8,5 @@ FakeWeb.register_uri(:get, /users\/([^\/]*)\/gists\z/,
|
|
8
8
|
:body => File.open("spec/support/user_public_gists.json"){|f| f.read })
|
9
9
|
FakeWeb.register_uri(:get, /users\/\w+\z/,
|
10
10
|
:body => File.open("spec/support/user.json"){|f| f.read })
|
11
|
+
FakeWeb.register_uri(:get, /gists\/\d+/,
|
12
|
+
:body => File.open('spec/support/gist.json'){|f| f.read })
|
@@ -0,0 +1,335 @@
|
|
1
|
+
{
|
2
|
+
"url": "https://api.github.com/gists/1",
|
3
|
+
"files": {
|
4
|
+
"gistfile1.txt": {
|
5
|
+
"content": "This is gist. \nThere are many like it, but this one is mine. \nIt is my life. \nI must master it as I must master my life. \nWithout me gist is useless. \nWithout gist, I am useless.",
|
6
|
+
"type": "text/plain",
|
7
|
+
"language": "Text",
|
8
|
+
"size": 178,
|
9
|
+
"filename": "gistfile1.txt",
|
10
|
+
"raw_url": "https://gist.github.com/raw/1/9b2ac7c792209f19e157ddaf00f8946edc306a6b/gistfile1.txt"
|
11
|
+
}
|
12
|
+
},
|
13
|
+
"history": [
|
14
|
+
{
|
15
|
+
"url": "https://api.github.com/gists/1/3a641566d0a49014cea6f395e8be68c42b9e46d9",
|
16
|
+
"change_status": {
|
17
|
+
"deletions": 1,
|
18
|
+
"additions": 6,
|
19
|
+
"total": 7
|
20
|
+
},
|
21
|
+
"committed_at": "2011-02-22T02:58:22Z",
|
22
|
+
"user": {
|
23
|
+
"url": "https://api.github.com/users/schacon",
|
24
|
+
"gravatar_id": "9375a9529679f1b42b567a640d775e7d",
|
25
|
+
"login": "schacon",
|
26
|
+
"avatar_url": "https://secure.gravatar.com/avatar/9375a9529679f1b42b567a640d775e7d?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
27
|
+
"id": 70
|
28
|
+
},
|
29
|
+
"version": "3a641566d0a49014cea6f395e8be68c42b9e46d9"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"url": "https://api.github.com/gists/1/24c894e1ca5cefd36b3b6e914beb93a7068f6efb",
|
33
|
+
"change_status": {
|
34
|
+
"deletions": 6,
|
35
|
+
"additions": 1,
|
36
|
+
"total": 7
|
37
|
+
},
|
38
|
+
"committed_at": "2011-02-22T02:53:32Z",
|
39
|
+
"user": {
|
40
|
+
"url": "https://api.github.com/users/schacon",
|
41
|
+
"gravatar_id": "9375a9529679f1b42b567a640d775e7d",
|
42
|
+
"login": "schacon",
|
43
|
+
"avatar_url": "https://secure.gravatar.com/avatar/9375a9529679f1b42b567a640d775e7d?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
44
|
+
"id": 70
|
45
|
+
},
|
46
|
+
"version": "24c894e1ca5cefd36b3b6e914beb93a7068f6efb"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"url": "https://api.github.com/gists/1/0864db9cbe551088b2269128c5b5d145141f57ef",
|
50
|
+
"change_status": {
|
51
|
+
"deletions": 1,
|
52
|
+
"additions": 6,
|
53
|
+
"total": 7
|
54
|
+
},
|
55
|
+
"committed_at": "2008-07-15T18:17:27Z",
|
56
|
+
"user": {
|
57
|
+
"url": "https://api.github.com/users/schacon",
|
58
|
+
"gravatar_id": "9375a9529679f1b42b567a640d775e7d",
|
59
|
+
"login": "schacon",
|
60
|
+
"avatar_url": "https://secure.gravatar.com/avatar/9375a9529679f1b42b567a640d775e7d?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
61
|
+
"id": 70
|
62
|
+
},
|
63
|
+
"version": "0864db9cbe551088b2269128c5b5d145141f57ef"
|
64
|
+
},
|
65
|
+
{
|
66
|
+
"url": "https://api.github.com/gists/1/8afc134bf14f8f56ed2e7234128490d9946e8c16",
|
67
|
+
"change_status": {
|
68
|
+
"deletions": 0,
|
69
|
+
"additions": 1,
|
70
|
+
"total": 1
|
71
|
+
},
|
72
|
+
"committed_at": "2008-07-15T18:17:14Z",
|
73
|
+
"user": {
|
74
|
+
"url": "https://api.github.com/users/schacon",
|
75
|
+
"gravatar_id": "9375a9529679f1b42b567a640d775e7d",
|
76
|
+
"login": "schacon",
|
77
|
+
"avatar_url": "https://secure.gravatar.com/avatar/9375a9529679f1b42b567a640d775e7d?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
78
|
+
"id": 70
|
79
|
+
},
|
80
|
+
"version": "8afc134bf14f8f56ed2e7234128490d9946e8c16"
|
81
|
+
}
|
82
|
+
],
|
83
|
+
"public": true,
|
84
|
+
"comments": 6,
|
85
|
+
"updated_at": "2011-02-22T02:58:22Z",
|
86
|
+
"user": {
|
87
|
+
"url": "https://api.github.com/users/schacon",
|
88
|
+
"gravatar_id": "9375a9529679f1b42b567a640d775e7d",
|
89
|
+
"login": "schacon",
|
90
|
+
"avatar_url": "https://secure.gravatar.com/avatar/9375a9529679f1b42b567a640d775e7d?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
91
|
+
"id": 70
|
92
|
+
},
|
93
|
+
"forks": [
|
94
|
+
{
|
95
|
+
"url": "https://api.github.com/gists/95",
|
96
|
+
"updated_at": "2009-10-14T10:23:33Z",
|
97
|
+
"user": {
|
98
|
+
"url": "https://api.github.com/users/danielmorrison",
|
99
|
+
"gravatar_id": "16ae5c2e160af3bdb60db447c092985d",
|
100
|
+
"login": "danielmorrison",
|
101
|
+
"avatar_url": "https://secure.gravatar.com/avatar/16ae5c2e160af3bdb60db447c092985d?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
102
|
+
"id": 125
|
103
|
+
},
|
104
|
+
"created_at": "2008-07-21T20:15:46Z",
|
105
|
+
"id": "95"
|
106
|
+
},
|
107
|
+
{
|
108
|
+
"url": "https://api.github.com/gists/140",
|
109
|
+
"updated_at": "2009-10-14T10:23:41Z",
|
110
|
+
"user": {
|
111
|
+
"url": "https://api.github.com/users/elliottcable",
|
112
|
+
"gravatar_id": "4eac78fe7a7a607dcc097a0d6fd63690",
|
113
|
+
"login": "elliottcable",
|
114
|
+
"avatar_url": "https://secure.gravatar.com/avatar/4eac78fe7a7a607dcc097a0d6fd63690?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
115
|
+
"id": 200
|
116
|
+
},
|
117
|
+
"created_at": "2008-07-21T20:34:51Z",
|
118
|
+
"id": "140"
|
119
|
+
},
|
120
|
+
{
|
121
|
+
"url": "https://api.github.com/gists/248",
|
122
|
+
"updated_at": "2009-10-14T10:24:01Z",
|
123
|
+
"user": {
|
124
|
+
"url": "https://api.github.com/users/mattetti",
|
125
|
+
"gravatar_id": "c69521d6e22fc0bbd69337ec8b1698df",
|
126
|
+
"login": "mattetti",
|
127
|
+
"avatar_url": "https://secure.gravatar.com/avatar/c69521d6e22fc0bbd69337ec8b1698df?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
128
|
+
"id": 113
|
129
|
+
},
|
130
|
+
"created_at": "2008-07-21T21:13:11Z",
|
131
|
+
"id": "248"
|
132
|
+
},
|
133
|
+
{
|
134
|
+
"url": "https://api.github.com/gists/582",
|
135
|
+
"updated_at": "2009-10-14T10:25:16Z",
|
136
|
+
"user": {
|
137
|
+
"url": "https://api.github.com/users/davidwparker",
|
138
|
+
"gravatar_id": "b7964c02372a1218c65f4a679f9d78d5",
|
139
|
+
"login": "davidwparker",
|
140
|
+
"avatar_url": "https://secure.gravatar.com/avatar/b7964c02372a1218c65f4a679f9d78d5?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
141
|
+
"id": 2379
|
142
|
+
},
|
143
|
+
"created_at": "2008-07-22T01:36:18Z",
|
144
|
+
"id": "582"
|
145
|
+
},
|
146
|
+
{
|
147
|
+
"url": "https://api.github.com/gists/591",
|
148
|
+
"updated_at": "2009-10-14T10:25:18Z",
|
149
|
+
"user": {
|
150
|
+
"url": "https://api.github.com/users/willcodeforfoo",
|
151
|
+
"gravatar_id": "6a2f7f7a997fab1dbf815d155cca50ee",
|
152
|
+
"login": "willcodeforfoo",
|
153
|
+
"avatar_url": "https://secure.gravatar.com/avatar/6a2f7f7a997fab1dbf815d155cca50ee?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
154
|
+
"id": 100
|
155
|
+
},
|
156
|
+
"created_at": "2008-07-22T01:51:28Z",
|
157
|
+
"id": "591"
|
158
|
+
},
|
159
|
+
{
|
160
|
+
"url": "https://api.github.com/gists/2398",
|
161
|
+
"updated_at": "2009-10-14T10:31:26Z",
|
162
|
+
"user": {
|
163
|
+
"url": "https://api.github.com/users/mattagar",
|
164
|
+
"gravatar_id": "c77e15da48833a5205255d0051460464",
|
165
|
+
"login": "mattagar",
|
166
|
+
"avatar_url": "https://secure.gravatar.com/avatar/c77e15da48833a5205255d0051460464?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
167
|
+
"id": 18075
|
168
|
+
},
|
169
|
+
"created_at": "2008-07-25T06:24:15Z",
|
170
|
+
"id": "2398"
|
171
|
+
},
|
172
|
+
{
|
173
|
+
"url": "https://api.github.com/gists/11539",
|
174
|
+
"updated_at": "2009-10-14T11:50:19Z",
|
175
|
+
"user": {
|
176
|
+
"url": "https://api.github.com/users/sunfmin",
|
177
|
+
"gravatar_id": "d4a7c04ca87944e7fb06518fb64f9c36",
|
178
|
+
"login": "sunfmin",
|
179
|
+
"avatar_url": "https://secure.gravatar.com/avatar/d4a7c04ca87944e7fb06518fb64f9c36?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
180
|
+
"id": 1014
|
181
|
+
},
|
182
|
+
"created_at": "2008-09-19T04:44:37Z",
|
183
|
+
"id": "11539"
|
184
|
+
},
|
185
|
+
{
|
186
|
+
"url": "https://api.github.com/gists/93488",
|
187
|
+
"updated_at": "2009-10-16T21:03:06Z",
|
188
|
+
"user": {
|
189
|
+
"url": "https://api.github.com/users/demonbane",
|
190
|
+
"gravatar_id": "881bd08b6b94e600475ce431e8e6ea35",
|
191
|
+
"login": "demonbane",
|
192
|
+
"avatar_url": "https://secure.gravatar.com/avatar/881bd08b6b94e600475ce431e8e6ea35?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
193
|
+
"id": 7385
|
194
|
+
},
|
195
|
+
"created_at": "2009-04-11T07:17:37Z",
|
196
|
+
"id": "93488"
|
197
|
+
},
|
198
|
+
{
|
199
|
+
"url": "https://api.github.com/gists/256016",
|
200
|
+
"updated_at": "2009-12-14T12:58:33Z",
|
201
|
+
"user": {
|
202
|
+
"url": "https://api.github.com/users/pedrodelgallego",
|
203
|
+
"gravatar_id": "f09383a4b8725aa99cf892813608de76",
|
204
|
+
"login": "pedrodelgallego",
|
205
|
+
"avatar_url": "https://secure.gravatar.com/avatar/f09383a4b8725aa99cf892813608de76?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
206
|
+
"id": 6951
|
207
|
+
},
|
208
|
+
"created_at": "2009-12-14T12:39:44Z",
|
209
|
+
"id": "256016"
|
210
|
+
},
|
211
|
+
{
|
212
|
+
"url": "https://api.github.com/gists/369414",
|
213
|
+
"updated_at": "2010-04-17T08:52:11Z",
|
214
|
+
"user": {
|
215
|
+
"url": "https://api.github.com/users/pedrodelgallego",
|
216
|
+
"gravatar_id": "f09383a4b8725aa99cf892813608de76",
|
217
|
+
"login": "pedrodelgallego",
|
218
|
+
"avatar_url": "https://secure.gravatar.com/avatar/f09383a4b8725aa99cf892813608de76?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
219
|
+
"id": 6951
|
220
|
+
},
|
221
|
+
"created_at": "2010-04-17T08:51:34Z",
|
222
|
+
"id": "369414"
|
223
|
+
},
|
224
|
+
{
|
225
|
+
"url": "https://api.github.com/gists/838269",
|
226
|
+
"updated_at": "2011-02-22T05:33:17Z",
|
227
|
+
"user": {
|
228
|
+
"url": "https://api.github.com/users/hz",
|
229
|
+
"gravatar_id": "a5556e47f603afb7695d05d2cd9883da",
|
230
|
+
"login": "hz",
|
231
|
+
"avatar_url": "https://secure.gravatar.com/avatar/a5556e47f603afb7695d05d2cd9883da?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
232
|
+
"id": 63441
|
233
|
+
},
|
234
|
+
"created_at": "2011-02-22T05:32:03Z",
|
235
|
+
"id": "838269"
|
236
|
+
},
|
237
|
+
{
|
238
|
+
"url": "https://api.github.com/gists/838371",
|
239
|
+
"updated_at": "2011-02-22T08:31:24Z",
|
240
|
+
"user": {
|
241
|
+
"url": "https://api.github.com/users/BlackBulletIV",
|
242
|
+
"gravatar_id": "5ccd0ef26cb0bd488c7e496f080f8dc5",
|
243
|
+
"login": "BlackBulletIV",
|
244
|
+
"avatar_url": "https://secure.gravatar.com/avatar/5ccd0ef26cb0bd488c7e496f080f8dc5?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
245
|
+
"id": 446397
|
246
|
+
},
|
247
|
+
"created_at": "2011-02-22T08:27:53Z",
|
248
|
+
"id": "838371"
|
249
|
+
},
|
250
|
+
{
|
251
|
+
"url": "https://api.github.com/gists/854804",
|
252
|
+
"updated_at": "2011-03-04T15:37:14Z",
|
253
|
+
"user": {
|
254
|
+
"url": "https://api.github.com/users/mtsoerin",
|
255
|
+
"gravatar_id": "50be7ccda1a6f9f895a2cdf4615eed6e",
|
256
|
+
"login": "mtsoerin",
|
257
|
+
"avatar_url": "https://secure.gravatar.com/avatar/50be7ccda1a6f9f895a2cdf4615eed6e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
258
|
+
"id": 643236
|
259
|
+
},
|
260
|
+
"created_at": "2011-03-04T15:36:59Z",
|
261
|
+
"id": "854804"
|
262
|
+
},
|
263
|
+
{
|
264
|
+
"url": "https://api.github.com/gists/942242",
|
265
|
+
"updated_at": "2011-04-26T13:19:30Z",
|
266
|
+
"user": {
|
267
|
+
"url": "https://api.github.com/users/gbraad",
|
268
|
+
"gravatar_id": "e466994eea3c2a1672564e45aca844d0",
|
269
|
+
"login": "gbraad",
|
270
|
+
"avatar_url": "https://secure.gravatar.com/avatar/e466994eea3c2a1672564e45aca844d0?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
271
|
+
"id": 1894
|
272
|
+
},
|
273
|
+
"created_at": "2011-04-26T13:19:11Z",
|
274
|
+
"id": "942242"
|
275
|
+
},
|
276
|
+
{
|
277
|
+
"url": "https://api.github.com/gists/959681",
|
278
|
+
"updated_at": "2011-05-06T20:05:34Z",
|
279
|
+
"user": {
|
280
|
+
"url": "https://api.github.com/users/bry4n",
|
281
|
+
"gravatar_id": "bb108e4ccd3d3d79350b167b62e2db2a",
|
282
|
+
"login": "bry4n",
|
283
|
+
"avatar_url": "https://secure.gravatar.com/avatar/bb108e4ccd3d3d79350b167b62e2db2a?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
284
|
+
"id": 73400
|
285
|
+
},
|
286
|
+
"created_at": "2011-05-06T20:04:46Z",
|
287
|
+
"id": "959681"
|
288
|
+
},
|
289
|
+
{
|
290
|
+
"url": "https://api.github.com/gists/1020085",
|
291
|
+
"updated_at": "2011-06-11T00:34:11Z",
|
292
|
+
"user": {
|
293
|
+
"url": "https://api.github.com/users/hijolan",
|
294
|
+
"gravatar_id": "b5d1886ee10bb84b1d1db698a1ca922e",
|
295
|
+
"login": "hijolan",
|
296
|
+
"avatar_url": "https://secure.gravatar.com/avatar/b5d1886ee10bb84b1d1db698a1ca922e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
297
|
+
"id": 404480
|
298
|
+
},
|
299
|
+
"created_at": "2011-06-11T00:29:06Z",
|
300
|
+
"id": "1020085"
|
301
|
+
},
|
302
|
+
{
|
303
|
+
"url": "https://api.github.com/gists/1086800",
|
304
|
+
"updated_at": "2011-07-16T21:14:13Z",
|
305
|
+
"user": {
|
306
|
+
"url": "https://api.github.com/users/ryanwcohen",
|
307
|
+
"gravatar_id": "71a33a634d5397ef8be84890365687d0",
|
308
|
+
"login": "ryanwcohen",
|
309
|
+
"avatar_url": "https://secure.gravatar.com/avatar/71a33a634d5397ef8be84890365687d0?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
310
|
+
"id": 730418
|
311
|
+
},
|
312
|
+
"created_at": "2011-07-16T21:14:13Z",
|
313
|
+
"id": "1086800"
|
314
|
+
},
|
315
|
+
{
|
316
|
+
"url": "https://api.github.com/gists/1509670",
|
317
|
+
"updated_at": "2011-12-22T09:29:22Z",
|
318
|
+
"user": {
|
319
|
+
"url": "https://api.github.com/users/dirkmc",
|
320
|
+
"gravatar_id": "364d08b8747ad5e230f49b65bb07805c",
|
321
|
+
"login": "dirkmc",
|
322
|
+
"avatar_url": "https://secure.gravatar.com/avatar/364d08b8747ad5e230f49b65bb07805c?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
323
|
+
"id": 169124
|
324
|
+
},
|
325
|
+
"created_at": "2011-12-22T09:29:22Z",
|
326
|
+
"id": "1509670"
|
327
|
+
}
|
328
|
+
],
|
329
|
+
"html_url": "https://gist.github.com/1",
|
330
|
+
"created_at": "2008-07-15T18:17:13Z",
|
331
|
+
"git_pull_url": "git://gist.github.com/1.git",
|
332
|
+
"id": "1",
|
333
|
+
"description": "the meaning of gist",
|
334
|
+
"git_push_url": "git@gist.github.com:1.git"
|
335
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: githubris
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &19299620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 0.8.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *19299620
|
25
25
|
description: Githubris is meant to make Github API interaction a breeze.
|
26
26
|
email:
|
27
27
|
- isaac@isaacbfsanders.com
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- Gemfile
|
36
36
|
- README.md
|
37
37
|
- Rakefile
|
38
|
+
- features/get_a_gist.feature
|
38
39
|
- features/get_a_user.feature
|
39
40
|
- features/list_of_public_gists.feature
|
40
41
|
- features/list_of_users_public_gists.feature
|
@@ -48,8 +49,6 @@ files:
|
|
48
49
|
- lib/githubris/api/gist.rb
|
49
50
|
- lib/githubris/api/user.rb
|
50
51
|
- lib/githubris/builder.rb
|
51
|
-
- lib/githubris/builder/gist.rb
|
52
|
-
- lib/githubris/builder/user.rb
|
53
52
|
- lib/githubris/comment.rb
|
54
53
|
- lib/githubris/gist.rb
|
55
54
|
- lib/githubris/gist/file.rb
|
@@ -61,7 +60,6 @@ files:
|
|
61
60
|
- spec/githubris/api/gist_spec.rb
|
62
61
|
- spec/githubris/api/user_spec.rb
|
63
62
|
- spec/githubris/api_spec.rb
|
64
|
-
- spec/githubris/builder/gist_spec.rb
|
65
63
|
- spec/githubris/builder_spec.rb
|
66
64
|
- spec/githubris/gist_spec.rb
|
67
65
|
- spec/githubris/user_spec.rb
|
@@ -70,6 +68,7 @@ files:
|
|
70
68
|
- spec/support/custom_matchers.rb
|
71
69
|
- spec/support/fakeweb_responses.rb
|
72
70
|
- spec/support/fixtures.rb
|
71
|
+
- spec/support/gist.json
|
73
72
|
- spec/support/public_gists_page_1.json
|
74
73
|
- spec/support/public_gists_page_2.json
|
75
74
|
- spec/support/user.json
|
@@ -99,4 +98,3 @@ signing_key:
|
|
99
98
|
specification_version: 3
|
100
99
|
summary: Githubris is meant to make Github API interaction a breeze.
|
101
100
|
test_files: []
|
102
|
-
has_rdoc:
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class Githubris::Builder::Gist
|
2
|
-
def build data
|
3
|
-
gist_data = {}
|
4
|
-
gist_data[:id] = Integer(data.delete('id'))
|
5
|
-
gist_data[:public] = data.delete('public')
|
6
|
-
gist_data[:description] = data.delete('description')
|
7
|
-
gist_data[:files] = data.delete('files').values
|
8
|
-
gist_data[:url] = URI.parse data.delete('url')
|
9
|
-
gist_data[:created_at] = DateTime.parse data.delete('created_at')
|
10
|
-
gist_data[:updated_at] = DateTime.parse data.delete('updated_at')
|
11
|
-
tmp_arr = []
|
12
|
-
data.delete('comments').times { tmp_arr << Githubris::Comment.new }
|
13
|
-
gist_data[:comments] = tmp_arr
|
14
|
-
Githubris::Gist.new gist_data
|
15
|
-
end
|
16
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'githubris/builder'
|
2
|
-
require 'githubris/user'
|
3
|
-
|
4
|
-
class Githubris::Builder::User
|
5
|
-
def build data
|
6
|
-
user_attributes = {
|
7
|
-
:login => data.delete('login'),
|
8
|
-
:id => Integer(data.delete('id')),
|
9
|
-
:avatar_url => URI.parse(data.delete('avatar_url')),
|
10
|
-
:url => URI.parse(data.delete('url')),
|
11
|
-
:gravatar_id => data.delete('gravatar_id')
|
12
|
-
}
|
13
|
-
Githubris::User.new user_attributes
|
14
|
-
end
|
15
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Githubris::Builder::Gist do
|
4
|
-
subject { Githubris::Builder::Gist.new.build gist_data }
|
5
|
-
let(:gist_data) { Githubris::SpecHelper.gist_data }
|
6
|
-
|
7
|
-
context 'schema' do
|
8
|
-
|
9
|
-
it { should be_instance_of Githubris::Gist }
|
10
|
-
its(:url) { should be_kind_of URI }
|
11
|
-
its(:id) { should be_instance_of Fixnum }
|
12
|
-
its(:description) { should be_instance_of String }
|
13
|
-
it { should be_public }
|
14
|
-
its(:created_at) { should be_instance_of DateTime }
|
15
|
-
its(:updated_at) { should be_instance_of DateTime }
|
16
|
-
its(:comments) { should be_instance_of Array }
|
17
|
-
its(:files) { should be_instance_of Array }
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'when passed a specific gist' do
|
21
|
-
|
22
|
-
it 'is public' do
|
23
|
-
subject.should be_public
|
24
|
-
end
|
25
|
-
|
26
|
-
its(:id) { should eql 1 }
|
27
|
-
|
28
|
-
its(:description) { should eql 'the meaning of gist' }
|
29
|
-
|
30
|
-
it 'was created at 6:17:13 on July 15, 2008' do
|
31
|
-
subject.created_at.should eql DateTime.new(2008, 7, 15, 18, 17, 13)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'was updated at 2:58:22 on Feburary 22, 2011' do
|
35
|
-
subject.updated_at.should eql DateTime.new(2011, 2, 22, 2, 58, 22)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|