Module: Cardio::Mod::Sow::YamlDump

Included in:
Cardio::Mod::Sow
Defined in:
card/lib/cardio/mod/sow/yaml_dump.rb

Overview

Writing the card representations to yaml files in mod directories

Instance Method Summary collapse

Instance Method Details

#dump(hash) ⇒ Object

write yaml to file



7
8
9
10
# File 'card/lib/cardio/mod/sow/yaml_dump.rb', line 7

def dump hash
  File.write filename, hash.to_yaml
  puts "#{filename} now contains #{hash.size} items".green
end

#filenameString

Returns – MOD_DIR/data/ENVIRONMENT.yml.

Returns:

  • (String)

    – MOD_DIR/data/ENVIRONMENT.yml



13
14
15
# File 'card/lib/cardio/mod/sow/yaml_dump.rb', line 13

def filename
  @filename ||= File.join mod_path, "#{@podtype}.yml"
end

#mod_pathObject

Returns Path.

Returns:

  • Path



18
19
20
21
# File 'card/lib/cardio/mod/sow/yaml_dump.rb', line 18

def mod_path
  Mod.dirs.subpaths("data")[@mod] ||
    raise(Card::Error::NotFound, "no data directory found for mod: #{@mod}")
end