Class: IssueBeaver::Models::Merger
- Inherits:
-
Object
- Object
- IssueBeaver::Models::Merger
- Defined in:
- lib/issue_beaver/models/merger.rb
Instance Method Summary collapse
- #added ⇒ Object
- #changed ⇒ Object
- #closed ⇒ Object
-
#initialize(issues, todos, repo) ⇒ Merger
constructor
A new instance of Merger.
- #merged_issues ⇒ Object
- #modified ⇒ Object
-
#unmatched_issues ⇒ Object
TODO: Tidy up a bit.
Constructor Details
Instance Method Details
#added ⇒ Object
14 15 16 |
# File 'lib/issue_beaver/models/merger.rb', line 14 def added @added ||= merged_issues.select(&:new?) end |
#changed ⇒ Object
24 25 26 |
# File 'lib/issue_beaver/models/merger.rb', line 24 def changed @changed ||= added.merge_left(modified).merge_left(closed, :number) end |
#closed ⇒ Object
29 30 31 |
# File 'lib/issue_beaver/models/merger.rb', line 29 def closed @closed ||= unmatched_issues.select(&:must_close?) end |
#merged_issues ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/issue_beaver/models/merger.rb', line 34 def merged_issues @merged_issues ||= @matcher.matches.map do |todo, issue| if issue if todo.updated_at > issue.updated_at issue.update_attributes(todo.attributes) end else issue = todo end issue end end |
#modified ⇒ Object
19 20 21 |
# File 'lib/issue_beaver/models/merger.rb', line 19 def modified @modified ||= merged_issues.select(&:must_update?) end |
#unmatched_issues ⇒ Object
TODO: Tidy up a bit
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/issue_beaver/models/merger.rb', line 49 def unmatched_issues @unmatched_issues ||= Enumerator.new do |yielder| @issues.to_a.each do |issue| next if merged_issues.to_a.map{|issue| issue.attributes.number }.compact.include? issue.number issue.mark_for_closing if @repo.is_ahead?(issue.commit) yielder << issue end end.memoizing.lazy end |