liquidscript 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 214333df60e65b294cded24a6eb2cd301fbf49d8
4
- data.tar.gz: 588829872097423d0f5d4121b84bcada786a651e
3
+ metadata.gz: fd125951854295e502bad68f06358e1546554d70
4
+ data.tar.gz: ca1ddecbcbaff2e1f54689eb4482f56f8ff0c147
5
5
  SHA512:
6
- metadata.gz: ed7808cc437c8b84940d87321d0c0bc1f7397636d2559e4ce120a22b3bc7bc5aaafe5dae48ea07a978ebf1cfecedff78788256a5d8a87ebfa53c89a4d8c90f6d
7
- data.tar.gz: 9b677ab1a7fff741147f48f7c8d121afb0a858b08d40ee041e79296e1014962633517662089071f4e3e7786f9eed753328110cf5926bbd7a140c97c04598c658
6
+ metadata.gz: 9efea19e05234c3eefedfdd374884e6df84f105ee0831fbf18d0f2a90eea32cf027e6d6e83ef4693c2656303666f52ebf6cad053219c822bc45423620a9fb478
7
+ data.tar.gz: c1ba8350f0ce9db207aaac1fd08456d1142c57c964e7ef11c13c956c30ef5d07fff53a984b7d1aecef4e16da5892c70c3dcb34373559224c440c02300faf5a64
@@ -6,14 +6,8 @@ module Liquidscript
6
6
  def compile_property(prop)
7
7
  shift :prop
8
8
 
9
- ref = if [:identifier, :class, :module].include?(prop.type)
10
- ref(prop)
11
- else
12
- prop
13
- end
14
-
15
9
  property = action do |ident|
16
- code :property, ref, ident
10
+ code :property, prop, ident
17
11
  end
18
12
 
19
13
  # Just in case there is a property named 'class' or 'module'
@@ -38,7 +38,8 @@ module Liquidscript
38
38
  shift :lbrack
39
39
 
40
40
  objects = collect_compiles :rbrack,
41
- :comma => action.shift do
41
+ :comma => action.shift,
42
+ :newline => action.shift do
42
43
  [compile_object_key, compile_vexpression]
43
44
  end
44
45
 
@@ -3,7 +3,7 @@ module Liquidscript
3
3
  class Error < ::StandardError; end
4
4
 
5
5
  class SyntaxError < Error; end
6
- class CompileError < Error; end
6
+ class CompileError < Error; end
7
7
  class GeneratorError < Error; end
8
8
 
9
9
  class UnexpectedEndError < CompileError; end
@@ -13,6 +13,7 @@ module Liquidscript
13
13
  super "No variable named #{name}"
14
14
  end
15
15
  end
16
+
16
17
  class UnexpectedError < CompileError
17
18
  def initialize(expected, got)
18
19
  @expected = expected
@@ -97,7 +97,7 @@ module Liquidscript
97
97
  module_name = code[1].value
98
98
 
99
99
  in_module(module_name) do |last_module|
100
- body << "#{module_name} ||= {};"
100
+ body << "#{module_name} = #{module_name} || {};"
101
101
 
102
102
  code[2].each do |part|
103
103
  k, v = part
@@ -1,5 +1,5 @@
1
1
  module Liquidscript
2
2
 
3
3
  # The current version of liquidscript.
4
- VERSION = "0.2.1".freeze
4
+ VERSION = "0.3.0".freeze
5
5
  end
@@ -8,8 +8,8 @@ data: |
8
8
  compiled:
9
9
  - :exec
10
10
  - - :_context
11
- - - :SomeClass
12
- - :Something
11
+ - - :Something
12
+ - :SomeClass
13
13
  - - :module
14
14
  - - :identifier
15
15
  - Something
@@ -24,3 +24,4 @@ compiled:
24
24
  - []
25
25
  - - :_arguments
26
26
  - []
27
+ - - :newline
@@ -12,10 +12,10 @@ data: |
12
12
  }
13
13
 
14
14
  compiled: |
15
- var Test, Something;
15
+ var Something, Test;
16
16
 
17
- Something = {};
18
- Test = function Test() {
17
+ Something = Something || {};
18
+ Test = Test || function Test() {
19
19
  if(this.initialize) {
20
20
  this.initialize.apply(this, arguments);
21
21
  }
@@ -14,10 +14,10 @@ data: |
14
14
  }
15
15
 
16
16
  compiled: |
17
- var Test, Thing, SomeModule;
17
+ var Test, SomeModule, Thing;
18
18
  Test = require("some_module/test");
19
- SomeModule = {};
20
- Thing = function Thing() {
19
+ SomeModule = SomeModule || {};
20
+ Thing = Thing || function Thing() {
21
21
  if(this.initialize) {
22
22
  this.initialize.apply(this, arguments);
23
23
  }
@@ -13,6 +13,7 @@ compiled:
13
13
  - :console
14
14
  - - :number
15
15
  - "2"
16
+ - - :newline
16
17
  - - :set
17
18
  - - :_variable
18
19
  - :func
@@ -22,11 +23,14 @@ compiled:
22
23
  - []
23
24
  - - :_arguments
24
25
  - []
26
+ - - :newline
25
27
  - - :call
26
28
  - - :property
27
- - - :_variable
28
- - :console
29
+ - - :identifier
30
+ - console
29
31
  - - :identifier
30
32
  - log
31
33
  - - :dstring
32
34
  - hello world
35
+ - - :newline
36
+ - - :newline
@@ -32,7 +32,7 @@ RSpec::Matchers.define :compile do
32
32
  end
33
33
 
34
34
  def actual
35
- @_out || []
35
+ (@_out || []).to_a!
36
36
  end
37
37
 
38
38
  def compiler(data)
@@ -29,7 +29,7 @@ RSpec::Matchers.define :generate do |v|
29
29
  diffable
30
30
 
31
31
  def generator(data)
32
- compiler = Compiler::ICR.new(Scanner.new(data))
32
+ compiler = Compiler::ICR.new(s = Scanner.new(data))
33
33
  compiler.compile
34
34
  Generator::Javascript.new(compiler.top)
35
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liquidscript
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Rodi