Class: Cardio::Mod::Sow

Inherits:
Object
  • Object
show all
Includes:
CardSource, RemoteSource, YamlDump
Defined in:
lib/cardio/mod/sow.rb,
lib/cardio/mod/sow/yaml_dump.rb,
lib/cardio/mod/sow/card_source.rb,
lib/cardio/mod/sow/remote_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, RemoteSource, YamlDump

Instance Method Summary collapse

Methods included from RemoteSource

#pod_from_url, #remote_source, #yaml_from_url

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.



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

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

Instance Method Details

#runObject

if output mod given,



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

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