Class: Plugit::Descriptor
- Inherits:
-
Object
- Object
- Plugit::Descriptor
- Defined in:
- lib/plugit/descriptor.rb
Instance Attribute Summary collapse
-
#environments_root_path ⇒ Object
writeonly
Sets the attribute environments_root_path.
Instance Method Summary collapse
- #[](env_name) ⇒ Object
- #environment(*init_args, &block) ⇒ Object
- #environments ⇒ Object
-
#initialize ⇒ Descriptor
constructor
A new instance of Descriptor.
- #install_environment(name) ⇒ Object
Constructor Details
#initialize ⇒ Descriptor
Returns a new instance of Descriptor.
7 8 9 |
# File 'lib/plugit/descriptor.rb', line 7 def initialize @environments = [] end |
Instance Attribute Details
#environments_root_path=(value) ⇒ Object (writeonly)
Sets the attribute environments_root_path
5 6 7 |
# File 'lib/plugit/descriptor.rb', line 5 def environments_root_path=(value) @environments_root_path = value end |
Instance Method Details
#[](env_name) ⇒ Object
11 12 13 |
# File 'lib/plugit/descriptor.rb', line 11 def [](env_name) @environments.detect {|e|e.name == env_name} end |
#environment(*init_args, &block) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/plugit/descriptor.rb', line 15 def environment(*init_args, &block) init_args << File.(@environments_root_path || 'environments') @environments << (env = Environment.new(*init_args)) block.call(EnvironmentBuilder.new(env)) env end |
#environments ⇒ Object
22 23 24 |
# File 'lib/plugit/descriptor.rb', line 22 def environments @environments.dup end |
#install_environment(name) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/plugit/descriptor.rb', line 26 def install_environment(name) env = @environments.detect {|e| e.name == name.to_sym} raise UndefinedEnvironmentError.new(name) unless env env.libraries.each do |lib| lib.update(env) lib.install(env) end end |