module Cardio::Mod::Sow::CardSource

Fetch sow data form cards

Public Instance Methods

cards() click to toggle source
# File lib/cardio/mod/sow/card_source.rb, line 16
def cards
  if @name
    cards_from_name
  elsif @cql
    Card.search JSON.parse(@cql).reverse_merge(limit: 0)
  else
    raise Card::Error::NotFound, "must specify either name (-n) or CQL (-c)"
  end
end
cards_from_name() click to toggle source
# File lib/cardio/mod/sow/card_source.rb, line 26
def cards_from_name
  case @items
  when :only then item_cards
  when true  then main_cards + item_cards
  else            main_cards
  end
end
field_tag_marks() click to toggle source
# File lib/cardio/mod/sow/card_source.rb, line 10
def field_tag_marks
  @field_tag_marks ||= @field_tags.to_s.split(",").map do |mark|
    mark.strip.cardname.codename_or_string
  end
end
item_cards() click to toggle source
# File lib/cardio/mod/sow/card_source.rb, line 34
def item_cards
  main_cards.map(&:item_cards).flatten
end
main_cards() click to toggle source
# File lib/cardio/mod/sow/card_source.rb, line 38
def main_cards
  @main_cards ||= @name.split(",").map { |n| require_card n }
end
new_data_from_cards() click to toggle source
# File lib/cardio/mod/sow/card_source.rb, line 6
def new_data_from_cards
  cards.map { |c| c.pod_hash field_tags: field_tag_marks }
end
require_card(name) click to toggle source
# File lib/cardio/mod/sow/card_source.rb, line 42
def require_card name
  Card.fetch(name) || raise(Card::Error::NotFound, "card not found: #{name}")
end