Class: Octopi::Repository
Constant Summary
Constants inherited
from Base
Base::VALID
Instance Attribute Summary collapse
Attributes inherited from Base
#api
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Resource
for, included
Methods inherited from Base
#initialize, #property, #save
Constructor Details
This class inherits a constructor from Octopi::Base
Instance Attribute Details
#private ⇒ Object
Returns the value of attribute private.
11
12
13
|
# File 'lib/octopi/repository.rb', line 11
def private
@private
end
|
Class Method Details
.create(owner, name, opts = {}) ⇒ Object
97
98
99
100
101
102
103
|
# File 'lib/octopi/repository.rb', line 97
def self.create(owner, name, opts = {})
api = owner.is_a?(User) ? owner.api : ANONYMOUS_API
raise APIError, "To create a repository you must be authenticated." if api.read_only?
self.validate_args(name => :repo)
api.post(path_for(:create), opts.merge(:name => name))
self.find(owner, name, api)
end
|
.find(*args) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/octopi/repository.rb', line 47
def self.find(*args)
api = args.last.is_a?(Api) ? args.pop : ANONYMOUS_API
repo = args.pop
user = args.pop
user = user.login if user.is_a? User
if repo.is_a? Repository
repo = repo.name
user ||= repo.owner
end
self.validate_args(user => :user, repo => :repo)
super user, repo, api
end
|
.find_all(*args) ⇒ Object
62
63
64
65
66
|
# File 'lib/octopi/repository.rb', line 62
def self.find_all(*args)
super args.join(" ").gsub(/ /,'+')
end
|
.find_by_user(user, api = ANONYMOUS_API) ⇒ Object
41
42
43
44
45
|
# File 'lib/octopi/repository.rb', line 41
def self.find_by_user(user, api = ANONYMOUS_API)
user = user.login if user.is_a? User
self.validate_args(user => :user)
find_plural(user, :resource, api)
end
|
.open_issue(args) ⇒ Object
68
69
70
|
# File 'lib/octopi/repository.rb', line 68
def self.open_issue(args)
Issue.open(args[:user], args[:repo], args)
end
|
Instance Method Details
#all_issues ⇒ Object
85
86
87
|
# File 'lib/octopi/repository.rb', line 85
def all_issues
Issue::STATES.map{|state| self.issues(state)}.flatten
end
|
#branches ⇒ Object
Returns all branches for the Repository
Example:
repo = Repository.find("fcoury", "octopi")
repo.branches.each { |r| puts r.name }
19
20
21
|
# File 'lib/octopi/repository.rb', line 19
def branches
Branch.find(self.owner, self.name,api)
end
|
#clone_url ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/octopi/repository.rb', line 33
def clone_url
if private? || api.login == self.owner
"[email protected]:#{self.owner}/#{self.name}.git"
else
"git://github.com/#{self.owner}/#{self.name}.git"
end
end
|
#collaborators ⇒ Object
93
94
95
|
# File 'lib/octopi/repository.rb', line 93
def collaborators
property('collaborators', [self.owner,self.name].join('/')).values
end
|
#commits(branch = "master") ⇒ Object
76
77
78
79
|
# File 'lib/octopi/repository.rb', line 76
def commits(branch = "master")
api = self.api || ANONYMOUS_API
Commit.find_all(self, {:branch => branch}, api)
end
|
#delete ⇒ Object
105
106
107
108
|
# File 'lib/octopi/repository.rb', line 105
def delete
token = @api.post(self.class.path_for(:delete), :id => self.name)['delete_token']
@api.post(self.class.path_for(:delete), :id => self.name, :delete_token => token) unless token.nil?
end
|
#issue(number) ⇒ Object
89
90
91
|
# File 'lib/octopi/repository.rb', line 89
def issue(number)
Issue.find(self, number)
end
|
#issues(state = "open") ⇒ Object
81
82
83
|
# File 'lib/octopi/repository.rb', line 81
def issues(state = "open")
Issue.find_all(self, :state => state)
end
|
#open_issue(args) ⇒ Object
72
73
74
|
# File 'lib/octopi/repository.rb', line 72
def open_issue(args)
Issue.open(self.owner, self, args, @api)
end
|
Returns all tags for the Repository
Example:
repo = Repository.find("fcoury", "octopi")
repo.tags.each { |t| puts t.name }
29
30
31
|
# File 'lib/octopi/repository.rb', line 29
def tags
Tag.find(self.owner, self.name)
end
|