Class: Gub::Repository
- Inherits:
-
Object
- Object
- Gub::Repository
- Defined in:
- lib/gub/repository.rb
Instance Attribute Summary collapse
-
#full_name ⇒ Object
Returns the value of attribute full_name.
-
#info ⇒ Object
Returns the value of attribute info.
Instance Method Summary collapse
- #add_upstream ⇒ Object
- #branches ⇒ Object
- #browse ⇒ Object
- #has_issues? ⇒ Boolean
-
#initialize(full_name) ⇒ Repository
constructor
A new instance of Repository.
- #is_fork? ⇒ Boolean
- #issue(id, action = :fetch, extra_args = nil) ⇒ Object
- #issues(params = {}) ⇒ Object
- #name ⇒ Object
- #owner ⇒ Object
- #parent ⇒ Object
- #sync ⇒ Object
Constructor Details
#initialize(full_name) ⇒ Repository
Returns a new instance of Repository.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/gub/repository.rb', line 5 def initialize full_name self.full_name = full_name # Strip .git from the name self.full_name = self.full_name.split('.').first if self.full_name.nil? || self.full_name.empty? Gub.log.fatal 'Unable to find repo name' exit 1 else Gub.log.debug "Loading information for #{self.full_name}" self.info = Gub.github.repo(repo: self.full_name) end end |
Instance Attribute Details
#full_name ⇒ Object
Returns the value of attribute full_name.
3 4 5 |
# File 'lib/gub/repository.rb', line 3 def full_name @full_name end |
#info ⇒ Object
Returns the value of attribute info.
3 4 5 |
# File 'lib/gub/repository.rb', line 3 def info @info end |
Instance Method Details
#add_upstream ⇒ Object
46 47 48 |
# File 'lib/gub/repository.rb', line 46 def add_upstream Gub.git.remote('add', 'upstream', "https://github.com/#{self.parent}") end |
#branches ⇒ Object
62 63 64 |
# File 'lib/gub/repository.rb', line 62 def branches Gub.git.branch() end |
#browse ⇒ Object
66 67 68 69 |
# File 'lib/gub/repository.rb', line 66 def browse require 'launchy' ::Launchy.open("#{Gub.github.url}#{self.full_name}") end |
#has_issues? ⇒ Boolean
22 23 24 |
# File 'lib/gub/repository.rb', line 22 def has_issues? self.info.has_issues end |
#is_fork? ⇒ Boolean
50 51 52 |
# File 'lib/gub/repository.rb', line 50 def is_fork? self.info.fork end |
#issue(id, action = :fetch, extra_args = nil) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/gub/repository.rb', line 33 def issue id, action = :fetch, extra_args = nil if self.has_issues? name = self.full_name else name = self.parent end Gub::Issue.new(name, id) end |
#issues(params = {}) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/gub/repository.rb', line 26 def issues params = {} issues = [] issues << Gub.github.issues(self.full_name, params) if self.has_issues? issues << Gub.github.issues(self.parent, params) issues.flatten! end |
#name ⇒ Object
18 19 20 |
# File 'lib/gub/repository.rb', line 18 def name self.full_name.split('/').last end |
#owner ⇒ Object
42 43 44 |
# File 'lib/gub/repository.rb', line 42 def owner @full_name.split('/').first end |
#parent ⇒ Object
54 55 56 |
# File 'lib/gub/repository.rb', line 54 def parent self.info.parent.full_name.split('.').first if self.info.parent end |
#sync ⇒ Object
58 59 60 |
# File 'lib/gub/repository.rb', line 58 def sync Gub.git.sync('upstream') end |