Class: Fig::Package
- Inherits:
-
Object
- Object
- Fig::Package
- Defined in:
- lib/fig/package.rb
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#package_name ⇒ Object
readonly
Returns the value of attribute package_name.
-
#statements ⇒ Object
readonly
Returns the value of attribute statements.
-
#version_name ⇒ Object
readonly
Returns the value of attribute version_name.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](config_name) ⇒ Object
- #archive_urls ⇒ Object
-
#initialize(package_name, version_name, directory, statements) ⇒ Package
constructor
A new instance of Package.
- #publish_statements ⇒ Object
- #resource_urls ⇒ Object
- #retrieves ⇒ Object
- #unparse ⇒ Object
Constructor Details
#initialize(package_name, version_name, directory, statements) ⇒ Package
Returns a new instance of Package.
5 6 7 8 9 10 |
# File 'lib/fig/package.rb', line 5 def initialize(package_name, version_name, directory, statements) @package_name = package_name @version_name = version_name @directory = directory @statements = statements end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
3 4 5 |
# File 'lib/fig/package.rb', line 3 def directory @directory end |
#package_name ⇒ Object (readonly)
Returns the value of attribute package_name.
3 4 5 |
# File 'lib/fig/package.rb', line 3 def package_name @package_name end |
#statements ⇒ Object (readonly)
Returns the value of attribute statements.
3 4 5 |
# File 'lib/fig/package.rb', line 3 def statements @statements end |
#version_name ⇒ Object (readonly)
Returns the value of attribute version_name.
3 4 5 |
# File 'lib/fig/package.rb', line 3 def version_name @version_name end |
Instance Method Details
#==(other) ⇒ Object
42 43 44 |
# File 'lib/fig/package.rb', line 42 def ==(other) @package_name == other.package_name && @version_name == other.version_name && @statements.to_yaml == other.statements.to_yaml end |
#[](config_name) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/fig/package.rb', line 12 def [](config_name) @statements.each do |stmt| return stmt if stmt.is_a?(Configuration) && stmt.name == config_name end raise "Configuration not found: #{@package_name}/#{@version_name}:#{config_name}" end |
#archive_urls ⇒ Object
24 25 26 |
# File 'lib/fig/package.rb', line 24 def archive_urls @statements.select{|s| s.is_a?(Archive)}.map{|s|s.url} end |
#publish_statements ⇒ Object
32 33 34 35 36 |
# File 'lib/fig/package.rb', line 32 def publish_statements statements = [] @statements.each{ |s| statements += s.statements if s.is_a?(Publish) } statements end |
#resource_urls ⇒ Object
28 29 30 |
# File 'lib/fig/package.rb', line 28 def resource_urls @statements.select{|s| s.is_a?(Resource)}.map{|s|s.url} end |
#retrieves ⇒ Object
19 20 21 22 23 |
# File 'lib/fig/package.rb', line 19 def retrieves retrieves = {} statements.each { |statement| retrieves[statement.var] = statement.path if statement.is_a?(Retrieve) } retrieves end |
#unparse ⇒ Object
38 39 40 |
# File 'lib/fig/package.rb', line 38 def unparse @statements.map { |statement| statement.unparse('') }.join("\n") end |