dancroak-le-git 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -2,20 +2,14 @@ h1. Le Git
2
2
 
3
3
  bq. French for "Ruby wrapper around the Github API (v2)".
4
4
 
5
- Le Git provides a Ruby wrapper around the "The GitHub API":http://develop.github.com using "rest-client":http://rdoc.info/projects/adamwiggins/rest-client and "happymapper":http://rdoc.info/projects/jnunemaker/happymapper.
5
+ Le Git provides a Ruby wrapper around the "The Github API":http://develop.github.com using "rest-client":http://rdoc.info/projects/adamwiggins/rest-client and "happymapper":http://rdoc.info/projects/jnunemaker/happymapper.
6
6
 
7
7
  h2. Example usage
8
8
 
9
9
  require 'rubygems'
10
10
  require 'le_git'
11
11
 
12
- commits = GitHub::Commit.find "caged", "gitnub", :all
13
-
14
- commit = GitHub::Commit.find "defunkt", "github-gem", "c26d4ce9807ecf57d3f9eefe19ae64e75bcaaa8b"
15
-
16
- repositories = GitHub::Repository.search "merb"
17
-
18
- user = GitHub::User.find "defunkt"
12
+ user = Github::User.find "defunkt"
19
13
 
20
14
  h2. Maintainers
21
15
 
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 0
4
- :patch: 2
4
+ :patch: 3
data/lib/le_git/commit.rb CHANGED
@@ -1,34 +1,12 @@
1
- module GitHub
1
+ module Github
2
2
  class Commit
3
3
  include HappyMapper
4
4
 
5
- tag "commit"
6
-
7
5
  element :url, String
8
6
  element :tree, String
9
7
  element :message, String
10
8
  element :id, String
11
9
 
12
- # Find commit(s) for a particular username/repository
13
- #
14
- # username:
15
- # GitHub username, required, +String+
16
- #
17
- # repository:
18
- # Name of repository, required, +String+
19
- #
20
- # hash_or_:all
21
- # a commit's hash to get a single commit
22
- # OR
23
- # :all to get the first 30 commits
24
- #
25
- #
26
- #
27
- # Example:
28
- #
29
- # GitHub::Commit.find("caged", "gitnub", :all)
30
- # GitHub::Commit.find "defunkt", "github-gem", "c26d4ce9807ecf57d3f9eefe19ae64e75bcaaa8b"
31
- #
32
10
  def self.find(username, repository, hash_or_all)
33
11
  case hash_or_all
34
12
  when :all
@@ -1,21 +1,19 @@
1
- module GitHub
1
+ module Github
2
2
  class Repository
3
3
  include HappyMapper
4
4
 
5
- tag "repository"
6
-
7
- element :owner, String
8
- element :forks, Integer
5
+ element :description, String
9
6
  element :name, String
10
7
  element :private, Boolean
11
8
  element :url, String
12
- element :watchers, Integer
13
9
  element :fork, Boolean
10
+ element :watchers, Integer
11
+ element :forks, Integer
12
+ element :owner, String
14
13
  element :homepage, String
15
- element :description, String
16
14
 
17
- def self.search(query)
18
- xml = RestClient.get("http://github.com/api/v1/xml/search/#{query}")
15
+ def self.user(name)
16
+ xml = RestClient.get("http://github.com/api/v2/xml/repos/show/#{name}")
19
17
  parse(xml)
20
18
  end
21
19
  end
data/lib/le_git/user.rb CHANGED
@@ -1,19 +1,29 @@
1
- module GitHub
1
+ module Github
2
2
  class User
3
3
  include HappyMapper
4
4
 
5
- tag "user"
6
-
5
+ element :score, Float
7
6
  element :name, String
7
+ element :actions, Integer
8
8
  element :language, String
9
- element :location, String
10
- element :repos, Integer
11
9
  element :followers, Integer
10
+ element :username, String
11
+ element :type, String
12
+ element :fullname, String
13
+ element :repos, Integer
14
+ element :id, String
15
+ element :pushed, DateTime
16
+ element :created, DateTime
17
+ element :location, String
12
18
 
13
19
  def self.find(username)
14
20
  xml = RestClient.get("http://github.com/api/v2/xml/user/search/#{username}")
15
21
  users = parse(xml)
16
22
  users.first
17
23
  end
24
+
25
+ def repositories
26
+ Github::Repository.user(name)
27
+ end
18
28
  end
19
29
  end
@@ -0,0 +1,224 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.6.26
3
+ Date: Tue, 26 May 2009 01:40:03 GMT
4
+ Content-Type: application/xml; charset=utf-8
5
+ Connection: keep-alive
6
+ Set-Cookie: _github_ses=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7AA%3D%3D--884981fc5aa85daf318eeff084d98e2cff92578f; path=/; expires=Wed, 01 Jan 2020 08:00:00 GMT; HttpOnly
7
+ Status: 200 OK
8
+ X-Runtime: 132ms
9
+ ETag: "1f3e21db9930f7474098feada4b49c21"
10
+ Cache-Control: private, max-age=0, must-revalidate
11
+ Content-Length: 8254
12
+
13
+ <?xml version="1.0" encoding="UTF-8"?>
14
+ <repositories type="array">
15
+ <repository>
16
+ <description>Rails plugin. Force major browsers (IE, Firefox, Safari) to reload a page, even when triggered by 'back' button.</description>
17
+ <name>no_cache</name>
18
+ <private type="boolean">false</private>
19
+ <url>http://github.com/dancroak/no_cache</url>
20
+ <fork type="boolean">false</fork>
21
+ <watchers type="integer">10</watchers>
22
+ <forks type="integer">0</forks>
23
+ <owner>dancroak</owner>
24
+ <homepage>http://giantrobots.thoughtbot.com</homepage>
25
+ </repository>
26
+ <repository>
27
+ <description>A craps simulator to help you plan your next trip to the casino by minimizing the house advantage and setting basic constraints on your play.</description>
28
+ <name>craps</name>
29
+ <private type="boolean">false</private>
30
+ <url>http://github.com/dancroak/craps</url>
31
+ <fork type="boolean">false</fork>
32
+ <watchers type="integer">3</watchers>
33
+ <forks type="integer">0</forks>
34
+ <owner>dancroak</owner>
35
+ <homepage></homepage>
36
+ </repository>
37
+ <repository>
38
+ <description>port of Alex Dunae's validates_email_format_of Rails plugin to a gem</description>
39
+ <name>validates_email_format_of</name>
40
+ <private type="boolean">false</private>
41
+ <url>http://github.com/dancroak/validates_email_format_of</url>
42
+ <fork type="boolean">false</fork>
43
+ <watchers type="integer">23</watchers>
44
+ <forks type="integer">0</forks>
45
+ <owner>dancroak</owner>
46
+ <homepage></homepage>
47
+ </repository>
48
+ <repository>
49
+ <description>Ruby wrapper for the Twitter Search API.</description>
50
+ <name>twitter-search</name>
51
+ <private type="boolean">false</private>
52
+ <url>http://github.com/dancroak/twitter-search</url>
53
+ <fork type="boolean">false</fork>
54
+ <watchers type="integer">74</watchers>
55
+ <forks type="integer">8</forks>
56
+ <owner>dancroak</owner>
57
+ <homepage>http://search.twitter.com/api</homepage>
58
+ </repository>
59
+ <repository>
60
+ <description>Subdomain validation for ActiveRecord. Light wrapper around the excellent Addressable library (required). Includes a Shoulda macro.</description>
61
+ <name>validates_subdomain_format_of</name>
62
+ <private type="boolean">false</private>
63
+ <url>http://github.com/dancroak/validates_subdomain_format_of</url>
64
+ <fork type="boolean">false</fork>
65
+ <watchers type="integer">9</watchers>
66
+ <forks type="integer">0</forks>
67
+ <owner>dancroak</owner>
68
+ <homepage></homepage>
69
+ </repository>
70
+ <repository>
71
+ <description>Unit tests I wrote way back when I started learning Ruby.</description>
72
+ <name>ruby-learning-tests</name>
73
+ <private type="boolean">false</private>
74
+ <url>http://github.com/dancroak/ruby-learning-tests</url>
75
+ <fork type="boolean">true</fork>
76
+ <watchers type="integer">2</watchers>
77
+ <forks type="integer">0</forks>
78
+ <owner>dancroak</owner>
79
+ <homepage>http://clarkware.com/cgi/blosxom/2005/03/18</homepage>
80
+ </repository>
81
+ <repository>
82
+ <description>URL shortening app in the fewest readable lines of Ruby possible.</description>
83
+ <name>shorty</name>
84
+ <private type="boolean">false</private>
85
+ <url>http://github.com/dancroak/shorty</url>
86
+ <fork type="boolean">false</fork>
87
+ <watchers type="integer">2</watchers>
88
+ <forks type="integer">0</forks>
89
+ <owner>dancroak</owner>
90
+ <homepage></homepage>
91
+ </repository>
92
+ <repository>
93
+ <description>Generate random short, non-offensive words. Good for human-readable confirmation codes.</description>
94
+ <name>webster</name>
95
+ <private type="boolean">false</private>
96
+ <url>http://github.com/dancroak/webster</url>
97
+ <fork type="boolean">false</fork>
98
+ <watchers type="integer">21</watchers>
99
+ <forks type="integer">0</forks>
100
+ <owner>dancroak</owner>
101
+ <homepage></homepage>
102
+ </repository>
103
+ <repository>
104
+ <description>Nurse cares for invalid ActiveRecord objects.</description>
105
+ <name>nurse</name>
106
+ <private type="boolean">false</private>
107
+ <url>http://github.com/dancroak/nurse</url>
108
+ <fork type="boolean">false</fork>
109
+ <watchers type="integer">2</watchers>
110
+ <forks type="integer">0</forks>
111
+ <owner>dancroak</owner>
112
+ <homepage></homepage>
113
+ </repository>
114
+ <repository>
115
+ <description>Makes tests easy on the fingers and the eyes</description>
116
+ <name>shoulda</name>
117
+ <private type="boolean">false</private>
118
+ <url>http://github.com/dancroak/shoulda</url>
119
+ <fork type="boolean">true</fork>
120
+ <watchers type="integer">6</watchers>
121
+ <forks type="integer">1</forks>
122
+ <owner>dancroak</owner>
123
+ <homepage>http://www.thoughtbot.com/projects/shoulda</homepage>
124
+ </repository>
125
+ <repository>
126
+ <description>Experimental.</description>
127
+ <name>rails-templates</name>
128
+ <private type="boolean">false</private>
129
+ <url>http://github.com/dancroak/rails-templates</url>
130
+ <fork type="boolean">false</fork>
131
+ <watchers type="integer">2</watchers>
132
+ <forks type="integer">0</forks>
133
+ <owner>dancroak</owner>
134
+ <homepage></homepage>
135
+ </repository>
136
+ <repository>
137
+ <description>Most awesome pagination solution for Ruby</description>
138
+ <name>will_paginate</name>
139
+ <private type="boolean">false</private>
140
+ <url>http://github.com/dancroak/will_paginate</url>
141
+ <fork type="boolean">true</fork>
142
+ <watchers type="integer">1</watchers>
143
+ <forks type="integer">0</forks>
144
+ <owner>dancroak</owner>
145
+ <homepage>http://github.com/mislav/will_paginate/wikis</homepage>
146
+ </repository>
147
+ <repository>
148
+ <description>My config files (aka dotfiles)</description>
149
+ <name>config_files</name>
150
+ <private type="boolean">false</private>
151
+ <url>http://github.com/dancroak/config_files</url>
152
+ <fork type="boolean">true</fork>
153
+ <watchers type="integer">1</watchers>
154
+ <forks type="integer">0</forks>
155
+ <owner>dancroak</owner>
156
+ <homepage></homepage>
157
+ </repository>
158
+ <repository>
159
+ <description>Rails generators for developers who do TDD.</description>
160
+ <name>coulda</name>
161
+ <private type="boolean">false</private>
162
+ <url>http://github.com/dancroak/coulda</url>
163
+ <fork type="boolean">false</fork>
164
+ <watchers type="integer">11</watchers>
165
+ <forks type="integer">0</forks>
166
+ <owner>dancroak</owner>
167
+ <homepage></homepage>
168
+ </repository>
169
+ <repository>
170
+ <description>Generated scopes for ActiveRecord classes</description>
171
+ <name>pacecar</name>
172
+ <private type="boolean">false</private>
173
+ <url>http://github.com/dancroak/pacecar</url>
174
+ <fork type="boolean">true</fork>
175
+ <watchers type="integer">1</watchers>
176
+ <forks type="integer">0</forks>
177
+ <owner>dancroak</owner>
178
+ <homepage></homepage>
179
+ </repository>
180
+ <repository>
181
+ <description>Tweet from the command line.</description>
182
+ <name>tweet</name>
183
+ <private type="boolean">false</private>
184
+ <url>http://github.com/dancroak/tweet</url>
185
+ <fork type="boolean">true</fork>
186
+ <watchers type="integer">3</watchers>
187
+ <forks type="integer">0</forks>
188
+ <owner>dancroak</owner>
189
+ <homepage></homepage>
190
+ </repository>
191
+ <repository>
192
+ <description>Hello is a Ruby interface to a collection of the word &#8220;hello&#8221; in many languages and dialects.</description>
193
+ <name>hello</name>
194
+ <private type="boolean">false</private>
195
+ <url>http://github.com/dancroak/hello</url>
196
+ <fork type="boolean">false</fork>
197
+ <watchers type="integer">4</watchers>
198
+ <forks type="integer">1</forks>
199
+ <owner>dancroak</owner>
200
+ <homepage></homepage>
201
+ </repository>
202
+ <repository>
203
+ <description>Reading lists</description>
204
+ <name>reading</name>
205
+ <private type="boolean">false</private>
206
+ <url>http://github.com/dancroak/reading</url>
207
+ <fork type="boolean">false</fork>
208
+ <watchers type="integer">2</watchers>
209
+ <forks type="integer">0</forks>
210
+ <owner>dancroak</owner>
211
+ <homepage>http://dancroak.com</homepage>
212
+ </repository>
213
+ <repository>
214
+ <description>Ruby wrapper for the GitHub API v2.</description>
215
+ <name>le-git</name>
216
+ <private type="boolean">false</private>
217
+ <url>http://github.com/dancroak/le-git</url>
218
+ <fork type="boolean">true</fork>
219
+ <watchers type="integer">1</watchers>
220
+ <forks type="integer">0</forks>
221
+ <owner>dancroak</owner>
222
+ <homepage></homepage>
223
+ </repository>
224
+ </repositories>
File without changes
@@ -1,15 +1,19 @@
1
1
  require File.join(File.dirname(__FILE__), '/test_helper.rb')
2
2
 
3
- class GitHubRepositoryTest < Test::Unit::TestCase
4
- context "searching repositories" do
3
+ class GithubRepositoryTest < Test::Unit::TestCase
4
+ context "a Github::Repository found via user" do
5
5
  setup do
6
- FakeWeb.register_uri('http://github.com/api/v1/xml/search/merb', :response => File.join(File.dirname(__FILE__), 'fixtures', 'search.xml'))
6
+ fixture_path = File.join(File.dirname(__FILE__),
7
+ 'fixtures',
8
+ 'user_repositories.xml')
9
+ FakeWeb.register_uri('http://github.com/api/v2/xml/repos/show/dancroak',
10
+ :response => fixture_path)
7
11
 
8
- @repositories = GitHub::Repository.search("merb")
12
+ @repositories = Github::Repository.user("dancroak")
9
13
  end
10
14
 
11
15
  test "size" do
12
- @repositories.size.should == 30
16
+ @repositories.size.should == 19
13
17
  end
14
18
 
15
19
  context "first" do
@@ -17,32 +21,40 @@ class GitHubRepositoryTest < Test::Unit::TestCase
17
21
  @repository = @repositories.first
18
22
  end
19
23
 
20
- test "#name" do
21
- @repository.name.should == "merb"
24
+ test "#description" do
25
+ @repository.description.should == "Rails plugin. Force major browsers (IE, Firefox, Safari) to reload a page, even when triggered by 'back' button."
22
26
  end
23
27
 
24
- test "#watchers" do
25
- @repository.watchers.should == 15
28
+ test "#name" do
29
+ @repository.name.should == "no_cache"
26
30
  end
27
31
 
28
32
  test "#private" do
29
33
  @repository.private.should == false
30
34
  end
31
35
 
32
- test "#description" do
33
- @repository.description.should == "Merb official repository"
36
+ test "#url" do
37
+ @repository.url.should == "http://github.com/dancroak/no_cache"
38
+ end
39
+
40
+ test "#fork" do
41
+ @repository.fork.should == false
42
+ end
43
+
44
+ test "#watchers" do
45
+ @repository.watchers.should == 10
34
46
  end
35
47
 
36
48
  test "#forks" do
37
49
  @repository.forks.should == 0
38
50
  end
39
51
 
40
- test "#homepage" do
41
- @repository.homepage.should == "http://www.merbivore.com"
52
+ test "#owner" do
53
+ @repository.owner.should == "dancroak"
42
54
  end
43
55
 
44
- test "#owner" do
45
- @repository.owner.should == "merb"
56
+ test "#homepage" do
57
+ @repository.homepage.should == "http://giantrobots.thoughtbot.com"
46
58
  end
47
59
  end
48
60
  end
@@ -1,33 +1,123 @@
1
1
  require File.join(File.dirname(__FILE__), '/test_helper.rb')
2
2
 
3
- class GitHubUserTest < Test::Unit::TestCase
4
- context "A GitHub::User" do
3
+ class GithubUserTest < Test::Unit::TestCase
4
+ context "A Github::User" do
5
5
  setup do
6
6
  fixture_path = File.join(File.dirname(__FILE__), 'fixtures', 'user.xml')
7
7
  FakeWeb.register_uri('http://github.com/api/v2/xml/user/search/dancroak',
8
8
  :response => fixture_path)
9
9
 
10
- @user = GitHub::User.find('dancroak')
10
+ @user = Github::User.find('dancroak')
11
+ end
12
+
13
+ test "#score" do
14
+ @user.score.should == 3.8653853
11
15
  end
12
16
 
13
17
  test "#name" do
14
18
  @user.name.should == "dancroak"
15
19
  end
16
20
 
21
+ test "#actions" do
22
+ @user.actions.should == 35
23
+ end
24
+
17
25
  test "#language" do
18
26
  @user.language.should == "Ruby"
19
27
  end
20
28
 
21
- test "#location" do
22
- @user.location.should == "Boston"
29
+ test "#followers" do
30
+ @user.followers.should == 50
31
+ end
32
+
33
+ test "#username" do
34
+ @user.username.should == "dancroak"
35
+ end
36
+
37
+ test "#type" do
38
+ @user.type.should == "user"
39
+ end
40
+
41
+ test "#fullname" do
42
+ @user.fullname.should == "Dan Croak"
23
43
  end
24
44
 
25
45
  test "#repos" do
26
- @user.repos == 18
46
+ @user.repos.should == 18
27
47
  end
28
48
 
29
- test "#followers" do
30
- @user.followers == 50
49
+ test "#id" do
50
+ @user.id.should == "user-198"
51
+ end
52
+
53
+ test "#pushed" do
54
+ @user.pushed.to_s.should == DateTime.new(2009, 5, 22, 17, 15, 11).to_s
55
+ end
56
+
57
+ test "#created" do
58
+ @user.created.to_s.should == DateTime.new(2008, 2, 13, 2, 48, 35).to_s
59
+ end
60
+
61
+ test "#location" do
62
+ @user.location.should == "Boston"
63
+ end
64
+
65
+ context "GETing #repositories" do
66
+ setup do
67
+ fixture_path = File.join(File.dirname(__FILE__),
68
+ 'fixtures',
69
+ 'user_repositories.xml')
70
+ FakeWeb.register_uri('http://github.com/api/v2/xml/repos/show/dancroak',
71
+ :response => fixture_path)
72
+
73
+ @repositories = @user.repositories
74
+ end
75
+
76
+ test "size" do
77
+ @repositories.size.should == 19
78
+ end
79
+
80
+ context "first" do
81
+ setup do
82
+ @repository = @repositories.first
83
+ end
84
+
85
+ test "#description" do
86
+ @repository.description.should == "Rails plugin. Force major browsers (IE, Firefox, Safari) to reload a page, even when triggered by 'back' button."
87
+ end
88
+
89
+ test "#name" do
90
+ @repository.name.should == "no_cache"
91
+ end
92
+
93
+ test "#private" do
94
+ @repository.private.should == false
95
+ end
96
+
97
+ test "#url" do
98
+ @repository.url.should == "http://github.com/dancroak/no_cache"
99
+ end
100
+
101
+ test "#fork" do
102
+ @repository.fork.should == false
103
+ end
104
+
105
+ test "#watchers" do
106
+ @repository.watchers.should == 10
107
+ end
108
+
109
+ test "#forks" do
110
+ @repository.forks.should == 0
111
+ end
112
+
113
+ test "#owner" do
114
+ @repository.owner.should == "dancroak"
115
+ end
116
+
117
+ test "#homepage" do
118
+ @repository.homepage.should == "http://giantrobots.thoughtbot.com"
119
+ end
120
+ end
31
121
  end
32
122
  end
33
123
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dancroak-le-git
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Nichols
@@ -55,7 +55,9 @@ files:
55
55
  - test/fixtures/commits.xml
56
56
  - test/fixtures/search.xml
57
57
  - test/fixtures/user.xml
58
+ - test/fixtures/user_repositories.xml
58
59
  - test/github_commit_test.rb
60
+ - test/github_follower_test.rb
59
61
  - test/github_repository_test.rb
60
62
  - test/github_user_test.rb
61
63
  - test/test_helper.rb
@@ -87,6 +89,7 @@ specification_version: 3
87
89
  summary: TODO
88
90
  test_files:
89
91
  - test/github_commit_test.rb
92
+ - test/github_follower_test.rb
90
93
  - test/github_repository_test.rb
91
94
  - test/github_user_test.rb
92
95
  - test/test_helper.rb