Class: StructuredChangelog::Roadmap

Inherits:
Object
  • Object
show all
Defined in:
lib/structured_changelog/roadmap.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ Roadmap

Returns a new instance of Roadmap.



21
22
23
# File 'lib/structured_changelog/roadmap.rb', line 21

def initialize(contents)
  @contents = contents.strip
end

Class Method Details

.patternsObject



9
10
11
12
13
14
15
# File 'lib/structured_changelog/roadmap.rb', line 9

def self.patterns
  [
    /^## ROADMAP #{VersionPattern}$/,
    /^## ROADMAP/,
    /^## NEXT RELEASE/,
  ]
end

.start_with?(line) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/structured_changelog/roadmap.rb', line 5

def self.start_with?(line)
  patterns.any? { |pattern| line =~ pattern }
end

Instance Method Details

#<=>(roadmap) ⇒ Object



17
18
19
# File 'lib/structured_changelog/roadmap.rb', line 17

def <=>(roadmap)
  version <=> roadmap.version
end

#versionObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/structured_changelog/roadmap.rb', line 25

def version
  self.class.patterns.each do |pattern|
    match = contents.match(pattern)

    if match && match.names.include?('version')
      return Gem::Version.new(match[:version])
    end
  end

  Gem::Version.new("")
end