Module: Trireme

Defined in:
lib/trireme.rb,
lib/trireme/actions.rb,
lib/trireme/version.rb,
lib/trireme/app_builder.rb,
lib/trireme/generators/app_generator.rb

Defined Under Namespace

Modules: Actions Classes: AppBuilder, AppGenerator

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.configObject



30
31
32
# File 'lib/trireme.rb', line 30

def self.config
  @config
end

.configure(opts = {}) ⇒ Object



14
15
16
# File 'lib/trireme.rb', line 14

def self.configure(opts = {})
  symbolize_keys(opts).each { |k, v| @config[k] = v } # if @valid_config_keys.include? k.to_sym}
end

.configure_with(path_to_yaml_file) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/trireme.rb', line 18

def self.configure_with(path_to_yaml_file)
  begin
    config = YAML::load(IO.read(path_to_yaml_file))
  rescue Errno::ENOENT
    puts "YAML configuration file couldn't be found. Using defaults."; return
  rescue Psych::SyntaxError
    puts "YAML configuration file contains invalid syntax. Using defaults."; return
  end

  configure(config)
end

.symbolize_keys(hash) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/trireme.rb', line 34

def self.symbolize_keys(hash)
  hash.inject({}){|result, (key, value)|
    new_key = case key
              when String then key.to_sym
              else key
              end
    new_value = case value
                when Hash then symbolize_keys(value)
                else value
                end
    result[new_key] = new_value
    result
  }
end