mbleigh-ruby-github 0.0.3
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/History.txt +13 -0
- data/Manifest.txt +6 -0
- data/README.txt +65 -0
- data/Rakefile +2 -0
- data/lib/mbleigh-ruby-github.rb +56 -0
- data/ruby-github.gemspec +15 -0
- metadata +69 -0
data/History.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
=== 0.0.3 / 2008-04-25
|
2
|
+
|
3
|
+
* Now using GitHub's gem library, ditching Rubyforge.
|
4
|
+
|
5
|
+
=== 0.0.2 / 2008-04-12
|
6
|
+
|
7
|
+
* Now using Hoe for Rubyforge distribution
|
8
|
+
* Uses the new Mash gem for its API structures
|
9
|
+
* GitHub API calls are now through GitHub::API instead of just GitHub
|
10
|
+
|
11
|
+
=== 0.0.1 / 2008-04-02
|
12
|
+
|
13
|
+
* Initial release
|
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
== Ruby-GitHub
|
2
|
+
|
3
|
+
= DESCRIPTION:
|
4
|
+
|
5
|
+
Ruby-GitHub is a simple wrapper library for the evolving GitHub API.
|
6
|
+
|
7
|
+
= INSTALLATION:
|
8
|
+
|
9
|
+
Gem:
|
10
|
+
|
11
|
+
The gem is hosted on GitHub so you will need to execute the first line if you have not installed any gems from GitHub before.
|
12
|
+
|
13
|
+
gem sources -a http://gems.github.com/
|
14
|
+
sudo gem install mbleigh-ruby-github
|
15
|
+
|
16
|
+
GitHub Clone:
|
17
|
+
|
18
|
+
git clone git://github.com/mbleigh/ruby-github.git
|
19
|
+
|
20
|
+
= DEPENDENCIES:
|
21
|
+
|
22
|
+
* Requires the 'json' gem
|
23
|
+
* Requires the 'mash' gem
|
24
|
+
|
25
|
+
= SYNOPSIS:
|
26
|
+
|
27
|
+
require 'ruby-github'
|
28
|
+
|
29
|
+
user = GitHub::API.user('mbleigh')
|
30
|
+
user.name # => "Michael Bleigh"
|
31
|
+
user.repositories # => array of repositories
|
32
|
+
user.repositories.last.name # => "ruby-github"
|
33
|
+
user.repositories.last.url # => "http://GitHub::API.com/mbleigh/ruby-github"
|
34
|
+
user.repositories.last.commits # => requests array of commits (see below)
|
35
|
+
|
36
|
+
commits = GitHub::API.commits('mbleigh','ruby-github')
|
37
|
+
commits.first.message # => "Moved GitHub::API.rb to ruby-GitHub::API.rb..."
|
38
|
+
commits.first.id # => "1d8c21062e11bb1ecd51ab840aa13d906993f3f7"
|
39
|
+
|
40
|
+
# these two lines are equivalent
|
41
|
+
commit = commits.first.detailed
|
42
|
+
commit = GitHub::API.commit('mbleigh', 'ruby-github', '1d8c21062e11bb1ecd51ab840aa13d906993f3f7')
|
43
|
+
|
44
|
+
commit.message # => "Moved GitHub::API.rb to ruby-GitHub::API.rb..."
|
45
|
+
commit.added.collect{|c| c.filename} # => ["init.rb", "lib/ruby-GitHub::API.rb"]
|
46
|
+
|
47
|
+
Note that the information is less complete in the 'commits' pull
|
48
|
+
than in the pull for an individual commit. calling 'detailed' on
|
49
|
+
a commit retreived from a 'commits' call will make a 'commit' call
|
50
|
+
for that specific commit.
|
51
|
+
|
52
|
+
Here's a one-liner that uses all parts of the Ruby-GitHub library:
|
53
|
+
|
54
|
+
latest_commit_filenames = GitHub::API.user('mbleigh').repositories.first.commits.first.detailed.modified.collect(&:filename)
|
55
|
+
|
56
|
+
= RESOURCES:
|
57
|
+
|
58
|
+
* GitHub Project: http://GitHub::API.com/mbleigh/ruby-github
|
59
|
+
* E-Mail: michael@intridea.com
|
60
|
+
|
61
|
+
= KNOWN ISSUES/FUTURE DEVELOPMENT:
|
62
|
+
|
63
|
+
Right now this library isn't spec'ed out, that's the top priority moving forward. It
|
64
|
+
will likely also have to evolve substantially as the GitHub API becomes more mature.
|
65
|
+
If you have any questions or requests, don't hesitate to e-mail me!
|
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'json'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'mash'
|
5
|
+
|
6
|
+
module GitHub
|
7
|
+
class API
|
8
|
+
BASE_URL = "http://github.com/api/v1/json"
|
9
|
+
|
10
|
+
# Fetches information about the specified user name.
|
11
|
+
def self.user(user)
|
12
|
+
url = BASE_URL + "/#{user}"
|
13
|
+
GitHub::User.new(JSON.parse(open(url).read)["user"])
|
14
|
+
end
|
15
|
+
|
16
|
+
# Fetches the commits for a given repository.
|
17
|
+
def self.commits(user,repository,branch="master")
|
18
|
+
url = BASE_URL + "/#{user}/#{repository}/commits/#{branch}"
|
19
|
+
JSON.parse(open(url).read)["commits"].collect{ |c|
|
20
|
+
GitHub::Commit.new(c.merge(:user => user, :repository => repository))
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
# Fetches a single commit for a repository.
|
25
|
+
def self.commit(user,repository,commit)
|
26
|
+
url = BASE_URL + "/#{user}/#{repository}/commit/#{commit}"
|
27
|
+
GitHub::Commit.new(JSON.parse(open(url).read).merge(:user => user, :repository => repository))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Repository < Mash
|
32
|
+
def commits
|
33
|
+
::GitHub::API.commits(user,name)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class User < Mash
|
38
|
+
def initialize(hash = nil)
|
39
|
+
@user = hash["login"] if hash
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
43
|
+
def repositories=(repo_array)
|
44
|
+
puts self.inspect
|
45
|
+
self["repositories"] = repo_array.collect{|r| ::GitHub::Repository.new(r.merge(:user => login || @user))}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class Commit < Mash
|
50
|
+
# if a method only available to a detailed commit is called,
|
51
|
+
# automatically fetch it from the API
|
52
|
+
def detailed
|
53
|
+
::GitHub::API.commit(user,repository,id)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/ruby-github.gemspec
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "ruby-github"
|
3
|
+
s.version = "0.0.3"
|
4
|
+
s.date = "2008-04-25"
|
5
|
+
s.summary = "Simple Ruby library to access the GitHub API."
|
6
|
+
s.email = "michael@intridea.com"
|
7
|
+
s.homepage = "http://github.com/mbleigh/ruby-github"
|
8
|
+
s.description = "Ruby-GitHub is a small library that provides simple access to GitHub's evolving API."
|
9
|
+
s.has_rdoc = true
|
10
|
+
s.authors = ["Michael Bleigh"]
|
11
|
+
s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "ruby-github.gemspec", "lib/ruby-github.rb"]
|
12
|
+
s.rdoc_options = ["--main", "README.txt"]
|
13
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
|
14
|
+
s.add_dependency("mash", [">= 0.0.3"])
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mbleigh-ruby-github
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Bleigh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-04-25 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mash
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.0.3
|
23
|
+
version:
|
24
|
+
description: Ruby-GitHub is a small library that provides simple access to GitHub's evolving API.
|
25
|
+
email: michael@intridea.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- History.txt
|
32
|
+
- Manifest.txt
|
33
|
+
- README.txt
|
34
|
+
files:
|
35
|
+
- History.txt
|
36
|
+
- Manifest.txt
|
37
|
+
- README.txt
|
38
|
+
- Rakefile
|
39
|
+
- ruby-github.gemspec
|
40
|
+
- lib/ruby-github.rb
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://github.com/mbleigh/ruby-github
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options:
|
45
|
+
- --main
|
46
|
+
- README.txt
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
version:
|
61
|
+
requirements: []
|
62
|
+
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.0.1
|
65
|
+
signing_key:
|
66
|
+
specification_version: 2
|
67
|
+
summary: Simple Ruby library to access the GitHub API.
|
68
|
+
test_files: []
|
69
|
+
|