Module: ReleaseNotes::Versioning

Defined in:
lib/release_notes/versioning.rb,
lib/release_notes/versioning/semantic.rb

Defined Under Namespace

Modules: Semantic

Class Method Summary collapse

Class Method Details

.current_version_number(dirname) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/release_notes/versioning.rb', line 6

def current_version_number(dirname)
  last_timestamp = version_lookup_at(dirname).collect do |file|
    File.basename(file).split("_").first.to_i
  end.max.to_i

  last_version = Dir.glob("#{dirname}/#{last_timestamp}_*").to_s.split('/').last
  last_version = last_version.gsub(last_version[0..14], '')[0..-3].gsub('_', '.')

  if last_version.empty?
    return nil
  else
    return last_version
  end        
end

.version_lookup_at(dirname) ⇒ Object



21
22
23
# File 'lib/release_notes/versioning.rb', line 21

def version_lookup_at(dirname)
  Dir.glob("#{dirname}/[0-9]*_*")
end