Class: Senju::Repository
- Inherits:
-
Object
- Object
- Senju::Repository
- Defined in:
- lib/senju/repository.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #changes(no) ⇒ Object
- #client ⇒ Object
- #comments(no) ⇒ Object
-
#initialize(name, options) ⇒ Repository
constructor
A new instance of Repository.
- #issue(no) ⇒ Object
- #issues ⇒ Object
- #pull_request(no) ⇒ Object
- #pull_requests ⇒ Object
Constructor Details
#initialize(name, options) ⇒ Repository
Returns a new instance of Repository.
31 32 33 34 35 |
# File 'lib/senju/repository.rb', line 31 def initialize(name, ) @name = ["repo"] || name @options = @type = ["type"] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/senju/repository.rb', line 15 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'lib/senju/repository.rb', line 15 def @options end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
15 16 17 |
# File 'lib/senju/repository.rb', line 15 def type @type end |
Class Method Details
.all ⇒ Object
17 18 19 20 21 |
# File 'lib/senju/repository.rb', line 17 def self.all Senju::Repos.new.data.map do |repository, config| new(repository, config) end end |
.find(name) ⇒ Object
27 28 29 |
# File 'lib/senju/repository.rb', line 27 def self.find(name) new(name, Senju::Repos.new[name]) end |
.first ⇒ Object
23 24 25 |
# File 'lib/senju/repository.rb', line 23 def self.first all.first end |
Instance Method Details
#changes(no) ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/senju/repository.rb', line 68 def changes(no) case type when "github" then list = client.pull_request_files(name, no) when "gitlab" then list = client.merge_request_changes(name, no).changes end list.map do |raw| Senju::Change.new(raw, type) end end |
#client ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/senju/repository.rb', line 37 def client credential = Senju::Credential.find(type) case type when "github" then Senju::Github.new(credential) when "gitlab" then Senju::Gitlab.new(credential) when "trello" then Senju::Trello.new(credential) end end |
#comments(no) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/senju/repository.rb', line 57 def comments(no) case type when "github" then list = client.issue_comments(name, no) when "gitlab" then list = client.issue_notes(name, no) end list.map do |raw| Senju::Comment.new(raw, type) end end |
#issue(no) ⇒ Object
46 47 48 |
# File 'lib/senju/repository.rb', line 46 def issue(no) Senju::Issue.new(client.issue(name, no), type) end |
#issues ⇒ Object
79 80 81 82 83 |
# File 'lib/senju/repository.rb', line 79 def issues client.issues(name).map do |raw| Senju::Issue.new(raw, type) end end |