Class: Cardio::Mod::Sow

Inherits:
Object
  • Object
show all
Includes:
CardSource, YamlDump
Defined in:
lib/cardio/mod/sow.rb,
lib/cardio/mod/sow/yaml_dump.rb,
lib/cardio/mod/sow/card_source.rb

Overview

The Sow class is for exporting data to mods’ data directories so that they can be used as seed data when the mod is installed.

docs.google.com/document/d/13K_ynFwfpHwc3t5gnLeAkZJZHco1wK063nJNYwU8qfc/edit#

Defined Under Namespace

Modules: CardSource, YamlDump

Instance Method Summary collapse

Methods included from CardSource

#cards, #cards_from_name, #field_tag_marks, #item_cards, #main_cards, #new_data_from_cards, #require_card

Methods included from YamlDump

#dump, #filename, #mod_path

Constructor Details

#initialize(**args) ⇒ Sow

Returns a new instance of Sow.



11
12
13
14
15
16
17
18
19
# File 'lib/cardio/mod/sow.rb', line 11

def initialize **args
  @mod = args[:mod]
  @name = args[:name]
  @cql = args[:cql]
  @url = args[:url]
  @podtype = args[:podtype] || (Rails.env.test? ? :test : :real)
  @items = args[:items]
  @field_tags = args[:field_tags]
end

Instance Method Details

#outObject

if output mod given,



22
23
24
25
26
27
28
29
30
# File 'lib/cardio/mod/sow.rb', line 22

def out
  Card::Cache.reset_all
  @mod ? dump(output_hash) : puts(new_data.to_yaml.yellow)
  :success
rescue Card::Error::NotFound => e
  e.message
rescue JSON::ParserError => e
  e.message
end