Class: Fuselage::Repository
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#fork ⇒ Object
Returns the value of attribute fork.
-
#forks ⇒ Object
Returns the value of attribute forks.
-
#homepage ⇒ Object
Returns the value of attribute homepage.
-
#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.
-
#size ⇒ Object
Returns the value of attribute size.
-
#url ⇒ Object
Returns the value of attribute url.
-
#watchers ⇒ Object
Returns the value of attribute watchers.
Attributes inherited from Base
Class Method Summary collapse
- .create(name, options = {}) ⇒ Object
-
.find(repo, options = {}) ⇒ Object
Finds a repo with current authenticated user.
-
.find_all(options = {}) ⇒ Object
Finds all public repos identified by the given username.
-
.find_by_organization(organization, options = {}) ⇒ Object
Finds all public repos identified by the given organization.
Instance Method Summary collapse
- #branches ⇒ Object
- #commits(options = {}) ⇒ Object
- #create_branch(name, parent_sha) ⇒ Object
- #most_recent_commit(ref_sha) ⇒ Object
- #pp ⇒ Object
- #tags ⇒ Object
- #to_s ⇒ Object
Methods inherited from Base
delete_method, get, #initialize, post
Constructor Details
This class inherits a constructor from Fuselage::Base
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/fuselage/repository.rb', line 4 def description @description end |
#fork ⇒ Object
Returns the value of attribute fork.
4 5 6 |
# File 'lib/fuselage/repository.rb', line 4 def fork @fork end |
#forks ⇒ Object
Returns the value of attribute forks.
4 5 6 |
# File 'lib/fuselage/repository.rb', line 4 def forks @forks end |
#homepage ⇒ Object
Returns the value of attribute homepage.
4 5 6 |
# File 'lib/fuselage/repository.rb', line 4 def homepage @homepage end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/fuselage/repository.rb', line 4 def name @name end |
#open_issues ⇒ Object
Returns the value of attribute open_issues.
4 5 6 |
# File 'lib/fuselage/repository.rb', line 4 def open_issues @open_issues end |
#owner ⇒ Object
Returns the value of attribute owner.
4 5 6 |
# File 'lib/fuselage/repository.rb', line 4 def owner @owner end |
#pledgie ⇒ Object
Returns the value of attribute pledgie.
4 5 6 |
# File 'lib/fuselage/repository.rb', line 4 def pledgie @pledgie end |
#private ⇒ Object
Returns the value of attribute private.
4 5 6 |
# File 'lib/fuselage/repository.rb', line 4 def private @private end |
#size ⇒ Object
Returns the value of attribute size.
4 5 6 |
# File 'lib/fuselage/repository.rb', line 4 def size @size end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/fuselage/repository.rb', line 4 def url @url end |
#watchers ⇒ Object
Returns the value of attribute watchers.
4 5 6 |
# File 'lib/fuselage/repository.rb', line 4 def watchers @watchers end |
Class Method Details
.create(name, options = {}) ⇒ Object
43 44 45 46 |
# File 'lib/fuselage/repository.rb', line 43 def self.create(name, ={}) raise AuthenticationRequired unless Api.authenticated Repository.new(post('/user/repos', {:name => name}.merge())) end |
.find(repo, options = {}) ⇒ Object
Finds a repo with current authenticated user
10 11 12 13 14 15 16 17 18 |
# File 'lib/fuselage/repository.rb', line 10 def self.find(repo, ={}) = {:type => 'all'}.merge() if [:user] Repository.new(get("/repos/#{[:user]}/#{repo}", {:type => [:type]})) else raise AuthenticationRequired unless Api.authenticated Repository.new(get("/repos/#{User.current.login}/#{repo}", {:type => [:type]})) end end |
.find_all(options = {}) ⇒ Object
Finds all public repos identified by the given username
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fuselage/repository.rb', line 22 def self.find_all(={}) = {:type => 'all'}.merge() repos = [] if [:user] get("/users/#{[:user]}/repos", {:type => [:type]}).each { |r| repos << Repository.new(r) } else raise AuthenticationRequired unless Api.authenticated get("/user/repos", {:type => [:type]}).each { |r| repos << Repository.new(r) } end repos end |
.find_by_organization(organization, options = {}) ⇒ Object
Finds all public repos identified by the given organization
36 37 38 39 40 41 |
# File 'lib/fuselage/repository.rb', line 36 def self.find_by_organization(organization, ={}) = {:type => 'all'}.merge() repos = [] get("/orgs/#{organization}/repos", {:type => [:type]}).each { |r| repos << Repository.new(r) } repos end |
Instance Method Details
#branches ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/fuselage/repository.rb', line 63 def branches raise AuthenticationRequired unless Api.authenticated branches = [] Repository.get("/repos/#{User.current.login}/#{self.name}/branches").each do |b| branch = Reference.new branch.ref = 'ref/heads/' + b['name'] branch.url = b['url'] if b['commit'] branch.object = b['commit'] branch.object['type'] = 'commit' end branches << branch end branches end |
#commits(options = {}) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/fuselage/repository.rb', line 79 def commits(={}) raise AuthenticationRequired unless Api.authenticated commits = [] Repository.get("/repos/#{User.current.login}/#{self.name}/commits", ).each do |c| commit = Commit.new(c) if c['commit'] commit.merge_attributes(c['commit']) end commits << commit end commits end |
#create_branch(name, parent_sha) ⇒ Object
97 98 99 |
# File 'lib/fuselage/repository.rb', line 97 def create_branch(name, parent_sha) Reference.create(self.name, "refs/heads/#{name}", parent_sha) end |
#most_recent_commit(ref_sha) ⇒ Object
92 93 94 95 |
# File 'lib/fuselage/repository.rb', line 92 def most_recent_commit(ref_sha) commits = self.commits(:sha => ref_sha) commits.first end |
#pp ⇒ Object
105 106 107 |
# File 'lib/fuselage/repository.rb', line 105 def pp end |
#tags ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fuselage/repository.rb', line 48 def raise AuthenticationRequired unless Api.authenticated = [] Repository.get("/repos/#{User.current.login}/#{self.name}/tags").each do |t| tag = Tag.new tag.tag = t['name'] if t['commit'] tag.object = t['commit'] tag.object['type'] = 'commit' end << tag end end |
#to_s ⇒ Object
101 102 103 |
# File 'lib/fuselage/repository.rb', line 101 def to_s name end |