dancroak-le-git 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README.textile +25 -0
- data/Rakefile +43 -0
- data/VERSION.yml +4 -0
- data/lib/le_git/commit.rb +54 -0
- data/lib/le_git/repository.rb +22 -0
- data/lib/le_git/user.rb +22 -0
- data/lib/le_git.rb +8 -0
- data/test/fixtures/commit.xml +64 -0
- data/test/fixtures/commits.xml +649 -0
- data/test/fixtures/search.xml +347 -0
- data/test/fixtures/user.xml +450 -0
- data/test/github_commit_test.rb +163 -0
- data/test/github_repository_test.rb +49 -0
- data/test/github_user_test.rb +73 -0
- data/test/test_helper.rb +20 -0
- metadata +92 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Josh Nichols
|
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.
|
data/README.textile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
h1. Le Git
|
2
|
+
|
3
|
+
bq. French for "Ruby wrapper around the Github API (v2)".
|
4
|
+
|
5
|
+
Le Git provides a Ruby wrapper around the "The GitHub API":http://github.com/guides/the-github-api using "rest-client":http://rdoc.info/projects/adamwiggins/rest-client and "happymapper":http://rdoc.info/projects/jnunemaker/happymapper.
|
6
|
+
|
7
|
+
h2. Example usage
|
8
|
+
|
9
|
+
require 'rubygems'
|
10
|
+
require 'le_git'
|
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"
|
19
|
+
|
20
|
+
h2. Maintainers
|
21
|
+
|
22
|
+
Running the test suite requires:
|
23
|
+
|
24
|
+
sudo gem install happymapper fakeweb rcov jeremymcanally-context jeremymcanally-matchy jeremymcanally-pending thoughtbot-quietbacktrace redgreen
|
25
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'rcov/rcovtask'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |s|
|
9
|
+
s.name = "le-git"
|
10
|
+
s.summary = "TODO"
|
11
|
+
s.email = "josh@technicalpickles.com"
|
12
|
+
s.homepage = "http://github.com/dancroak/le-git"
|
13
|
+
s.description = "TODO"
|
14
|
+
s.authors = ["Josh Nichols", "Dan Croak"]
|
15
|
+
s.add_dependency "rest-client"
|
16
|
+
s.add_dependency "happymapper"
|
17
|
+
end
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
Rake::TestTask.new do |t|
|
24
|
+
t.libs << 'lib'
|
25
|
+
t.pattern = 'test/**/*_test.rb'
|
26
|
+
t.verbose = false
|
27
|
+
end
|
28
|
+
|
29
|
+
Rake::RDocTask.new do |rdoc|
|
30
|
+
rdoc.rdoc_dir = 'rdoc'
|
31
|
+
rdoc.title = 'GitHub Party'
|
32
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
33
|
+
rdoc.rdoc_files.include('README*')
|
34
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
35
|
+
end
|
36
|
+
|
37
|
+
Rcov::RcovTask.new do |t|
|
38
|
+
t.libs << "test"
|
39
|
+
t.test_files = FileList['test/*_test.rb']
|
40
|
+
t.verbose = true
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
data/VERSION.yml
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
module GitHub
|
2
|
+
class Commit
|
3
|
+
include HappyMapper
|
4
|
+
|
5
|
+
tag "commit"
|
6
|
+
|
7
|
+
element :url, String
|
8
|
+
element :tree, String
|
9
|
+
element :message, String
|
10
|
+
element :id, String
|
11
|
+
|
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
|
+
def self.find(username, repository, hash_or_all)
|
33
|
+
case hash_or_all
|
34
|
+
when :all
|
35
|
+
self.find_all username, repository
|
36
|
+
else
|
37
|
+
self.find_by_hash username, repository, hash_or_all
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
protected
|
42
|
+
|
43
|
+
def self.find_all(username, repository)
|
44
|
+
xml = RestClient.get("http://github.com/api/v1/xml/#{username}/#{repository}/commits/master")
|
45
|
+
parse(xml)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.find_by_hash(username, repository, hash)
|
49
|
+
xml = RestClient.get("http://github.com/api/v1/xml/#{username}/#{repository}/commit/#{hash}")
|
50
|
+
commits = parse(xml)
|
51
|
+
commits.first
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module GitHub
|
2
|
+
class Repository
|
3
|
+
include HappyMapper
|
4
|
+
|
5
|
+
tag "repository"
|
6
|
+
|
7
|
+
element :owner, String
|
8
|
+
element :forks, Integer
|
9
|
+
element :name, String
|
10
|
+
element :private, Boolean
|
11
|
+
element :url, String
|
12
|
+
element :watchers, Integer
|
13
|
+
element :fork, Boolean
|
14
|
+
element :homepage, String
|
15
|
+
element :description, String
|
16
|
+
|
17
|
+
def self.search(query)
|
18
|
+
xml = RestClient.get("http://github.com/api/v1/xml/search/#{query}")
|
19
|
+
parse(xml)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/le_git/user.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module GitHub
|
2
|
+
class User
|
3
|
+
include HappyMapper
|
4
|
+
|
5
|
+
tag "user"
|
6
|
+
|
7
|
+
element :company, String
|
8
|
+
element :name, String
|
9
|
+
element :blog, String
|
10
|
+
element :email, String
|
11
|
+
element :location, String
|
12
|
+
element :login, String
|
13
|
+
|
14
|
+
has_many :repositories, Repository
|
15
|
+
|
16
|
+
def self.find(username)
|
17
|
+
xml = RestClient.get("http://github.com/api/v1/xml/#{username}")
|
18
|
+
users = parse(xml)
|
19
|
+
users.first
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/le_git.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/0.6.31
|
3
|
+
Date: Tue, 20 Jan 2009 03:45:10 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: 180ms
|
9
|
+
ETag: "ae6c207c2f78e05bf43e7c4dd7ef3fed"
|
10
|
+
Cache-Control: private, max-age=0, must-revalidate
|
11
|
+
Content-Length: 1463
|
12
|
+
|
13
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
14
|
+
<commit>
|
15
|
+
<removed type="array">
|
16
|
+
<removed>
|
17
|
+
<filename>commands.rb</filename>
|
18
|
+
</removed>
|
19
|
+
<removed>
|
20
|
+
<filename>helpers.rb</filename>
|
21
|
+
</removed>
|
22
|
+
</removed>
|
23
|
+
<added type="array">
|
24
|
+
<added>
|
25
|
+
<filename>commands/commands.rb</filename>
|
26
|
+
</added>
|
27
|
+
<added>
|
28
|
+
<filename>commands/helpers.rb</filename>
|
29
|
+
</added>
|
30
|
+
</added>
|
31
|
+
<message>move commands.rb and helpers.rb into commands/ dir</message>
|
32
|
+
<modified type="array">
|
33
|
+
<modified>
|
34
|
+
<diff>@@ -56,7 +56,7 @@ module GitHub
|
35
|
+
end
|
36
|
+
|
37
|
+
def load(file)
|
38
|
+
- file[0] == ?/ ? super : super(BasePath + "/#{file}")
|
39
|
+
+ file[0] == ?/ ? super : super(BasePath + "/commands/#{file}")
|
40
|
+
end
|
41
|
+
|
42
|
+
def debug(*messages)</diff>
|
43
|
+
<filename>lib/github.rb</filename>
|
44
|
+
</modified>
|
45
|
+
</modified>
|
46
|
+
<parents type="array">
|
47
|
+
<parent>
|
48
|
+
<id>d462d2a2e60438ded3dd9e8e6593ca4146c5a0ba</id>
|
49
|
+
</parent>
|
50
|
+
</parents>
|
51
|
+
<url>http://github.com/defunkt/github-gem/commit/c26d4ce9807ecf57d3f9eefe19ae64e75bcaaa8b</url>
|
52
|
+
<author>
|
53
|
+
<name>Chris Wanstrath</name>
|
54
|
+
<email>chris@ozmm.org</email>
|
55
|
+
</author>
|
56
|
+
<id>c26d4ce9807ecf57d3f9eefe19ae64e75bcaaa8b</id>
|
57
|
+
<committed-date>2008-03-02T16:45:41-08:00</committed-date>
|
58
|
+
<authored-date>2008-03-02T16:45:41-08:00</authored-date>
|
59
|
+
<tree>28a1a1ca3e663d35ba8bf07d3f1781af71359b76</tree>
|
60
|
+
<committer>
|
61
|
+
<name>Chris Wanstrath</name>
|
62
|
+
<email>chris@ozmm.org</email>
|
63
|
+
</committer>
|
64
|
+
</commit>
|