Class: Naether::Configurator
- Inherits:
-
Object
- Object
- Naether::Configurator
show all
- Defined in:
- lib/naether/configuration.rb
Instance Method Summary
(collapse)
Constructor Details
- (Configurator) initialize(data = {})
A new instance of Configurator
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/naether/configuration.rb', line 4
def initialize(data={})
gem_dir = File.expand_path("#{File.dirname(__FILE__)}/../../")
version = nil
if File.exists?( File.expand_path("#{File.dirname(__FILE__)}/../../VERSION") )
version = IO.read(File.expand_path("#{File.dirname(__FILE__)}/../../VERSION")).strip
else
version = IO.read(File.expand_path("VERSION")).strip
end
@data = {
:gem_dir => gem_dir,
:naether_jar => File.join( gem_dir, "naether-#{version}.jar"),
:platform => ($platform || RUBY_PLATFORM[/java/] || 'ruby'),
:version => version,
:depenencies_yml => File.expand_path("#{File.dirname( __FILE__ )}/../../jar_dependencies.yml")
}
update!(data)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(sym, *args)
49
50
51
52
53
54
55
|
# File 'lib/naether/configuration.rb', line 49
def method_missing(sym, *args)
if sym.to_s =~ /(.+)=$/
self[$1] = args.first
else
self[sym]
end
end
|
Instance Method Details
- (Object) [](key)
37
38
39
|
# File 'lib/naether/configuration.rb', line 37
def [](key)
@data[key.to_sym]
end
|
- (Object) []=(key, value)
41
42
43
44
45
46
47
|
# File 'lib/naether/configuration.rb', line 41
def []=(key, value)
if value.class == Hash
@data[key.to_sym] = Config.new(value)
else
@data[key.to_sym] = value
end
end
|
- (Object) update!(data)
31
32
33
34
35
|
# File 'lib/naether/configuration.rb', line 31
def update!(data)
data.each do |key, value|
self[key] = value
end
end
|