Class: StepUp::RangedNotes
- Inherits:
-
Object
- Object
- StepUp::RangedNotes
- Defined in:
- lib/step-up/ranged_notes.rb
Constant Summary collapse
- COMMIT_NOTE =
0
- NOTE =
1
Instance Attribute Summary collapse
-
#driver ⇒ Object
readonly
Returns the value of attribute driver.
-
#first_commit ⇒ Object
readonly
Returns the value of attribute first_commit.
-
#last_commit ⇒ Object
readonly
Returns the value of attribute last_commit.
Instance Method Summary collapse
- #all_commits ⇒ Object
- #all_notes ⇒ Object
-
#initialize(driver, first_commit = nil, last_commit = "HEAD", options = {}) ⇒ RangedNotes
constructor
A new instance of RangedNotes.
- #notes ⇒ Object
- #notes_of(commit) ⇒ Object
- #scoped_commits ⇒ Object
- #scoped_tags ⇒ Object
Constructor Details
#initialize(driver, first_commit = nil, last_commit = "HEAD", options = {}) ⇒ RangedNotes
Returns a new instance of RangedNotes.
8 9 10 11 12 13 14 15 16 |
# File 'lib/step-up/ranged_notes.rb', line 8 def initialize(driver, first_commit = nil, last_commit = "HEAD", ={}) @include_initial_tag_notes = ![:exclude_initial_tag_notes] @notes_sections = notes_sections([:notes_sections]) @driver = driver @last_commit = driver.commit_history(last_commit, 1).first first_commit = driver.commit_history(first_commit, 1).first unless first_commit.nil? raise ArgumentError, "The object #{ first_commit.inspect } was not found" unless first_commit.nil? || all_commits.include?(first_commit) @first_commit = first_commit end |
Instance Attribute Details
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
6 7 8 |
# File 'lib/step-up/ranged_notes.rb', line 6 def driver @driver end |
#first_commit ⇒ Object (readonly)
Returns the value of attribute first_commit.
6 7 8 |
# File 'lib/step-up/ranged_notes.rb', line 6 def first_commit @first_commit end |
#last_commit ⇒ Object (readonly)
Returns the value of attribute last_commit.
6 7 8 |
# File 'lib/step-up/ranged_notes.rb', line 6 def last_commit @last_commit end |
Instance Method Details
#all_commits ⇒ Object
30 31 32 |
# File 'lib/step-up/ranged_notes.rb', line 30 def all_commits @all_commits ||= driver.commit_history(last_commit) end |
#all_notes ⇒ Object
22 23 24 |
# File 'lib/step-up/ranged_notes.rb', line 22 def all_notes (visible_detached_notes + scoped_commit_notes + scoped_attached_notes).sort.reverse.extend NotesArray end |
#notes ⇒ Object
18 19 20 |
# File 'lib/step-up/ranged_notes.rb', line 18 def notes (visible_detached_notes + scoped_commit_notes).sort.reverse.extend NotesArray end |
#notes_of(commit) ⇒ Object
26 27 28 |
# File 'lib/step-up/ranged_notes.rb', line 26 def notes_of(commit) all_visible_notes.select{ |note| note[3] == commit }.extend NotesArray end |
#scoped_commits ⇒ Object
34 35 36 |
# File 'lib/step-up/ranged_notes.rb', line 34 def scoped_commits @scoped_commits ||= driver.commits_between(first_commit, last_commit, :with_messages => true).compact end |
#scoped_tags ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/step-up/ranged_notes.rb', line 38 def unless defined? @scoped_tags = [] commits = scoped_commits.collect(&:first) = driver. unless .empty? .each do |version_tag| object = driver.commit_history(version_tag, 1).first << version_tag if commits.include?(object) end if !.empty? && include_initial_tag_notes? initial_tag_version_position = .index(.last).next initial_tag_version = [initial_tag_version_position] << initial_tag_version if initial_tag_version end end @scoped_tags = end @scoped_tags end |