liquidscript 0.11.0.rc1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/liquidscript.rb +1 -1
  3. data/lib/liquidscript/cli.rb +1 -1
  4. data/lib/liquidscript/compiler/base.rb +7 -0
  5. data/lib/liquidscript/compiler/base/blank.rb +7 -0
  6. data/lib/liquidscript/compiler/icr/classes.rb +46 -30
  7. data/lib/liquidscript/compiler/icr/directives.rb +42 -4
  8. data/lib/liquidscript/compiler/icr/expressions.rb +40 -6
  9. data/lib/liquidscript/compiler/icr/functions.rb +7 -11
  10. data/lib/liquidscript/compiler/icr/groups.rb +2 -1
  11. data/lib/liquidscript/compiler/icr/helpers.rb +8 -0
  12. data/lib/liquidscript/compiler/icr/literals.rb +9 -4
  13. data/lib/liquidscript/errors.rb +9 -8
  14. data/lib/liquidscript/generator/javascript/exceptions.rb +5 -1
  15. data/lib/liquidscript/generator/javascript/literals.rb +33 -1
  16. data/lib/liquidscript/generator/javascript/metas.rb +14 -1
  17. data/lib/liquidscript/generator/javascript/objects.rb +3 -0
  18. data/lib/liquidscript/icr/code.rb +43 -2
  19. data/lib/liquidscript/icr/context.rb +163 -85
  20. data/lib/liquidscript/icr/representable.rb +1 -1
  21. data/lib/liquidscript/icr/set.rb +43 -81
  22. data/lib/liquidscript/icr/variable.rb +17 -0
  23. data/lib/liquidscript/scanner/base.rb +11 -1
  24. data/lib/liquidscript/scanner/base/lexer.rb +3 -2
  25. data/lib/liquidscript/scanner/liquidscript/main.rb +36 -34
  26. data/lib/liquidscript/version.rb +1 -1
  27. data/spec/fixtures/class.compile.yml +0 -2
  28. data/spec/fixtures/function.generate.yml +14 -1
  29. data/spec/fixtures/literals.generate.yml +3 -1
  30. data/spec/liquidscript/compiler/icr_spec.rb +1 -1
  31. data/spec/liquidscript/icr/context_spec.rb +2 -2
  32. data/spec/liquidscript/icr/set_spec.rb +4 -4
  33. data/vendor/assets/javascripts/liquidscript.js +103 -0
  34. data/vendor/assets/javascripts/liquidscript.liq +29 -0
  35. data/vendor/assets/javascripts/promise.liq +67 -0
  36. metadata +7 -4
@@ -0,0 +1,103 @@
1
+ (function() {
2
+ "use strict";
3
+ var Liquidscript, Promise;
4
+ Liquidscript = function(opt) {
5
+ if(! (this instanceof Liquidscript)) {
6
+ return new Liquidscript(opt);
7
+ }else if(this.initialize) {
8
+ this.initialize.apply(this, arguments);
9
+ };
10
+ };
11
+ Liquidscript.prototype = Liquidscript;
12
+ Liquidscript.prototype.singleton = function(fn) {
13
+ var ran, memo;
14
+ ran = false;
15
+ memo = undefined();
16
+ return function() {
17
+ var ran, memo;
18
+ if(ran) {
19
+ return memo;
20
+ };
21
+ ran = true;
22
+ return memo = fn.apply(null, arguments);
23
+ };
24
+ };
25
+ ;
26
+ Promise = Promise || function Promise() {
27
+ if(this.initialize) {
28
+ this.initialize.apply(this, arguments);
29
+ }
30
+ };
31
+ Promise.prototype.onFulfilled = [];
32
+ Promise.prototype.onRejected = [];
33
+ Promise.prototype.func = undefined;
34
+ Promise.prototype.state = undefined;
35
+ Promise.prototype.initialize = function(fn) {
36
+ this.onFulfilled = [];
37
+ this.onRejected = [];
38
+ this.func = fn;
39
+ return this.state = "pending";
40
+ };
41
+ Promise.prototype.then = function(fulfilled, rejected) {
42
+ if(fulfilled instanceof Function) {
43
+ this.onFulfilled.push(fulfilled);
44
+ };
45
+ if(rejected instanceof Function) {
46
+ this.onRejected.push(rejected);
47
+ };
48
+ };
49
+ Promise.prototype.reject = function() {
50
+ return null;
51
+ };
52
+ Promise.prototype.fulfill = function() {
53
+ return null;
54
+ };
55
+ Promise.prototype.resolve = function(value) {
56
+ var self, thenProperty, resolved;
57
+ self = this;
58
+ this.value = value;
59
+ if(this === value) {
60
+ return this.reject(TypeError);
61
+ }else if(value instanceof Promise) {
62
+ value.then(function(v) {
63
+ return self.fulfill(v);
64
+ }, function(e) {
65
+ return self.reject(e);
66
+ });
67
+ };
68
+ try {
69
+ thenProperty = value.then;
70
+ }catch(e) {
71
+ return this.reject(e);
72
+ };
73
+ if(thenProperty) {
74
+ resolved = false;
75
+ try {
76
+ thenProperty(function(v) {
77
+ var resolved;
78
+ if(resolved) {
79
+ return null;
80
+ };
81
+ resolved = true;
82
+ return self.resolve(v);
83
+ }, function(e) {
84
+ var resolved;
85
+ if(resolved) {
86
+ return null;
87
+ };
88
+ resolved = true;
89
+ return self.reject(e);
90
+ });
91
+ }catch(e) {
92
+ if(! resolved) {
93
+ this.reject(e);
94
+ };
95
+ };
96
+ } else {
97
+ this.fulfill(value);
98
+ };
99
+ };
100
+ Liquidscript.Promise = Promise;
101
+ ;
102
+ ;
103
+ })();
@@ -0,0 +1,29 @@
1
+ (-> {
2
+
3
+ :[ strict ]
4
+
5
+ Liquidscript = (opt)-> {
6
+ if(!(this instanceof Liquidscript))
7
+ return new Liquidscript(opt)
8
+ elsif(this.initialize)
9
+ this.initialize.apply(this, arguments)
10
+ }
11
+
12
+ Liquidscript.prototype = Liquidscript
13
+
14
+ class Liquidscript {
15
+ singleton: (fn)-> {
16
+ ran = false
17
+ memo = undefined
18
+
19
+ ()-> {
20
+ if(ran) return memo
21
+ ran = true
22
+ memo = fn.apply(null, arguments)
23
+ }
24
+ }
25
+ }
26
+
27
+ :[ include "promise.liq" ]
28
+
29
+ })()
@@ -0,0 +1,67 @@
1
+ class Liquidscript {
2
+ class Promise {
3
+ on-fulfilled: []
4
+ on-rejected: []
5
+ func: undefined
6
+ state: undefined
7
+
8
+ initialize: (fn)-> {
9
+ this.on-fulfilled = []
10
+ this.on-rejected = []
11
+ this.func = fn
12
+ this.state = "pending"
13
+ }
14
+
15
+ then: (fulfilled, rejected)-> {
16
+ if(fulfilled instanceof Function) {
17
+ this.on-fulfilled.push(fulfilled)
18
+ }
19
+
20
+ if(rejected instanceof Function) {
21
+ this.on-rejected.push(rejected)
22
+ }
23
+ }
24
+
25
+ reject: -> nil
26
+ fulfill: -> nil
27
+
28
+ resolve: (value)-> {
29
+ self = this
30
+ this.value = value
31
+ if(this == value)
32
+ return reject(TypeError)
33
+ elsif(value instanceof Promise) {
34
+ value.then((v)-> self.fulfill(v), (e)-> self.reject(e))
35
+ }
36
+
37
+ try {
38
+ then-property = value.then
39
+ } catch(e) {
40
+ return reject(e)
41
+ }
42
+
43
+ if(then-property) {
44
+ resolved = false
45
+
46
+ try {
47
+ then-property((v)-> {
48
+ if(resolved) return null
49
+ resolved = true
50
+ self.resolve(v)
51
+ }, (e)-> {
52
+ if(resolved) return null
53
+ resolved = true
54
+ self.reject(e)
55
+ })
56
+ } catch(e) {
57
+ if(!resolved) {
58
+ reject(e)
59
+ }
60
+ }
61
+ } else {
62
+ fulfill(value)
63
+ }
64
+ }
65
+
66
+ }
67
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liquidscript
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0.rc1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Rodi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-25 00:00:00.000000000 Z
11
+ date: 2014-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -214,6 +214,9 @@ files:
214
214
  - spec/support/matchers/compile.rb
215
215
  - spec/support/matchers/generate.rb
216
216
  - spec/support/matchers/run.rb
217
+ - vendor/assets/javascripts/liquidscript.js
218
+ - vendor/assets/javascripts/liquidscript.liq
219
+ - vendor/assets/javascripts/promise.liq
217
220
  homepage: https://github.com/medcat/liquidscript
218
221
  licenses:
219
222
  - MIT
@@ -229,9 +232,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
229
232
  version: '0'
230
233
  required_rubygems_version: !ruby/object:Gem::Requirement
231
234
  requirements:
232
- - - ">"
235
+ - - ">="
233
236
  - !ruby/object:Gem::Version
234
- version: 1.3.1
237
+ version: '0'
235
238
  requirements: []
236
239
  rubyforge_project:
237
240
  rubygems_version: 2.2.2