Class: RubyConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-config.rb

Constant Summary collapse

VERSION =
'0.0.1'
LIBPATH =
::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
PATH =
::File.dirname(LIBPATH) + ::File::SEPARATOR

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.libpath(*args) ⇒ Object



16
17
18
# File 'lib/ruby-config.rb', line 16

def self.libpath( *args )
  args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
end

.path(*args) ⇒ Object



20
21
22
# File 'lib/ruby-config.rb', line 20

def self.path( *args )
  args.empty? ? PATH : ::File.join(PATH, args.flatten)
end

.versionObject



12
13
14
# File 'lib/ruby-config.rb', line 12

def self.version
  VERSION
end

Instance Method Details

#add_option(*args, &block) ⇒ Object

Original the add_choice method from user-choice



39
40
41
42
# File 'lib/ruby-config.rb', line 39

def add_option(*args, &block)
  self.options << args.first
  self.builder.add_choice(*args, &block)
end

#add_source(*args) ⇒ Object



34
35
36
# File 'lib/ruby-config.rb', line 34

def add_source(*args)
  self.builder.add_source(*args)
end

#add_subconfig(config_name) ⇒ Object

Adds a method to the RubyConfig object which is another RubyConfig object This way you can add subconfigs (plugins?) to a base config



26
27
28
29
# File 'lib/ruby-config.rb', line 26

def add_subconfig(config_name)
  define_config_methods(config_name)
  self.send("#{config_name}=", RubyConfig.new)
end

#buildObject

Get the yaml, parameter, etc. parameters and put them in conf-methodss



45
46
47
48
# File 'lib/ruby-config.rb', line 45

def build
  builder_values = builder.build
  self.use_values(builder_values)
end