card-mod-machines 0.12.0 → 0.13.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,2 @@
1
1
  //script: html5shiv printshiv
2
- !function(e,i){function m(e,t){var n=e.createElement("p"),r=e.getElementsByTagName("head")[0]||e.documentElement;return n.innerHTML="x<style>"+t+"</style>",r.insertBefore(n.lastChild,r.firstChild)}function c(){var e=T.elements;return"string"==typeof e?e.split(" "):e}function d(e){var t=N[e[b]];return t||(t={},S++,e[b]=S,N[S]=t),t}function r(e,t,n){return t||(t=i),u?t.createElement(e):(n||(n=d(t)),(r=n.cache[e]?n.cache[e].cloneNode():E.test(e)?(n.cache[e]=n.createElem(e)).cloneNode():n.createElem(e)).canHaveChildren&&!y.test(e)?n.frag.appendChild(r):r);var r}function t(e,t){if(e||(e=i),u)return e.createDocumentFragment();for(var n=(t=t||d(e)).frag.cloneNode(),r=0,a=c(),o=a.length;r<o;r++)n.createElement(a[r]);return n}function n(t,n){n.cache||(n.cache={},n.createElem=t.createElement,n.createFrag=t.createDocumentFragment,n.frag=n.createFrag()),t.createElement=function(e){return T.shivMethods?r(e,t,n):n.createElem(e)},t.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+c().join().replace(/\w+/g,function(e){return n.createElem(e),n.frag.createElement(e),'c("'+e+'")'})+");return n}")(T,n.frag)}function a(e){e||(e=i);var t=d(e);return!T.shivCSS||p||t.hasCSS||(t.hasCSS=!!m(e,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),u||n(e,t),e}function h(e){for(var t,n=e.getElementsByTagName("*"),r=n.length,a=RegExp("^(?:"+c().join("|")+")$","i"),o=[];r--;)t=n[r],a.test(t.nodeName)&&o.push(t.applyElement(l(t)));return o}function l(e){for(var t,n=e.attributes,r=n.length,a=e.ownerDocument.createElement(C+":"+e.nodeName);r--;)(t=n[r]).specified&&a.setAttribute(t.nodeName,t.nodeValue);return a.style.cssText=e.style.cssText,a}function f(e){for(var t,n=e.split("{"),r=n.length,a=RegExp("(^|[\\s,>+~])("+c().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),o="$1"+C+"\\:$2";r--;)(t=n[r]=n[r].split("}"))[t.length-1]=t[t.length-1].replace(a,o),n[r]=t.join("}");return n.join("{")}function o(e){for(var t=e.length;t--;)e[t].removeNode()}function s(c){function l(){clearTimeout(e._removeSheetTimer),s&&s.removeNode(!0),s=null}var s,u,e=d(c),t=c.namespaces,n=c.parentWindow;return!D||c.printShived||("undefined"==typeof t[C]&&t.add(C),n.attachEvent("onbeforeprint",function(){l();for(var e,t,n,r=c.styleSheets,a=[],o=r.length,i=Array(o);o--;)i[o]=r[o];for(;n=i.pop();)if(!n.disabled&&x.test(n.media)){try{t=(e=n.imports).length}catch(p){t=0}for(o=0;o<t;o++)i.push(e[o]);try{a.push(n.cssText)}catch(p){}}a=f(a.reverse().join("")),u=h(c),s=m(c,a)}),n.attachEvent("onafterprint",function(){o(u),clearTimeout(e._removeSheetTimer),e._removeSheetTimer=setTimeout(l,500)}),c.printShived=!0),c}var p,u,v="3.6.2",g=e.html5||{},y=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,E=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,b="_html5shiv",S=0,N={};!function(){try{var e=i.createElement("a");e.innerHTML="<xyz></xyz>",p="hidden"in e,u=1==e.childNodes.length||function(){i.createElement("a");var e=i.createDocumentFragment();return"undefined"==typeof e.cloneNode||"undefined"==typeof e.createDocumentFragment||"undefined"==typeof e.createElement}()}catch(m){u=p=!0}}();var T={elements:g.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:v,shivCSS:!1!==g.shivCSS,supportsUnknownElements:u,shivMethods:!1!==g.shivMethods,type:"default",shivDocument:a,createElement:r,createDocumentFragment:t};e.html5=T,a(i);var F,x=/^$|\b(?:all|print)\b/,C="html5shiv",D=!(u||(F=i.documentElement,"undefined"==typeof i.namespaces||"undefined"==typeof i.parentWindow||"undefined"==typeof F.applyElement||"undefined"==typeof F.removeNode||"undefined"==typeof e.attachEvent));T.type+=" print",(T.shivPrint=s)(i)}(this,document);
2
+ !function(e,t){function n(e,t){var n=e.createElement("p"),r=e.getElementsByTagName("head")[0]||e.documentElement;return n.innerHTML="x<style>"+t+"</style>",r.insertBefore(n.lastChild,r.firstChild)}function r(){var e=T.elements;return"string"==typeof e?e.split(" "):e}function a(e){var t=N[e[b]];return t||(t={},S++,e[b]=S,N[S]=t),t}function o(e,n,r){if(n||(n=t),p)return n.createElement(e);r||(r=a(n));var o;return o=r.cache[e]?r.cache[e].cloneNode():E.test(e)?(r.cache[e]=r.createElem(e)).cloneNode():r.createElem(e),o.canHaveChildren&&!y.test(e)?r.frag.appendChild(o):o}function i(e,n){if(e||(e=t),p)return e.createDocumentFragment();n=n||a(e);for(var o=n.frag.cloneNode(),i=0,c=r(),l=c.length;l>i;i++)o.createElement(c[i]);return o}function c(e,t){t.cache||(t.cache={},t.createElem=e.createElement,t.createFrag=e.createDocumentFragment,t.frag=t.createFrag()),e.createElement=function(n){return T.shivMethods?o(n,e,t):t.createElem(n)},e.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+r().join().replace(/\w+/g,function(e){return t.createElem(e),t.frag.createElement(e),'c("'+e+'")'})+");return n}")(T,t.frag)}function l(e){e||(e=t);var r=a(e);return!T.shivCSS||h||r.hasCSS||(r.hasCSS=!!n(e,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),p||c(e,r),e}function u(e){for(var t,n=e.getElementsByTagName("*"),a=n.length,o=RegExp("^(?:"+r().join("|")+")$","i"),i=[];a--;)t=n[a],o.test(t.nodeName)&&i.push(t.applyElement(s(t)));return i}function s(e){for(var t,n=e.attributes,r=n.length,a=e.ownerDocument.createElement(x+":"+e.nodeName);r--;)t=n[r],t.specified&&a.setAttribute(t.nodeName,t.nodeValue);return a.style.cssText=e.style.cssText,a}function m(e){for(var t,n=e.split("{"),a=n.length,o=RegExp("(^|[\\s,>+~])("+r().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),i="$1"+x+"\\:$2";a--;)t=n[a]=n[a].split("}"),t[t.length-1]=t[t.length-1].replace(o,i),n[a]=t.join("}");return n.join("{")}function d(e){for(var t=e.length;t--;)e[t].removeNode()}function f(e){function t(){clearTimeout(i._removeSheetTimer),r&&r.removeNode(!0),r=null}var r,o,i=a(e),c=e.namespaces,l=e.parentWindow;return!C||e.printShived?e:("undefined"==typeof c[x]&&c.add(x),l.attachEvent("onbeforeprint",function(){t();for(var a,i,c,l=e.styleSheets,s=[],d=l.length,f=Array(d);d--;)f[d]=l[d];for(;c=f.pop();)if(!c.disabled&&F.test(c.media)){try{a=c.imports,i=a.length}catch(h){i=0}for(d=0;i>d;d++)f.push(a[d]);try{s.push(c.cssText)}catch(h){}}s=m(s.reverse().join("")),o=u(e),r=n(e,s)}),l.attachEvent("onafterprint",function(){d(o),clearTimeout(i._removeSheetTimer),i._removeSheetTimer=setTimeout(t,500)}),e.printShived=!0,e)}var h,p,v="3.6.2",g=e.html5||{},y=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,E=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,b="_html5shiv",S=0,N={};!function(){try{var e=t.createElement("a");e.innerHTML="<xyz></xyz>",h="hidden"in e,p=1==e.childNodes.length||function(){t.createElement("a");var e=t.createDocumentFragment();return"undefined"==typeof e.cloneNode||"undefined"==typeof e.createDocumentFragment||"undefined"==typeof e.createElement}()}catch(n){h=!0,p=!0}}();var T={elements:g.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:v,shivCSS:g.shivCSS!==!1,supportsUnknownElements:p,shivMethods:g.shivMethods!==!1,type:"default",shivDocument:l,createElement:o,createDocumentFragment:i};e.html5=T,l(t);var F=/^$|\b(?:all|print)\b/,x="html5shiv",C=!p&&function(){var n=t.documentElement;return!("undefined"==typeof t.namespaces||"undefined"==typeof t.parentWindow||"undefined"==typeof n.applyElement||"undefined"==typeof n.removeNode||"undefined"==typeof e.attachEvent)}();T.type+=" print",T.shivPrint=f,f(t)}(this,document);
data/lib/card/machine.rb CHANGED
@@ -3,16 +3,53 @@ class Card
3
3
  REFRESHED = "MACHINE_ASSETS_REFRESHED".freeze
4
4
 
5
5
  class << self
6
- def refresh_script_and_style
7
- return unless refresh_script_and_style?
6
+ def refresh_assets force: false
7
+ return unless force || refresh_assets?
8
8
 
9
- Card.fetch(:all, :script)&.update_if_source_file_changed
10
- Card.fetch(:all, :style)&.update_if_source_file_changed
9
+ refresh_asset :script, force
10
+ refresh_asset :style, force
11
+ end
12
+
13
+ def refresh_assets!
14
+ refresh_assets force: true
15
+ end
16
+
17
+ def reset_all
18
+ Auth.as_bot do
19
+ Card.search(right: { codename: "machine_output" }).each do |card|
20
+ card.update_columns trash: true
21
+ card.expire
22
+ end
23
+ end
24
+ reset_virtual_machine_cache
25
+ end
26
+
27
+ def reset_script
28
+ Auth.as_bot do
29
+ card = Card[:all, :script, :machine_output]
30
+ if card
31
+ card.update_columns trash: true
32
+ card.expire
33
+ reset_virtual_machine_cache
34
+ end
35
+ end
36
+ end
37
+
38
+ def refresh_asset asset_type, force
39
+ all_rule(asset_type)&.refresh_output force: force
11
40
  end
12
41
 
13
42
  private
14
43
 
15
- def refresh_script_and_style?
44
+ def all_rule asset_type
45
+ Card[[:all, asset_type]]
46
+ end
47
+
48
+ def reset_virtual_machine_cache
49
+ Virtual.where(right_id: MachineCacheID).delete_all
50
+ end
51
+
52
+ def refresh_assets?
16
53
  case Cardio.config.machine_refresh
17
54
  when :eager then true
18
55
  when :cautious then cautious_refresh?
@@ -25,7 +62,7 @@ class Card
25
62
 
26
63
  # only refresh when cache was cleared
27
64
  def cautious_refresh?
28
- return false unless Card::Cache.persistent_cache
65
+ return false unless Cache.persistent_cache
29
66
  return false if Card.cache.read REFRESHED
30
67
 
31
68
  Card.cache.write REFRESHED, true
@@ -4,7 +4,7 @@ def reset_machine_output
4
4
  @updated_at = output_updated_at
5
5
  moc.delete! if moc.real?
6
6
  update_input_card
7
- expire_if_source_file_changed @updated_at
7
+ expire_outdated @updated_at
8
8
  end
9
9
  end
10
10
 
@@ -19,7 +19,7 @@ def update_machine_output
19
19
 
20
20
  lock do
21
21
  update_input_card
22
- expire_if_source_file_changed output_updated_at
22
+ expire_outdated
23
23
  run_machine
24
24
  end
25
25
  end
@@ -41,29 +41,24 @@ def update_input_card
41
41
  end
42
42
  end
43
43
 
44
- def input_cards_with_changed_source output_updated
45
- machine_input_card.extended_item_cards.select do |i_card|
46
- i_card.try(:source_changed?, since: output_updated)
47
- end
44
+ # regenerates the machine output if a source file of a input card has been changed
45
+ def refresh_output force: false
46
+ regenerate_machine_output if expire_outdated || force
48
47
  end
49
48
 
50
- def expire_if_source_file_changed output_updated_at
51
- return unless output_updated_at
49
+ private
50
+
51
+ def expire_outdated updated_at=nil
52
+ updated_at ||= output_updated_at
53
+ return true unless updated_at
52
54
 
53
- changed = input_cards_with_changed_source(output_updated_at)
55
+ changed = input_cards_with_changed_source updated_at
54
56
  return if changed.empty?
55
57
 
56
58
  changed.each(&:expire_machine_cache)
57
59
  true
58
60
  end
59
61
 
60
- # regenerates the machine output if a source file of a input card has been changed
61
- def update_if_source_file_changed
62
- return unless expire_if_source_file_changed output_updated_at
63
-
64
- regenerate_machine_output
65
- end
66
-
67
62
  def output_updated_at
68
63
  return unless (output_card = machine_output_card)
69
64
 
@@ -73,3 +68,9 @@ def output_updated_at
73
68
  output_card.updated_at
74
69
  end
75
70
  end
71
+
72
+ def input_cards_with_changed_source output_updated
73
+ machine_input_card.extended_item_cards.select do |i_card|
74
+ i_card.try(:source_changed?, since: output_updated)
75
+ end
76
+ end
@@ -88,7 +88,7 @@ class EngineInput
88
88
  end
89
89
 
90
90
  def simple_item?
91
- @item.item_cards == [@item] # no pointer card
91
+ @item.item_cards == [@item] || @item.try(:self_machine_input?) # no pointer card
92
92
  end
93
93
 
94
94
  def pointer_item
@@ -123,17 +123,15 @@ def after_engine output
123
123
  file = Tempfile.new [id.to_s, ".#{filetype}"]
124
124
  file.write output
125
125
  file.rewind
126
- Card::Auth.as_bot do
127
- p = machine_output_card
128
- p.file = file
129
- p.save!
130
- end
126
+ store_machine_output file
131
127
  file.close
132
128
  file.unlink
133
129
  end
134
130
 
135
- view :machine_output_url do
136
- machine_output_url
131
+ format do
132
+ view :machine_output_url do
133
+ machine_output_url
134
+ end
137
135
  end
138
136
 
139
137
  class << self
@@ -166,15 +164,14 @@ def run_machine joint="\n"
166
164
  end
167
165
 
168
166
  def direct_machine_input? input_card
169
- !input_card.collection? ||
170
- input_card.respond_to?(:machine_input)
167
+ !input_card.collection? || input_card.respond_to?(:machine_input)
171
168
  end
172
169
 
173
170
  def run_engine input_card
174
171
  return unless direct_machine_input? input_card
175
- if (cached = fetch_cache_card(input_card)) && cached.content?
176
- return cached.content
177
- end
172
+ # if (cached = fetch_cache_card(input_card)) && cached.content?
173
+ # return cached.content
174
+ # end
178
175
 
179
176
  engine(input_from_card(input_card)).tap do |output|
180
177
  cache_output_part input_card, output
@@ -189,6 +186,7 @@ def input_from_card input_card
189
186
  end
190
187
  end
191
188
 
189
+ # FIXME: this is wack. set the storage right the first time through. obviate
192
190
  def make_machine_output_coded mod=:machines
193
191
  update_machine_output
194
192
  Card::Auth.as_bot do
@@ -219,3 +217,24 @@ def machine_output_path
219
217
  ensure_machine_output
220
218
  machine_output_card.file.path
221
219
  end
220
+
221
+ private
222
+
223
+ # TODO: make more methods private!
224
+
225
+ def store_machine_output file
226
+ Card::Auth.as_bot do
227
+ moc = machine_output_card
228
+ prepare_coded_output moc
229
+ moc.file = file
230
+ moc.save!
231
+ end
232
+ end
233
+
234
+ def prepare_coded_output moc
235
+ return unless (dir = ENV["SEED_MACHINE_OUTPUT_TO"])
236
+ ENV["STORE_CODED_FILES"] = "true"
237
+ moc.storage_type = moc.new_storage_type = :coded
238
+ moc.mod = dir
239
+ moc.codename = machine_output_codename
240
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: card-mod-machines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan McCutchen
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-07-05 00:00:00.000000000 Z
13
+ date: 2021-09-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: card
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.102.0
21
+ version: 1.103.3
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 1.102.0
28
+ version: 1.103.3
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: execjs
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -52,56 +52,56 @@ dependencies:
52
52
  requirements:
53
53
  - - '='
54
54
  - !ruby/object:Gem::Version
55
- version: 0.12.0
55
+ version: 0.13.3
56
56
  type: :runtime
57
57
  prerelease: false
58
58
  version_requirements: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - '='
61
61
  - !ruby/object:Gem::Version
62
- version: 0.12.0
62
+ version: 0.13.3
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: card-mod-format
65
65
  requirement: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - '='
68
68
  - !ruby/object:Gem::Version
69
- version: 0.12.0
69
+ version: 0.13.3
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - '='
75
75
  - !ruby/object:Gem::Version
76
- version: 0.12.0
76
+ version: 0.13.3
77
77
  - !ruby/object:Gem::Dependency
78
78
  name: card-mod-list
79
79
  requirement: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - '='
82
82
  - !ruby/object:Gem::Version
83
- version: 0.12.0
83
+ version: 0.13.3
84
84
  type: :runtime
85
85
  prerelease: false
86
86
  version_requirements: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - '='
89
89
  - !ruby/object:Gem::Version
90
- version: 0.12.0
90
+ version: 0.13.3
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: card-mod-carrierwave
93
93
  requirement: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - '='
96
96
  - !ruby/object:Gem::Version
97
- version: 0.12.0
97
+ version: 0.13.3
98
98
  type: :runtime
99
99
  prerelease: false
100
100
  version_requirements: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - '='
103
103
  - !ruby/object:Gem::Version
104
- version: 0.12.0
104
+ version: 0.13.3
105
105
  description: ''
106
106
  email:
107
107
  - info@decko.org
@@ -109,7 +109,6 @@ executables: []
109
109
  extensions: []
110
110
  extra_rdoc_files: []
111
111
  files:
112
- - file/all_script_machine_output/file.js
113
112
  - file/all_style_machine_output/file.css
114
113
  - file/script_html5shiv_printshiv_machine_output/file.js
115
114
  - lib/card/machine.rb
@@ -117,7 +116,6 @@ files:
117
116
  - set/abstract/machine/output_cache.rb
118
117
  - set/abstract/machine/output_update.rb
119
118
  - set/abstract/machine_input.rb
120
- - set/all/reset_machines.rb
121
119
  - set/right/machine_cache.rb
122
120
  - set/right/machine_input.rb
123
121
  - set/right/machine_output.rb
@@ -146,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
144
  - !ruby/object:Gem::Version
147
145
  version: '0'
148
146
  requirements: []
149
- rubygems_version: 3.2.15
147
+ rubygems_version: 3.1.6
150
148
  signing_key:
151
149
  specification_version: 4
152
150
  summary: decko machines