Class: Simp::ComponentInfo
- Inherits:
-
Object
- Object
- Simp::ComponentInfo
- Defined in:
- lib/simp/componentinfo.rb
Overview
Class that provides component version, release, and changelog information
Constant Summary collapse
- ERR_MARKER =
A helpful method for ensuring that the errors can be easily seen
'WARNING: !!! '- CHANGELOG_ENTRY_REGEX =
See https://fedoraproject.org/wiki/Packaging:Guidelines?rd=Packaging/Guidelines#Changelogs When matched against this regex match 1 = date of the form weekday month day year match 2 = author of the form name <email> match 3 = version match 4 = optional release qualifier; nil when absent
%r{^\*\s+((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-3]{1}[0-9]{1} \d{4})\s+(.+<.+>)(?:\s+|\s*-\s*)(\d+\.\d+\.\d+)(?:-(\S+))?\s*$}.freeze
Instance Attribute Summary collapse
-
#changelog ⇒ Object
Returns the value of attribute changelog.
-
#component_dir ⇒ Object
Returns the value of attribute component_dir.
-
#release ⇒ Object
Returns the value of attribute release.
-
#type ⇒ Object
Returns the value of attribute type.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(component_dir, latest_version_only = false, verbose = true) ⇒ ComponentInfo
constructor
Load component information from appropriate component files.
Constructor Details
#initialize(component_dir, latest_version_only = false, verbose = true) ⇒ ComponentInfo
Load component information from appropriate component files
Module version: Top-level 'version' key from the metadata.json file release: Not set changelog: Array of valid changelog entries derived from the CHANGELOG file
Asset
version: Primary Version tag from build/
NOTES:
-
The changelog is only parsed up to the first entry that fails basic validation.
-
First line must be of the form
where, date string = weekday month day year author info = name <email>
-
Weekday must be correct for the specified date
-
Entries must be separated by a blank line
NOTE: This currently does not support the valid RPM
%changelogformat that places the version number on the next line:- Fri Mar 02 2012 Maintenance 4.0.0-2
- Improved test stubs.
However, since we are not using this form for recent changelogs and we stop processing upon reaching such a changelog entry, this should not be an issue.
-
-
When RPM spec files contain sub-packages, only the primary package information is returned.
-
Some assets have another version in a lib/.../version.rb. Since there is no definitive way for this code to determine that version, it will not be loaded here.
Fails if any of the following occur:
- The metadata.json file for a Puppet module component cannot be parsed.
- A top-level 'version' key does not exist in the metadata.json file.
- The CHANGELOG file for a Puppet module component does not exist.
- The RPM spec file for a non-Puppet module component does not exist.
- More than 1 RPM spec file for a non-Puppet module component exists.
- The version, release or changelog cannot be extracted from the RPM spec file for a non-Puppet module.
- Any changelog entry below the first entry has a version greater than that of the first entry. Changelog entries must be ordered from latest version to earliest version.
- The changelog entries are out of date order.
component_dirThe root directory of the component project.
latest_version_onlyWhether to only return the changelog
entries for the latest version
verboseWhether to log a changelog validation failure
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/simp/componentinfo.rb', line 88 def initialize(component_dir, latest_version_only = false, verbose = true) @component_dir = component_dir if File.exist?(File.join(@component_dir, 'metadata.json')) @type = :module load_module_info(latest_version_only, verbose) else @type = :asset load_asset_info(latest_version_only, verbose) end end |
Instance Attribute Details
#changelog ⇒ Object
Returns the value of attribute changelog.
11 12 13 |
# File 'lib/simp/componentinfo.rb', line 11 def changelog @changelog end |
#component_dir ⇒ Object
Returns the value of attribute component_dir.
11 12 13 |
# File 'lib/simp/componentinfo.rb', line 11 def component_dir @component_dir end |
#release ⇒ Object
Returns the value of attribute release.
11 12 13 |
# File 'lib/simp/componentinfo.rb', line 11 def release @release end |
#type ⇒ Object
Returns the value of attribute type.
11 12 13 |
# File 'lib/simp/componentinfo.rb', line 11 def type @type end |
#version ⇒ Object
Returns the value of attribute version.
11 12 13 |
# File 'lib/simp/componentinfo.rb', line 11 def version @version end |