Class: Simp::ComponentInfo

Inherits:
Object
  • Object
show all
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 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
/^\*\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*$/

Instance Attribute Summary collapse

Instance Method Summary collapse

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 .json file
release:     Not set
changelog:   Array of valid changelog entries derived from the
             CHANGELOG file

Asset

 version:     Primary Version tag from build/<component>.spec
 release:     Primary Release tag from build/<component>.spec
 changelog:   Array of valid changelog entries derived from the
              contents of the %changelog section in
              build/<component>.spec.  Will be an empty if
              changelog is not present.

NOTES:
1.  The changelog is only parsed up to the first entry that
    fails basic validation.
    - First line must be of the form
       * {date string} {author info} - {version}
       * {date string} {author info} - {version}-{release}

      where,
       date string =  {weekday} {month} {day} {year}
       author info =  {author name} <{author 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 `%changelog`
     format 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.
2.  When RPM spec files contain sub-packages, only the primary
    package information is returned.
3.  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_dir

The root directory of the component project.

latest_version_only

Whether to only return the changelog

entries for  the latest version
verbose

Whether to log a changelog validation failure



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/simp/componentinfo.rb', line 85

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

#changelogObject

Returns the value of attribute changelog.



8
9
10
# File 'lib/simp/componentinfo.rb', line 8

def changelog
  @changelog
end

#component_dirObject

Returns the value of attribute component_dir.



8
9
10
# File 'lib/simp/componentinfo.rb', line 8

def component_dir
  @component_dir
end

#releaseObject

Returns the value of attribute release.



8
9
10
# File 'lib/simp/componentinfo.rb', line 8

def release
  @release
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/simp/componentinfo.rb', line 8

def type
  @type
end

#versionObject

Returns the value of attribute version.



8
9
10
# File 'lib/simp/componentinfo.rb', line 8

def version
  @version
end