Module: Dployr::Config::Create

Includes:
Constants
Defined in:
lib/dployr/config/create.rb

Constant Summary collapse

RB_CONTENT =
"Dployr::configure do |dployr|\n  dployr.config.set_default({\n    attributes: {\n      instance_type: \"m1.medium\"\n    }\n  })\n\n  dployr.config.add_instance('name', {\n    scripts: [\n      { path: 'path/to/script.sh' }\n    ]\n  })\nend\n"
YAML_CONTENT =
"default:\n  attributes:\n    instance_type: m1.medium\ninstance:\n  attributes:\n    name: my_instance\n  scripts:\n    -\n      path: path/to/script.sh\n"

Constants included from Constants

Dployr::Config::Constants::EXTENSIONS, Dployr::Config::Constants::FILENAME, Dployr::Config::Constants::FILENAMES

Class Method Summary collapse

Class Method Details

.write_file(dir = Dir.pwd, type = 'rb') ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/dployr/config/create.rb', line 39

def write_file(dir = Dir.pwd, type = 'rb')
  yaml = type == 'yaml'
  file_name = FILENAME
  file_name += ".yaml" if yaml
  content = yaml ? YAML_CONTENT : RB_CONTENT
  begin
    file = File.open "#{dir}/#{FILENAME}", "w"
    file.write content
  rescue IOError => e
    raise e
  ensure
    file.close unless file == nil
  end
end