Class: Roll::Metadata
- Inherits:
-
Object
- Object
- Roll::Metadata
- Defined in:
- lib/roll/metadata.rb
Overview
– TODO: Use POM? If available? –
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
TODO: hide most methods.
Instance Method Summary collapse
-
#active ⇒ Object
Get library active state.
-
#initialize(location) ⇒ Metadata
constructor
A new instance of Metadata.
-
#loadpath ⇒ Object
Get library loadpath.
- #method_missing(name, *args) ⇒ Object
-
#name ⇒ Object
Get library name.
-
#released ⇒ Object
Get library release date.
- #requires ⇒ Object
-
#version ⇒ Object
Get library version.
Constructor Details
#initialize(location) ⇒ Metadata
Returns a new instance of Metadata.
13 14 15 16 |
# File 'lib/roll/metadata.rb', line 13 def initialize(location) @location = location @cache = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/roll/metadata.rb', line 76 def method_missing(name, *args) if @cache.key?(name) @cache[name] else @cache[name] = read(name) end end |
Instance Attribute Details
#location ⇒ Object (readonly)
TODO: hide most methods
10 11 12 |
# File 'lib/roll/metadata.rb', line 10 def location @location end |
Instance Method Details
#active ⇒ Object
Get library active state.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/roll/metadata.rb', line 33 def active return @cache[:active] if @cache.key?(:active) @cache[:active] = ( case read(:active).to_s.downcase when 'false', 'no' false else true end ) end |
#loadpath ⇒ Object
Get library loadpath.
54 55 56 57 58 59 60 |
# File 'lib/roll/metadata.rb', line 54 def loadpath @cache[:loadpath] ||= ( val = read(:loadpath).to_s.strip.split(/\s*\n/) # TODO: handle YAML val = ['lib'] if val.empty? val ) end |
#name ⇒ Object
Get library name.
19 20 21 |
# File 'lib/roll/metadata.rb', line 19 def name @cache[:name] ||= read('name') end |
#released ⇒ Object
Get library release date. – TODO: default date to what? ++
49 50 51 |
# File 'lib/roll/metadata.rb', line 49 def released @cache[:released] ||= read(:released) || "1900-01-01" end |
#requires ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/roll/metadata.rb', line 63 def requires @cache[:requires] ||= ( if entry = read(:requires) entry.strip.split("\n").map do |line| line.strip.split(/\s+/) end else [] end ) end |
#version ⇒ Object
Get library version. – TODO: handle VERSION file TODO: handle YAML ++
28 29 30 |
# File 'lib/roll/metadata.rb', line 28 def version @cache[:version] ||= Version.new(read(:version)) end |