hubruby 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/Manifest.txt +20 -0
- data/README.rdoc +6 -0
- data/Rakefile +1 -1
- data/hubruby.gemspec +39 -0
- data/lib/github/finders.rb +9 -9
- data/lib/github/models/repository.rb +5 -5
- data/lib/github/models/user.rb +5 -5
- data/lib/hubruby.rb +1 -1
- data/spec/github/github_spec.rb +35 -0
- data/spec/github/models/repository_spec.rb +24 -0
- data/spec/github/models/user_spec.rb +39 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/tasks/rspec.rake +21 -0
- metadata +17 -7
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.rdoc
|
4
|
+
Rakefile
|
5
|
+
TODO
|
6
|
+
hubruby.gemspec
|
7
|
+
lib/github/base.rb
|
8
|
+
lib/github/finders.rb
|
9
|
+
lib/github/models/repository.rb
|
10
|
+
lib/github/models/user.rb
|
11
|
+
lib/hubruby.rb
|
12
|
+
script/console
|
13
|
+
script/destroy
|
14
|
+
script/generate
|
15
|
+
spec/github/github_spec.rb
|
16
|
+
spec/github/models/repository_spec.rb
|
17
|
+
spec/github/models/user_spec.rb
|
18
|
+
spec/spec.opts
|
19
|
+
spec/spec_helper.rb
|
20
|
+
tasks/rspec.rake
|
data/README.rdoc
CHANGED
@@ -11,6 +11,12 @@ A simple Ruby library for accessing the current GitHub API (v2).
|
|
11
11
|
user = GitHub.user('diogenes')
|
12
12
|
user.repositories
|
13
13
|
user.following
|
14
|
+
user.followers
|
15
|
+
user.watched
|
16
|
+
|
17
|
+
repository = GitHub.repository('aslakhellesoy', 'cucumber')
|
18
|
+
repository.branches
|
19
|
+
repository.network
|
14
20
|
|
15
21
|
== REQUIREMENTS:
|
16
22
|
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ $hoe = Hoe.spec 'hubruby' do
|
|
14
14
|
self.developer 'Diógenes Falcão', 'diogenes {d-o-t} araujo {at} gmail.com'
|
15
15
|
self.rubyforge_name = self.name
|
16
16
|
self.extra_deps = [['httparty','= 0.6.1']]
|
17
|
-
self.version = '0.0.
|
17
|
+
self.version = '0.0.4'
|
18
18
|
end
|
19
19
|
|
20
20
|
require 'newgem/tasks'
|
data/hubruby.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{hubruby}
|
5
|
+
s.version = "0.0.4"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Di\303\263genes Falc\303\243o"]
|
9
|
+
s.date = %q{2010-09-03}
|
10
|
+
s.description = %q{A simple Ruby library for accessing the current GitHub API (v2).}
|
11
|
+
s.email = ["diogenes {d-o-t} araujo {at} gmail.com"]
|
12
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
|
13
|
+
s.files = ["History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "TODO", "hubruby.gemspec", "lib/github/base.rb", "lib/github/finders.rb", "lib/github/models/repository.rb", "lib/github/models/user.rb", "lib/hubruby.rb", "script/console", "script/destroy", "script/generate", "spec/github/github_spec.rb", "spec/github/models/repository_spec.rb", "spec/github/models/user_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake"]
|
14
|
+
s.homepage = %q{http://github.com/diogenes/hubruby}
|
15
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{hubruby}
|
18
|
+
s.rubygems_version = %q{1.3.6}
|
19
|
+
s.summary = %q{A simple Ruby library for accessing the current GitHub API (v2).}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
+
s.add_runtime_dependency(%q<httparty>, ["= 0.6.1"])
|
27
|
+
s.add_development_dependency(%q<rubyforge>, [">= 2.0.4"])
|
28
|
+
s.add_development_dependency(%q<hoe>, [">= 2.6.1"])
|
29
|
+
else
|
30
|
+
s.add_dependency(%q<httparty>, ["= 0.6.1"])
|
31
|
+
s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
|
32
|
+
s.add_dependency(%q<hoe>, [">= 2.6.1"])
|
33
|
+
end
|
34
|
+
else
|
35
|
+
s.add_dependency(%q<httparty>, ["= 0.6.1"])
|
36
|
+
s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
|
37
|
+
s.add_dependency(%q<hoe>, [">= 2.6.1"])
|
38
|
+
end
|
39
|
+
end
|
data/lib/github/finders.rb
CHANGED
@@ -2,32 +2,32 @@ module GitHub
|
|
2
2
|
module Finders
|
3
3
|
def user(login)
|
4
4
|
j = json("/user/show/#{login}", :user)
|
5
|
-
User.
|
5
|
+
User.from_hash(j)
|
6
6
|
end
|
7
7
|
|
8
8
|
def following(login)
|
9
|
-
|
10
|
-
User.
|
9
|
+
l = json("/user/show/#{login}/following", :users)
|
10
|
+
User.users_from_logins(l)
|
11
11
|
end
|
12
12
|
|
13
13
|
def followers(login)
|
14
|
-
|
15
|
-
User.
|
14
|
+
l = json("/user/show/#{login}/followers", :users)
|
15
|
+
User.users_from_logins(l)
|
16
16
|
end
|
17
17
|
|
18
18
|
def repositories(login)
|
19
19
|
j = json("/repos/show/#{login}", :repositories)
|
20
|
-
Repository.
|
20
|
+
Repository.repositories_from_hashes(j)
|
21
21
|
end
|
22
22
|
|
23
23
|
def watched(login)
|
24
24
|
j = json("/repos/watched/#{login}", :repositories)
|
25
|
-
Repository.
|
25
|
+
Repository.repositories_from_hashes(j)
|
26
26
|
end
|
27
27
|
|
28
28
|
def repository(login, repository_name)
|
29
29
|
j = json("/repos/show/#{login}/#{repository_name}", :repository)
|
30
|
-
Repository.
|
30
|
+
Repository.from_hash(j)
|
31
31
|
end
|
32
32
|
|
33
33
|
def branches(login, repository_name)
|
@@ -36,7 +36,7 @@ module GitHub
|
|
36
36
|
|
37
37
|
def network(login, repository_name)
|
38
38
|
j = json("/repos/show/#{login}/#{repository_name}/network", :network)
|
39
|
-
Repository.
|
39
|
+
Repository.repositories_from_hashes(j)
|
40
40
|
end
|
41
41
|
|
42
42
|
private
|
@@ -2,13 +2,13 @@ require 'ostruct'
|
|
2
2
|
|
3
3
|
module GitHub
|
4
4
|
class Repository < OpenStruct
|
5
|
-
def self.
|
6
|
-
new(
|
5
|
+
def self.from_hash(h)
|
6
|
+
new(h)
|
7
7
|
end
|
8
8
|
|
9
|
-
def self.
|
10
|
-
|
11
|
-
repositories <<
|
9
|
+
def self.repositories_from_hashes(h)
|
10
|
+
h.inject([]) do |repositories, repository_attrs|
|
11
|
+
repositories << from_hash(repository_attrs)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
data/lib/github/models/user.rb
CHANGED
@@ -2,13 +2,13 @@ require 'ostruct'
|
|
2
2
|
|
3
3
|
module GitHub
|
4
4
|
class User < OpenStruct
|
5
|
-
def self.
|
6
|
-
new(
|
5
|
+
def self.from_hash(h)
|
6
|
+
new(h)
|
7
7
|
end
|
8
8
|
|
9
|
-
def self.
|
10
|
-
|
11
|
-
users <<
|
9
|
+
def self.users_from_logins(logins)
|
10
|
+
logins.inject([]) do |users, login|
|
11
|
+
users << from_hash(:login => login)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
data/lib/hubruby.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe GitHub do
|
4
|
+
it "should be able to find a user" do
|
5
|
+
subject.should respond_to(:user)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should be able to find the following users from a user" do
|
9
|
+
subject.should respond_to(:following)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be able to find an user followers" do
|
13
|
+
subject.should respond_to(:followers)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should be able to find an user repositories" do
|
17
|
+
subject.should respond_to(:repositories)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should be able to find an user watched repositories" do
|
21
|
+
subject.should respond_to(:watched)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should be able to find a repository" do
|
25
|
+
subject.should respond_to(:repository)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be able to find the branches of a repository" do
|
29
|
+
subject.should respond_to(:branches)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should be able to find the network of a repository" do
|
33
|
+
subject.should respond_to(:network)
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe GitHub::Repository do
|
4
|
+
it "should be instantiable from a hash" do
|
5
|
+
subject.class.should respond_to(:from_hash)
|
6
|
+
|
7
|
+
hash = {:name => 'hubruby', :owner => 'diogenes'}
|
8
|
+
|
9
|
+
repo = GitHub::Repository.from_hash(hash)
|
10
|
+
repo.name.should be_eql 'hubruby'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be instantiable as a collection from a hash" do
|
14
|
+
subject.class.should respond_to(:repositories_from_hashes)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be able to show your branches" do
|
18
|
+
subject.should respond_to(:branches)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should be able to show your network" do
|
22
|
+
subject.should respond_to(:network)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe GitHub::User do
|
4
|
+
it "should be instantiable from a hash" do
|
5
|
+
subject.class.should respond_to(:from_hash)
|
6
|
+
|
7
|
+
hash = {:name => 'Diógenes Falcão', :login => 'diogenes'}
|
8
|
+
|
9
|
+
user = GitHub::User.from_hash(hash)
|
10
|
+
user.login.should be_eql "diogenes"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be instantiable as a collection from a list of logins" do
|
14
|
+
subject.class.should respond_to(:users_from_logins)
|
15
|
+
|
16
|
+
logins = ['guy1', 'guy2']
|
17
|
+
|
18
|
+
users = GitHub::User.users_from_logins(logins)
|
19
|
+
users.first.login.should be_eql 'guy1'
|
20
|
+
users.last.login.should be_eql 'guy2'
|
21
|
+
users.size.should be_eql 2
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should be able to show your following users" do
|
25
|
+
subject.should respond_to(:following)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be able to show your followers users" do
|
29
|
+
subject.should respond_to(:followers)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should be able to show your repositories" do
|
33
|
+
subject.should respond_to(:repositories)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should be able to show your watched repositories" do
|
37
|
+
subject.should respond_to(:watched)
|
38
|
+
end
|
39
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "Di\xC3\xB3genes Falc\xC3\xA3o"
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-09-03 00:00:00 -03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -59,19 +59,23 @@ dependencies:
|
|
59
59
|
version: 2.6.1
|
60
60
|
type: :development
|
61
61
|
version_requirements: *id003
|
62
|
-
description: A simple Ruby library for accessing the current GitHub API (v2)
|
62
|
+
description: A simple Ruby library for accessing the current GitHub API (v2).
|
63
63
|
email:
|
64
64
|
- diogenes {d-o-t} araujo {at} gmail.com
|
65
65
|
executables: []
|
66
66
|
|
67
67
|
extensions: []
|
68
68
|
|
69
|
-
extra_rdoc_files:
|
70
|
-
|
69
|
+
extra_rdoc_files:
|
70
|
+
- History.txt
|
71
|
+
- Manifest.txt
|
71
72
|
files:
|
73
|
+
- History.txt
|
74
|
+
- Manifest.txt
|
72
75
|
- README.rdoc
|
73
76
|
- Rakefile
|
74
77
|
- TODO
|
78
|
+
- hubruby.gemspec
|
75
79
|
- lib/github/base.rb
|
76
80
|
- lib/github/finders.rb
|
77
81
|
- lib/github/models/repository.rb
|
@@ -80,6 +84,12 @@ files:
|
|
80
84
|
- script/console
|
81
85
|
- script/destroy
|
82
86
|
- script/generate
|
87
|
+
- spec/github/github_spec.rb
|
88
|
+
- spec/github/models/repository_spec.rb
|
89
|
+
- spec/github/models/user_spec.rb
|
90
|
+
- spec/spec.opts
|
91
|
+
- spec/spec_helper.rb
|
92
|
+
- tasks/rspec.rake
|
83
93
|
has_rdoc: true
|
84
94
|
homepage: http://github.com/diogenes/hubruby
|
85
95
|
licenses: []
|
@@ -110,6 +120,6 @@ rubyforge_project: hubruby
|
|
110
120
|
rubygems_version: 1.3.6
|
111
121
|
signing_key:
|
112
122
|
specification_version: 3
|
113
|
-
summary: A simple Ruby library for accessing the current GitHub API (v2)
|
123
|
+
summary: A simple Ruby library for accessing the current GitHub API (v2).
|
114
124
|
test_files: []
|
115
125
|
|