git_hub 0.2.0 → 0.2.7
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/README.rdoc +30 -29
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/features/{zemax.feature → git_hub.feature} +0 -0
- data/features/step_definitions/{zemax_steps.rb → git_hub_steps.rb} +0 -0
- data/features/support/env.rb +1 -1
- data/git_hub.gemspec +10 -4
- data/lib/git_hub/base.rb +37 -23
- data/lib/git_hub/commit.rb +20 -17
- data/lib/git_hub/repo.rb +51 -31
- data/lib/git_hub.rb +1 -10
- data/rdoc/classes/GitHub/Api.html +49 -15
- data/rdoc/classes/GitHub/Base.html +147 -47
- data/rdoc/classes/GitHub/Commit.html +390 -0
- data/rdoc/classes/GitHub/Repo.html +266 -111
- data/rdoc/classes/GitHub.html +34 -60
- data/rdoc/created.rid +1 -1
- data/rdoc/files/README_rdoc.html +43 -18
- data/rdoc/files/lib/git_hub/api_rb.html +2 -2
- data/rdoc/files/lib/git_hub/base_rb.html +2 -2
- data/rdoc/files/lib/git_hub/commit_rb.html +91 -0
- data/rdoc/files/lib/git_hub/repo_rb.html +2 -2
- data/rdoc/files/lib/git_hub_rb.html +2 -2
- data/rdoc/fr_class_index.html +4 -2
- data/rdoc/fr_file_index.html +4 -2
- data/rdoc/fr_method_index.html +42 -24
- data/rdoc/index.html +2 -2
- data/spec/git_hub/commit_spec.rb +6 -6
- data/spec/git_hub/repo_spec.rb +12 -7
- data/spec/git_hub/user_spec.rb +15 -0
- data/spec/spec_helper.rb +6 -2
- data/spec/stubs/commits/show/joe007/fine_repo/3a70f86293b719f193f778a8710b1f83f2f7bf38.res +47 -0
- data/spec/stubs/commits/show/joe007/fine_repo/f7f5dddaa37deacc83f1f56876e2b135389d03ab.res +38 -0
- metadata +10 -4
data/README.rdoc
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
= git_hub
|
2
|
-
by
|
3
|
-
url
|
2
|
+
by: Arvicco
|
3
|
+
url: http://github.com/arvicco/git_hub
|
4
4
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
7
7
|
git_hub is a library that wraps github API and exposes simple interface for
|
8
|
-
finding, creating and managing github repositories and other resources
|
8
|
+
finding, creating and managing github repositories and other resources.
|
9
9
|
|
10
10
|
== FEATURES/PROBLEMS:
|
11
11
|
|
@@ -15,31 +15,32 @@ Contributors always welcome!
|
|
15
15
|
|
16
16
|
== SYNOPSIS:
|
17
17
|
|
18
|
-
require 'git_hub'
|
19
|
-
include GitHub
|
20
|
-
|
21
|
-
|
22
|
-
repo = Repo.find(:user=>user_name, :repo=>repo_name)
|
23
|
-
repos = Repo.find(:user=>user_name)
|
24
|
-
search_repos = Repo.find(:query=>['search','terms'])
|
25
|
-
|
26
|
-
|
27
|
-
puts repo.tags['v0.1.0']
|
28
|
-
puts repo.branches['master']
|
29
|
-
repo.commits.each {|commit| p commit.author}
|
30
|
-
|
31
|
-
|
32
|
-
commits = Commit.find(:user=>user_name, :repo=>repo_name, :branch=>'master')
|
33
|
-
commits = Commit.find(:user=>user_name, :repo=>repo_name, :branch=>'master', :path=>'README.rdoc')
|
34
|
-
commit = Commit.find(:user=>user_name, :repo=>repo_name, :sha=>'commit_sha')
|
35
|
-
# or, if repo is already retrieved:
|
36
|
-
commit = repo.commits.last
|
37
|
-
commit = repo.tags['v0.1.0']
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
new_repo.
|
18
|
+
require 'git_hub'
|
19
|
+
include GitHub
|
20
|
+
|
21
|
+
Find existing repos:
|
22
|
+
repo = Repo.find(:user=>user_name, :repo=>repo_name)
|
23
|
+
repos = Repo.find(:user=>user_name)
|
24
|
+
search_repos = Repo.find(:query=>['search','terms'])
|
25
|
+
|
26
|
+
Retrieve tags, branches and commits for a repo:
|
27
|
+
puts repo.tags['v0.1.0'].committer
|
28
|
+
puts repo.branches['master'].committed_date
|
29
|
+
repo.commits.each {|commit| p commit.author}
|
30
|
+
|
31
|
+
Retrieve info for a specific commit:
|
32
|
+
commits = Commit.find(:user=>user_name, :repo=>repo_name, :branch=>'master')
|
33
|
+
commits = Commit.find(:user=>user_name, :repo=>repo_name, :branch=>'master', :path=>'README.rdoc')
|
34
|
+
commit = Commit.find(:user=>user_name, :repo=>repo_name, :sha=>'commit_sha')
|
35
|
+
# or, if repo is already retrieved:
|
36
|
+
commit = repo.commits.last
|
37
|
+
commit = repo.tags['v0.1.0']
|
38
|
+
commit = repo.branches['master'] # returns most recent commit for a branch
|
39
|
+
|
40
|
+
Create new repo or delete existing repo (need to authenticate with your github credentials first)
|
41
|
+
Api.auth = {:user=>user_name, :token=>token}
|
42
|
+
new_repo = Repo.create(:name=>repo_name, :desc=>'Description', :homepage=>'http://your_page.org', :private=> false)
|
43
|
+
new_repo.delete
|
43
44
|
|
44
45
|
== REQUIREMENTS:
|
45
46
|
|
@@ -47,7 +48,7 @@ new_repo.delete
|
|
47
48
|
|
48
49
|
== INSTALL:
|
49
50
|
|
50
|
-
$ sudo gem install git_hub
|
51
|
+
$ sudo gem install git_hub
|
51
52
|
|
52
53
|
== LICENSE:
|
53
54
|
|
data/Rakefile
CHANGED
@@ -51,7 +51,7 @@ Rake::RDocTask.new do |rdoc|
|
|
51
51
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
52
52
|
|
53
53
|
rdoc.rdoc_dir = 'rdoc'
|
54
|
-
rdoc.title = "
|
54
|
+
rdoc.title = "git_hub #{version}"
|
55
55
|
rdoc.rdoc_files.include('README*')
|
56
56
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
57
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.7
|
File without changes
|
File without changes
|
data/features/support/env.rb
CHANGED
data/git_hub.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{git_hub}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["arvicco"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-12}
|
13
13
|
s.default_executable = %q{git_hub}
|
14
14
|
s.description = %q{Simple interface to github API}
|
15
15
|
s.email = %q{arvitallian@gmail.com}
|
@@ -24,9 +24,9 @@ Gem::Specification.new do |s|
|
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION",
|
26
26
|
"bin/git_hub",
|
27
|
-
"features/
|
27
|
+
"features/git_hub.feature",
|
28
|
+
"features/step_definitions/git_hub_steps.rb",
|
28
29
|
"features/support/env.rb",
|
29
|
-
"features/zemax.feature",
|
30
30
|
"git_hub.gemspec",
|
31
31
|
"lib/git_hub.rb",
|
32
32
|
"lib/git_hub/api.rb",
|
@@ -36,11 +36,13 @@ Gem::Specification.new do |s|
|
|
36
36
|
"rdoc/classes/GitHub.html",
|
37
37
|
"rdoc/classes/GitHub/Api.html",
|
38
38
|
"rdoc/classes/GitHub/Base.html",
|
39
|
+
"rdoc/classes/GitHub/Commit.html",
|
39
40
|
"rdoc/classes/GitHub/Repo.html",
|
40
41
|
"rdoc/created.rid",
|
41
42
|
"rdoc/files/README_rdoc.html",
|
42
43
|
"rdoc/files/lib/git_hub/api_rb.html",
|
43
44
|
"rdoc/files/lib/git_hub/base_rb.html",
|
45
|
+
"rdoc/files/lib/git_hub/commit_rb.html",
|
44
46
|
"rdoc/files/lib/git_hub/repo_rb.html",
|
45
47
|
"rdoc/files/lib/git_hub_rb.html",
|
46
48
|
"rdoc/fr_class_index.html",
|
@@ -52,12 +54,15 @@ Gem::Specification.new do |s|
|
|
52
54
|
"spec/git_hub/base_spec.rb",
|
53
55
|
"spec/git_hub/commit_spec.rb",
|
54
56
|
"spec/git_hub/repo_spec.rb",
|
57
|
+
"spec/git_hub/user_spec.rb",
|
55
58
|
"spec/spec.opts",
|
56
59
|
"spec/spec_helper.rb",
|
57
60
|
"spec/stubs/api_route_error.res",
|
58
61
|
"spec/stubs/commits/list/joe007/fine_repo/master.res",
|
59
62
|
"spec/stubs/commits/list/joe007/fine_repo/master/README.res",
|
63
|
+
"spec/stubs/commits/show/joe007/fine_repo/3a70f86293b719f193f778a8710b1f83f2f7bf38.res",
|
60
64
|
"spec/stubs/commits/show/joe007/fine_repo/5e61f0687c40ca48214d09dc7ae2d0d0d8fbfeb8.res",
|
65
|
+
"spec/stubs/commits/show/joe007/fine_repo/f7f5dddaa37deacc83f1f56876e2b135389d03ab.res",
|
61
66
|
"spec/stubs/repos/create.1.res",
|
62
67
|
"spec/stubs/repos/create.2.res",
|
63
68
|
"spec/stubs/repos/create.3.res",
|
@@ -82,6 +87,7 @@ Gem::Specification.new do |s|
|
|
82
87
|
"spec/git_hub/base_spec.rb",
|
83
88
|
"spec/git_hub/commit_spec.rb",
|
84
89
|
"spec/git_hub/repo_spec.rb",
|
90
|
+
"spec/git_hub/user_spec.rb",
|
85
91
|
"spec/spec_helper.rb"
|
86
92
|
]
|
87
93
|
|
data/lib/git_hub/base.rb
CHANGED
@@ -4,10 +4,10 @@ module GitHub
|
|
4
4
|
class Base
|
5
5
|
|
6
6
|
def initialize(attributes={})
|
7
|
-
|
7
|
+
set_attributes attributes
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def set_attributes attributes
|
11
11
|
attributes.each do |key, value|
|
12
12
|
raise "No attr_accessor for #{key} on #{self.class}" unless respond_to?("#{key}=")
|
13
13
|
self.send("#{key.to_s}=", value)
|
@@ -16,9 +16,9 @@ module GitHub
|
|
16
16
|
|
17
17
|
class << self
|
18
18
|
def request verb, uri, params = {}
|
19
|
-
|
20
|
-
#p "request: #{verb} #{
|
21
|
-
res = api.request verb,
|
19
|
+
full_uri = uri[0] == '/' ? base_uri+uri : uri
|
20
|
+
#p "request: #{verb} #{full_uri} #{params}"
|
21
|
+
res = api.request verb, full_uri, params
|
22
22
|
YAML::load(res.body) if res.respond_to?(:body)
|
23
23
|
#p "response: #{res}: #{res.code}: #{res.http_version}: #{res.message}", res.body
|
24
24
|
end
|
@@ -42,34 +42,48 @@ module GitHub
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def base_uri
|
45
|
-
@base_uri ||
|
45
|
+
@base_uri || ''
|
46
46
|
end
|
47
47
|
|
48
48
|
private
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
50
|
+
# extracts arguments described by *args from an opts Hash
|
51
|
+
def extract(opts, *args)
|
52
|
+
raise "Expected options Hash, got #{opts}" unless opts.kind_of? Hash
|
53
|
+
args.map do |arg|
|
54
|
+
opts[arg] || opts[arg.to_sym] || case arg.to_sym
|
55
|
+
when :user
|
56
|
+
opts[:owner] || opts[:username] || opts[:login] || api.auth['login']
|
57
|
+
when :repo
|
58
|
+
opts[:repository] || opts[:name] || opts[:project]
|
59
|
+
when :sha
|
60
|
+
opts[:hash] || opts[:object_id] || opts[:id]
|
61
|
+
when :desc
|
62
|
+
opts[:description] || opts[:descr]
|
63
|
+
when :query
|
64
|
+
opts[:search]
|
65
|
+
when :branch
|
66
|
+
'master'
|
67
|
+
when :public
|
68
|
+
!opts[:private] unless opts[:public] == false
|
69
|
+
else
|
70
|
+
nil
|
71
|
+
end
|
72
|
+
end
|
58
73
|
end
|
59
74
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
75
|
+
# tries to single instance or an Array of instances for a given Hash of
|
76
|
+
# attributes Hash(es), returns original Hash if unsuccessful
|
77
|
+
def instantiate hash, extra_inits={}
|
78
|
+
raise "Expected result Hash, got #{hash}" unless hash.kind_of? Hash
|
79
|
+
if init = hash.values_at(*@singulars).compact.first
|
80
|
+
new init.merge extra_inits
|
81
|
+
elsif inits = hash.values_at(*@plurals).compact.first
|
82
|
+
inits.map {|init| new init.merge extra_inits}
|
65
83
|
else
|
66
84
|
hash
|
67
85
|
end
|
68
86
|
end
|
69
|
-
|
70
|
-
def contains hash, keys
|
71
|
-
keys.inject(nil) {|memo, key| memo ||= hash[key.to_s]}
|
72
|
-
end
|
73
87
|
end
|
74
88
|
|
75
89
|
def get uri, params ={}
|
data/lib/git_hub/commit.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
module GitHub
|
2
2
|
class Commit < Base
|
3
3
|
|
4
|
-
set_resource 'http://github.com/api/v2/yaml/commits', 'commit',
|
4
|
+
set_resource 'http://github.com/api/v2/yaml/commits', 'commit', 'commits'
|
5
5
|
|
6
6
|
attr_accessor :id, :author, :committer, :parents, :url, :committed_date, :authored_date, :message, :tree,
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
# retrieving commit for a specific sha - "/show/:user/:repo/:sha" adds:
|
8
|
+
:added, :modified, :removed,
|
9
|
+
# extra attributes:
|
10
|
+
:user, :repo
|
11
|
+
|
11
12
|
def initialize opts
|
12
13
|
super
|
13
14
|
raise "Unable to initialize #{self.class} without id(sha)" unless sha
|
@@ -22,23 +23,25 @@ module GitHub
|
|
22
23
|
# Find commits, accepts Hash with keys:
|
23
24
|
# :user/:owner/:username:: Github user name
|
24
25
|
# :repo/:repository/:project:: Repo name
|
25
|
-
# :branch::
|
26
|
-
# :path::
|
27
|
-
# :sha/:
|
26
|
+
# :branch:: Only commits for specific branch - default 'master'
|
27
|
+
# :path:: Only commits for specific path
|
28
|
+
# :sha/:id:: Only one commit with specific id (sha)
|
28
29
|
def find(opts)
|
29
|
-
|
30
|
-
|
31
|
-
path = if
|
32
|
-
"/show/#{
|
33
|
-
elsif
|
34
|
-
"/list/#{
|
30
|
+
user, repo, branch, sha, path = extract opts, :user, :repo, :branch, :sha, :path
|
31
|
+
repo_given = branch && user && repo
|
32
|
+
path = if sha && repo_given
|
33
|
+
"/show/#{user}/#{repo}/#{sha}"
|
34
|
+
elsif path && repo_given
|
35
|
+
"/list/#{user}/#{repo}/#{branch}/#{path}"
|
36
|
+
elsif repo_given
|
37
|
+
"/list/#{user}/#{repo}/#{branch}"
|
35
38
|
else
|
36
|
-
"
|
39
|
+
raise "Unable to find #{self.class}(s) for #{opts}"
|
37
40
|
end
|
38
|
-
instantiate get(path)
|
41
|
+
instantiate get(path), :user=>user, :repo=>repo
|
39
42
|
end
|
40
43
|
|
41
|
-
|
44
|
+
alias show find
|
42
45
|
end
|
43
46
|
end
|
44
47
|
|
data/lib/git_hub/repo.rb
CHANGED
@@ -26,26 +26,26 @@ module GitHub
|
|
26
26
|
|
27
27
|
set_resource 'http://github.com/api/v2/yaml/repos', 'repository', 'repositories'
|
28
28
|
|
29
|
-
attr_accessor :name, :
|
29
|
+
attr_accessor :name, :user, :description, :url, :homepage, :open_issues, :watchers, :forks, :fork, :private,
|
30
30
|
# additional attributes from search:
|
31
31
|
:id, :type, :size, :language, :created, :pushed, :score #?
|
32
32
|
|
33
33
|
def initialize options
|
34
34
|
super
|
35
|
-
raise "Unable to initialize #{self.class} without name" unless user && name
|
36
|
-
@url ||= "http://github.com/#{user}/#{name}"
|
35
|
+
raise "Unable to initialize #{self.class} without user and name" unless @user && @name
|
36
|
+
@url ||= "http://github.com/#{@user}/#{@name}"
|
37
37
|
@type ||= "repo"
|
38
|
-
end
|
38
|
+
end
|
39
39
|
|
40
40
|
alias followers= watchers=
|
41
41
|
alias followers watchers
|
42
|
-
alias username=
|
43
|
-
alias username
|
44
|
-
alias
|
45
|
-
alias user
|
42
|
+
alias username= user=
|
43
|
+
alias username user
|
44
|
+
alias owner= user=
|
45
|
+
alias owner user
|
46
46
|
|
47
47
|
def fork?;
|
48
|
-
!!
|
48
|
+
!!fork
|
49
49
|
end
|
50
50
|
|
51
51
|
def private?;
|
@@ -53,22 +53,24 @@ module GitHub
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def clone_url
|
56
|
-
url = private? || api.auth['login'] ==
|
57
|
-
url += "#{
|
56
|
+
url = private? || api.auth['login'] == user ? "git@github.com:" : "git://github.com/"
|
57
|
+
url += "#{@user}/#{@name}.git"
|
58
58
|
end
|
59
59
|
|
60
60
|
def tags
|
61
|
-
|
62
|
-
result['tags'] || result
|
61
|
+
hash_of_commits(:tags)
|
63
62
|
end
|
64
63
|
|
65
64
|
def branches
|
66
|
-
|
67
|
-
result['branches'] || result
|
65
|
+
hash_of_commits(:branches)
|
68
66
|
end
|
69
67
|
|
68
|
+
# Returns commits for this repo, accepts options:
|
69
|
+
# :branch:: Only commits for specific branch - default 'master'
|
70
|
+
# :path:: Only commits for specific path
|
71
|
+
# :sha/:id:: Only one commit with specific id (sha)
|
70
72
|
def commits opts = {}
|
71
|
-
Commit.find opts.merge(:user =>
|
73
|
+
Commit.find opts.merge(:user => @user, :repo => @name)
|
72
74
|
end
|
73
75
|
|
74
76
|
class << self # Repo class methods
|
@@ -78,13 +80,13 @@ module GitHub
|
|
78
80
|
# :repo/:repository/:project/:name:: Repo name
|
79
81
|
# :query/:search:: Array of search terms as Strings or Symbols
|
80
82
|
def find(opts)
|
81
|
-
|
82
|
-
path = if
|
83
|
-
"/search/#{
|
84
|
-
elsif
|
85
|
-
"/show/#{
|
86
|
-
elsif
|
87
|
-
"/show/#{
|
83
|
+
user, repo, query = extract opts, :user, :repo, :query
|
84
|
+
path = if query
|
85
|
+
"/search/#{query.map(&:to_s).join('+')}"
|
86
|
+
elsif user && repo
|
87
|
+
"/show/#{user}/#{repo}"
|
88
|
+
elsif user
|
89
|
+
"/show/#{user}"
|
88
90
|
else
|
89
91
|
raise "Unable to find #{self.class}(s) for #{opts}"
|
90
92
|
end
|
@@ -96,23 +98,23 @@ module GitHub
|
|
96
98
|
|
97
99
|
# Create new github repo, accepts Hash with :repo, :description, :homepage, :public/:private
|
98
100
|
def create(opts)
|
99
|
-
|
101
|
+
repo, desc, homepage, public = extract opts, :repo, :desc, :homepage, :public
|
100
102
|
api.ensure_auth opts
|
101
|
-
instantiate post("/create", 'name' =>
|
102
|
-
'homepage' =>
|
103
|
+
instantiate post("/create", 'name' => repo, 'description' => desc,
|
104
|
+
'homepage' => homepage, 'public' => (public ? 1 : 0))
|
103
105
|
end
|
104
|
-
end
|
106
|
+
end
|
105
107
|
|
106
108
|
# Delete github repo, accepts optional Hash with authentication
|
107
109
|
def delete(opts = {})
|
108
110
|
api.ensure_auth opts
|
109
|
-
result = post("/delete/#{name}")
|
110
|
-
if result['delete_token']
|
111
|
-
post("/delete/#{name}", 'delete_token' =>
|
111
|
+
result = post("/delete/#{@name}")
|
112
|
+
if token = result['delete_token']
|
113
|
+
post("/delete/#{@name}", 'delete_token' => token)
|
112
114
|
else
|
113
115
|
result
|
114
116
|
end
|
115
|
-
end
|
117
|
+
end
|
116
118
|
|
117
119
|
def add_service
|
118
120
|
end
|
@@ -120,12 +122,30 @@ module GitHub
|
|
120
122
|
def remove_service
|
121
123
|
end
|
122
124
|
|
125
|
+
def collaborators
|
126
|
+
'repos/show/:user/:repo/collaborators'
|
127
|
+
end
|
128
|
+
|
123
129
|
def add_collaborator
|
124
130
|
end
|
125
131
|
|
126
132
|
def remove_collaborator
|
127
133
|
end
|
128
134
|
|
135
|
+
private
|
136
|
+
|
137
|
+
def hash_of_commits(resource)
|
138
|
+
result = get "/show/#{@user}/#{@name}/#{resource}"
|
139
|
+
if tagged_shas = result[resource.to_s]
|
140
|
+
tagged_commits = tagged_shas.map do |tag,sha|
|
141
|
+
[tag, Commit.find(:user=>@user, :repo=>@name, :sha=>sha)]
|
142
|
+
end
|
143
|
+
Hash[*tagged_commits.flatten]
|
144
|
+
else
|
145
|
+
result
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
129
149
|
# repos/show/:user/:repo/tags
|
130
150
|
# repos/show/:user/:repo/branches
|
131
151
|
# repos/show/:user/:repo/languages
|
data/lib/git_hub.rb
CHANGED
@@ -2,17 +2,10 @@
|
|
2
2
|
module GitHub
|
3
3
|
|
4
4
|
# :stopdoc:
|
5
|
-
VERSION = '0.0.1'
|
6
5
|
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
7
6
|
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
8
7
|
# :startdoc:
|
9
8
|
|
10
|
-
# Returns the version string for the library.
|
11
|
-
#
|
12
|
-
def self.version
|
13
|
-
VERSION
|
14
|
-
end
|
15
|
-
|
16
9
|
# Returns the library path for the module. If any arguments are given,
|
17
10
|
# they will be joined to the end of the libray path using
|
18
11
|
# <tt>File.join</tt>.
|
@@ -36,8 +29,7 @@ module GitHub
|
|
36
29
|
#
|
37
30
|
def self.require_all_libs_relative_to( fname, dir = nil )
|
38
31
|
dir ||= ::File.basename(fname, '.*')
|
39
|
-
search_me = ::File.expand_path(
|
40
|
-
::File.join(::File.dirname(fname), dir, '**', '*.rb'))
|
32
|
+
search_me = ::File.expand_path(::File.join(::File.dirname(fname), dir, '**', '*.rb'))
|
41
33
|
|
42
34
|
Dir.glob(search_me).sort.each {|rb| require rb}
|
43
35
|
end
|
@@ -45,4 +37,3 @@ module GitHub
|
|
45
37
|
end # module GitHub
|
46
38
|
|
47
39
|
GitHub.require_all_libs_relative_to(__FILE__)
|
48
|
-
|
@@ -2,7 +2,7 @@
|
|
2
2
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
3
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
4
|
<head>
|
5
|
-
<title>Class: GitHub::Api [
|
5
|
+
<title>Class: GitHub::Api [git_hub 0.2.7
|
6
6
|
]</title>
|
7
7
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
8
8
|
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
@@ -92,12 +92,14 @@
|
|
92
92
|
|
93
93
|
<div class="name-list">
|
94
94
|
|
95
|
-
<a href="#
|
95
|
+
<a href="#M000004">auth</a>
|
96
96
|
|
97
|
-
<a href="#
|
97
|
+
<a href="#M000005">authenticated?</a>
|
98
98
|
|
99
99
|
<a href="#M000007">classify</a>
|
100
100
|
|
101
|
+
<a href="#M000006">ensure_auth</a>
|
102
|
+
|
101
103
|
<a href="#M000008">request</a>
|
102
104
|
|
103
105
|
</div>
|
@@ -147,12 +149,12 @@
|
|
147
149
|
<h3 class="section-bar">Public Instance methods</h3>
|
148
150
|
|
149
151
|
|
150
|
-
<div id="method-
|
151
|
-
<a name="
|
152
|
+
<div id="method-M000004" class="method-detail">
|
153
|
+
<a name="M000004"></a>
|
152
154
|
|
153
155
|
<div class="method-heading">
|
154
156
|
|
155
|
-
<a href="#
|
157
|
+
<a href="#M000004" class="method-signature">
|
156
158
|
|
157
159
|
<span class="method-name">auth</span><span class="method-args">()</span>
|
158
160
|
|
@@ -163,8 +165,8 @@
|
|
163
165
|
<div class="method-description">
|
164
166
|
|
165
167
|
<p><a class="source-toggle" href="#"
|
166
|
-
onclick="toggleCode('
|
167
|
-
<div class="method-source-code" id="
|
168
|
+
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
169
|
+
<div class="method-source-code" id="M000004-source">
|
168
170
|
<pre>
|
169
171
|
<span class="ruby-comment cmt"># File lib/git_hub/api.rb, line 10</span>
|
170
172
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">auth</span>
|
@@ -177,12 +179,12 @@
|
|
177
179
|
</div>
|
178
180
|
|
179
181
|
|
180
|
-
<div id="method-
|
181
|
-
<a name="
|
182
|
+
<div id="method-M000005" class="method-detail">
|
183
|
+
<a name="M000005"></a>
|
182
184
|
|
183
185
|
<div class="method-heading">
|
184
186
|
|
185
|
-
<a href="#
|
187
|
+
<a href="#M000005" class="method-signature">
|
186
188
|
|
187
189
|
<span class="method-name">authenticated?</span><span class="method-args">()</span>
|
188
190
|
|
@@ -193,8 +195,8 @@
|
|
193
195
|
<div class="method-description">
|
194
196
|
|
195
197
|
<p><a class="source-toggle" href="#"
|
196
|
-
onclick="toggleCode('
|
197
|
-
<div class="method-source-code" id="
|
198
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
199
|
+
<div class="method-source-code" id="M000005-source">
|
198
200
|
<pre>
|
199
201
|
<span class="ruby-comment cmt"># File lib/git_hub/api.rb, line 14</span>
|
200
202
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">authenticated?</span>
|
@@ -231,7 +233,7 @@ found
|
|
231
233
|
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
232
234
|
<div class="method-source-code" id="M000007-source">
|
233
235
|
<pre>
|
234
|
-
<span class="ruby-comment cmt"># File lib/git_hub/api.rb, line
|
236
|
+
<span class="ruby-comment cmt"># File lib/git_hub/api.rb, line 25</span>
|
235
237
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">classify</span> <span class="ruby-identifier">name</span>
|
236
238
|
<span class="ruby-identifier">klass</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">"::"</span>).<span class="ruby-identifier">inject</span>(<span class="ruby-constant">Kernel</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">klass</span>, <span class="ruby-identifier">const_name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">const_get</span> <span class="ruby-identifier">const_name</span> }
|
237
239
|
<span class="ruby-identifier">klass</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Class</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">klass</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
|
@@ -245,6 +247,38 @@ found
|
|
245
247
|
</div>
|
246
248
|
|
247
249
|
|
250
|
+
<div id="method-M000006" class="method-detail">
|
251
|
+
<a name="M000006"></a>
|
252
|
+
|
253
|
+
<div class="method-heading">
|
254
|
+
|
255
|
+
<a href="#M000006" class="method-signature">
|
256
|
+
|
257
|
+
<span class="method-name">ensure_auth</span><span class="method-args">(opts ={})</span>
|
258
|
+
|
259
|
+
</a>
|
260
|
+
|
261
|
+
</div>
|
262
|
+
|
263
|
+
<div class="method-description">
|
264
|
+
|
265
|
+
<p><a class="source-toggle" href="#"
|
266
|
+
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
267
|
+
<div class="method-source-code" id="M000006-source">
|
268
|
+
<pre>
|
269
|
+
<span class="ruby-comment cmt"># File lib/git_hub/api.rb, line 18</span>
|
270
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ensure_auth</span> <span class="ruby-identifier">opts</span> ={}
|
271
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">authenticated?</span>
|
272
|
+
<span class="ruby-ivar">@auth</span> = {<span class="ruby-value str">'login'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:login</span>], <span class="ruby-value str">'token'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:token</span>]}
|
273
|
+
<span class="ruby-identifier">raise</span>(<span class="ruby-value str">"Authentication failed"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">authenticated?</span>
|
274
|
+
<span class="ruby-keyword kw">end</span>
|
275
|
+
</pre>
|
276
|
+
</div>
|
277
|
+
|
278
|
+
</div>
|
279
|
+
</div>
|
280
|
+
|
281
|
+
|
248
282
|
<div id="method-M000008" class="method-detail">
|
249
283
|
<a name="M000008"></a>
|
250
284
|
|
@@ -264,7 +298,7 @@ found
|
|
264
298
|
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
265
299
|
<div class="method-source-code" id="M000008-source">
|
266
300
|
<pre>
|
267
|
-
<span class="ruby-comment cmt"># File lib/git_hub/api.rb, line
|
301
|
+
<span class="ruby-comment cmt"># File lib/git_hub/api.rb, line 32</span>
|
268
302
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span> <span class="ruby-identifier">verb</span>, <span class="ruby-identifier">url</span>, <span class="ruby-identifier">params</span> = {}
|
269
303
|
<span class="ruby-identifier">method</span> = <span class="ruby-identifier">classify</span>(<span class="ruby-value str">'Net::HTTP::'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">verb</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">capitalize</span>)
|
270
304
|
<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span> <span class="ruby-identifier">url</span>
|