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.
18 19 20 21 22 |
# File 'lib/senju/repository.rb', line 18 def initialize(name, ) @name = ["repo"] || name @options = @type = ["type"] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/senju/repository.rb', line 2 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
2 3 4 |
# File 'lib/senju/repository.rb', line 2 def @options end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
2 3 4 |
# File 'lib/senju/repository.rb', line 2 def type @type end |
Class Method Details
.all ⇒ Object
4 5 6 7 8 |
# File 'lib/senju/repository.rb', line 4 def self.all Senju::Projects.data.map do |repository, config| new(repository, config) end end |
.find(name) ⇒ Object
14 15 16 |
# File 'lib/senju/repository.rb', line 14 def self.find(name) new(name, Senju::Projects[name]) end |
.first ⇒ Object
10 11 12 |
# File 'lib/senju/repository.rb', line 10 def self.first all.first end |
Instance Method Details
#changes(no) ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/senju/repository.rb', line 67 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
24 25 26 27 28 29 30 31 |
# File 'lib/senju/repository.rb', line 24 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
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/senju/repository.rb', line 56 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
45 46 47 |
# File 'lib/senju/repository.rb', line 45 def issue(no) Senju::Issue.new(client.issue(name, no), type) end |
#issues ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/senju/repository.rb', line 33 def issues if type == "github" client.issues(name, labels: ["label"], assignee: ["assignee"]).map do |raw| Senju::Issue.new(raw, type) end else client.issues(name).map do |raw| Senju::Issue.new(raw, type) end end end |