Class: Plugit::Descriptor

Inherits:
Object
  • Object
show all
Defined in:
lib/plugit/descriptor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDescriptor

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

Parameters:

  • value

    the value to set the attribute environments_root_path to.



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.expand_path(@environments_root_path || 'environments')
  @environments << (env = Environment.new(*init_args))
  block.call(EnvironmentBuilder.new(env))
  env
end

#environmentsObject



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