Class: FeduxOrgStdlib::VersionManagement::RubygemVersionFileParser
- Inherits:
-
Object
- Object
- FeduxOrgStdlib::VersionManagement::RubygemVersionFileParser
- Defined in:
- lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
Overview
Ruby version file parser
Instance Attribute Summary collapse
-
#modules ⇒ Object
readonly
Returns the value of attribute modules.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
Instance Attribute Details
#modules ⇒ Object (readonly)
Returns the value of attribute modules.
10 11 12 |
# File 'lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb', line 10 def modules @modules end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb', line 10 def version @version end |
Instance Method Details
#parse(file) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb', line 12 def parse(file) data = File.read(file) @version = data.match(/(?:VERSION|Version)\s+=\s+["']([^'"]+)["']/) { Regexp.last_match[1] } @modules = data.scan(/^\s*module\s+([A-Z][A-Za-z0-9]+(?:::[A-Z][A-Z0-9a-z]+)*)$/x).flatten fail Exceptions::VersionFileInvalid, JSON.dump(file: file) if version.blank? end |