Class: StructuredChangelog::Release

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ Release

Returns a new instance of Release.



15
16
17
# File 'lib/structured_changelog/release.rb', line 15

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

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



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

def contents
  @contents
end

Class Method Details

.patternObject



11
12
13
# File 'lib/structured_changelog/release.rb', line 11

def self.pattern
  /^## RELEASE #{VersionPattern}$/
end

.start_with?(line) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/structured_changelog/release.rb', line 7

def self.start_with?(line)
  line =~ pattern
end

Instance Method Details

#<=>(release) ⇒ Object



33
34
35
# File 'lib/structured_changelog/release.rb', line 33

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

#validateObject



19
20
21
22
23
24
25
# File 'lib/structured_changelog/release.rb', line 19

def validate
  notifications = []

  notifications << "No version number" if version.nil?

  notifications
end

#versionObject



27
28
29
30
31
# File 'lib/structured_changelog/release.rb', line 27

def version
  version_string = contents.match(self.class.pattern)[:version]

  Gem::Version.new(version_string)
end