Module: Card::Set::Abstract::Script

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

Overview

-- encoding : utf-8 --

Defined Under Namespace

Modules: Format, HtmlFormat

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

.included(host_class) ⇒ Object



12
13
14
15
16
17
18
# File 'tmpsets/set/mod014-machines/abstract/script.rb', line 12

def self.included host_class
  host_class.include_set Abstract::Machine
  host_class.include_set Abstract::MachineInput

  host_class.machine_input { standard_machine_input }
  host_class.store_machine_output filetype: "js"
end

.source_locationObject



8
# File 'tmpsets/set/mod014-machines/abstract/script.rb', line 8

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

Instance Method Details

#clean_html?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'tmpsets/set/mod014-machines/abstract/script.rb', line 52

def clean_html?
  false
end

#comment_with_source(js) ⇒ Object



26
27
28
# File 'tmpsets/set/mod014-machines/abstract/script.rb', line 26

def comment_with_source js
  "//#{name}\n#{js}"
end

#compress_js(input) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'tmpsets/set/mod014-machines/abstract/script.rb', line 30

def compress_js input
  Uglifier.compile input
rescue => e
  # CoffeeScript is compiled in a view
  # If there is a CoffeeScript syntax error we get the rescued view here
  # and the error that the rescued view is no valid Javascript
  # To get the original error we have to refer to Card::Error.current
  raise Card::Error, compression_error_message(e)
end

#compress_js?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'tmpsets/set/mod014-machines/abstract/script.rb', line 48

def compress_js?
  Cardio.config.compress_javascript
end

#compression_error_message(e) ⇒ Object



40
41
42
43
44
45
46
# File 'tmpsets/set/mod014-machines/abstract/script.rb', line 40

def compression_error_message e
  if Card::Error.current
    Card::Error.current.message
  else
    "JavaScript::SyntaxError (#{name}): #{e.message}"
  end
end

#diff_argsObject



89
90
91
# File 'tmpsets/set/mod014-machines/abstract/script.rb', line 89

def diff_args
  { diff_format: :text }
end

#standard_machine_inputObject



20
21
22
23
24
# File 'tmpsets/set/mod014-machines/abstract/script.rb', line 20

def standard_machine_input
  js = format(:js)._render_core
  js = compress_js js if compress_js?
  comment_with_source js
end