Module: Card::Set::Abstract::Machine::OutputUpdate

Extended by:
Card::Set
Defined in:
tmpsets/set/mod014-machines/abstract/machine/output_update.rb

Overview

Set: Abstract (Machine, OutputUpdate)

Constant Summary

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Card::Set

reset_modules

Methods included from I18nScope

#mod_name, #scope

Methods included from Loader

#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set

Methods included from Helpers

#method_missing, #num_set_parts, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscore

Methods included from Card::Set::AdvancedApi

#attachment, #ensure_set, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket, #unshift_basket

Methods included from Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



7
# File 'tmpsets/set/mod014-machines/abstract/machine/output_update.rb', line 7

def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/machines/set/abstract/machine/output_update.rb"; end

Instance Method Details

#ensure_machine_outputObject



28
29
30
31
32
# File 'tmpsets/set/mod014-machines/abstract/machine/output_update.rb', line 28

def ensure_machine_output
  output = fetch trait: :machine_output
  return if output&.selected_content_action_id
  update_machine_output
end

#input_cards_with_changed_source(output_updated) ⇒ Object



44
45
46
47
48
# File 'tmpsets/set/mod014-machines/abstract/machine/output_update.rb', line 44

def input_cards_with_changed_source output_updated
  machine_input_card.extended_item_cards.select do |i_card|
    i_card.try(:source_changed?, since: output_updated)
  end
end

#output_updated_atObject



59
60
61
62
63
64
65
66
# File 'tmpsets/set/mod014-machines/abstract/machine/output_update.rb', line 59

def output_updated_at
  return unless (output_card = machine_output_card)
  if output_card.coded?
    File.mtime output_card.file.path
  else
    output_card.updated_at
  end
end

#regenerate_machine_outputObject



15
16
17
18
# File 'tmpsets/set/mod014-machines/abstract/machine/output_update.rb', line 15

def regenerate_machine_output
  return unless ok?(:read)
  lock { run_machine }
end

#reset_machine_outputObject



8
9
10
11
12
13
# File 'tmpsets/set/mod014-machines/abstract/machine/output_update.rb', line 8

def reset_machine_output
  Auth.as_bot do
    (moc = machine_output_card) && moc.real? && moc.delete!
    update_input_card
  end
end

#update_if_source_file_changedObject

regenerates the machine output if a source file of a input card has been changed



51
52
53
54
55
56
57
# File 'tmpsets/set/mod014-machines/abstract/machine/output_update.rb', line 51

def update_if_source_file_changed
  return unless (output_updated = output_updated_at)
  changed = input_cards_with_changed_source(output_updated)
  return if changed.empty?
  changed.each(&:expire_machine_cache)
  regenerate_machine_output
end

#update_input_cardObject



34
35
36
37
38
39
40
41
42
# File 'tmpsets/set/mod014-machines/abstract/machine/output_update.rb', line 34

def update_input_card
  if Card::ActManager.running_act?
    input_card = attach_subcard! machine_input_card
    input_card.content = ""
    engine_input.each { |input| input_card << input }
  else
    machine_input_card.items = engine_input
  end
end

#update_machine_outputObject



20
21
22
23
24
25
26
# File 'tmpsets/set/mod014-machines/abstract/machine/output_update.rb', line 20

def update_machine_output
  return unless ok?(:read)
  lock do
    update_input_card
    run_machine
  end
end