Class: Octopi::Repository
- Includes:
- Resource
- Defined in:
- lib/octopi/repository.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#created ⇒ Object
Returns the value of attribute created.
-
#description ⇒ Object
Returns the value of attribute description.
-
#followers ⇒ Object
Returns the value of attribute followers.
-
#fork ⇒ Object
Returns the value of attribute fork.
-
#forks ⇒ Object
Returns the value of attribute forks.
-
#homepage ⇒ Object
Returns the value of attribute homepage.
-
#id ⇒ Object
Returns the value of attribute id.
-
#language ⇒ Object
Returns the value of attribute language.
-
#name ⇒ Object
Returns the value of attribute name.
-
#open_issues ⇒ Object
Returns the value of attribute open_issues.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#pledgie ⇒ Object
Returns the value of attribute pledgie.
-
#private ⇒ Object
Returns the value of attribute private.
-
#pushed ⇒ Object
Returns the value of attribute pushed.
-
#score ⇒ Object
Returns the value of attribute score.
-
#size ⇒ Object
Returns the value of attribute size.
-
#type ⇒ Object
Returns the value of attribute type.
-
#url ⇒ Object
Returns the value of attribute url.
-
#username ⇒ Object
Returns the value of attribute username.
-
#watchers ⇒ Object
Returns the value of attribute watchers.
Attributes inherited from Base
Class Method Summary collapse
- .create(options = {}) ⇒ Object
- .find(options = {}) ⇒ Object
- .find_all(*args) ⇒ Object (also: search)
Instance Method Summary collapse
- #all_issues ⇒ Object
-
#branches ⇒ Object
Returns all branches for the Repository.
- #clone_url ⇒ Object
- #collaborators ⇒ Object
-
#comments ⇒ Object
Returns all the comments for a Repository.
- #commits(branch = "master") ⇒ Object
- #delete! ⇒ Object
- #issue(number) ⇒ Object
- #issues(state = "open") ⇒ Object
-
#tags ⇒ Object
Returns all tags for the Repository.
- #to_s ⇒ Object
Methods included from Resource
Methods inherited from Base
#error=, #initialize, #property, #save
Constructor Details
This class inherits a constructor from Octopi::Base
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def actions @actions end |
#created ⇒ Object
Returns the value of attribute created.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def created @created end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def description @description end |
#followers ⇒ Object
Returns the value of attribute followers.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def followers @followers end |
#fork ⇒ Object
Returns the value of attribute fork.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def fork @fork end |
#forks ⇒ Object
Returns the value of attribute forks.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def forks @forks end |
#homepage ⇒ Object
Returns the value of attribute homepage.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def homepage @homepage end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def id @id end |
#language ⇒ Object
Returns the value of attribute language.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def language @language end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def name @name end |
#open_issues ⇒ Object
Returns the value of attribute open_issues.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def open_issues @open_issues end |
#owner ⇒ Object
Returns the value of attribute owner.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def owner @owner end |
#pledgie ⇒ Object
Returns the value of attribute pledgie.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def pledgie @pledgie end |
#private ⇒ Object
Returns the value of attribute private.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def private @private end |
#pushed ⇒ Object
Returns the value of attribute pushed.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def pushed @pushed end |
#score ⇒ Object
Returns the value of attribute score.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def score @score end |
#size ⇒ Object
Returns the value of attribute size.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def size @size end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def url @url end |
#username ⇒ Object
Returns the value of attribute username.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def username @username end |
#watchers ⇒ Object
Returns the value of attribute watchers.
4 5 6 |
# File 'lib/octopi/repository.rb', line 4 def watchers @watchers end |
Class Method Details
.create(options = {}) ⇒ Object
113 114 115 116 117 |
# File 'lib/octopi/repository.rb', line 113 def self.create(={}) raise AuthenticationRequired, "To create a repository you must be authenticated." if Api.api.read_only? self.validate_args([:name] => :repo) new(Api.api.post(path_for(:create), )["repository"]) end |
.find(options = {}) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/octopi/repository.rb', line 70 def self.find(={}) ensure_hash() # Lots of people call the same thing differently. # Can't call gather_details here because this method is used by it internally. repo = [:repo] || [:repository] || [:name] user = [:user].to_s return find_plural(user, :resource) if repo.nil? self.validate_args(user => :user, repo => :repo) super user, repo end |
.find_all(*args) ⇒ Object Also known as: search
83 84 85 86 87 |
# File 'lib/octopi/repository.rb', line 83 def self.find_all(*args) # FIXME: This should be URI escaped, but have to check how the API # handles escaped characters first. super args.join(" ").gsub(/ /,'+') end |
Instance Method Details
#all_issues ⇒ Object
101 102 103 |
# File 'lib/octopi/repository.rb', line 101 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 }
28 29 30 |
# File 'lib/octopi/repository.rb', line 28 def branches Branch.all(:user => self.owner, :repo => self) end |
#clone_url ⇒ Object
65 66 67 68 |
# File 'lib/octopi/repository.rb', line 65 def clone_url url = private || Api.api.login == self.owner.login ? "[email protected]:" : "git://github.com/" url += "#{self.owner}/#{self.name}.git" end |
#collaborators ⇒ Object
109 110 111 |
# File 'lib/octopi/repository.rb', line 109 def collaborators property('collaborators', [self.owner, self.name].join('/')).values.map { |v| User.find(v.join) } end |
#comments ⇒ Object
Returns all the comments for a Repository
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/octopi/repository.rb', line 44 def comments path = "http#{'s' if private}://github.com/#{owner}/#{name}/comments.atom" xml = Crack::XML.parse(Net::HTTP.get(URI.parse(path))) # handle crack not always returning an array entries = [xml["feed"]["entry"]].flatten comments = entries.map do |entry| Comment.new( :id => entry["id"], :published => Time.parse(entry["published"]), :updated => Time.parse(entry["updated"]), :link => entry["link"]["href"], :title => entry["title"], :content => entry["content"].gsub("<", "<").gsub(">", ">"), :author => entry["author"]["name"], :repository => self ) end end |
#commits(branch = "master") ⇒ Object
93 94 95 |
# File 'lib/octopi/repository.rb', line 93 def commits(branch = "master") Commit.find_all(:user => self.owner, :repo => self, :branch => branch) end |
#delete! ⇒ Object
119 120 121 122 123 |
# File 'lib/octopi/repository.rb', line 119 def delete! raise APIError, "You must be authenticated as the owner of this repository to delete it" if Api.me.login != owner.login token = Api.api.post(self.class.path_for(:delete), :id => self.name)['delete_token'] Api.api.post(self.class.path_for(:delete), :id => self.name, :delete_token => token) unless token.nil? end |
#issue(number) ⇒ Object
105 106 107 |
# File 'lib/octopi/repository.rb', line 105 def issue(number) Issue.find(:user => self.owner, :repo => self, :number => number) end |
#issues(state = "open") ⇒ Object
97 98 99 |
# File 'lib/octopi/repository.rb', line 97 def issues(state = "open") IssueSet.new(Octopi::Issue.find_all(:user => owner, :repository => self)) end |
#tags ⇒ Object
Returns all tags for the Repository
Example:
repo = Repository.find("fcoury", "octopi")
repo..each { |t| puts t.name }
38 39 40 |
# File 'lib/octopi/repository.rb', line 38 def Tag.all(:user => self.owner, :repo => self) end |
#to_s ⇒ Object
125 126 127 |
# File 'lib/octopi/repository.rb', line 125 def to_s name end |