liquidscript 0.7.1 → 0.7.2

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: 32708208fcf1f212c031c3d7e843219653887748
4
- data.tar.gz: 8bf0b59774f62cdcaf18fc130cbbc8723311627e
3
+ metadata.gz: fcd4572f6244e74518ddb988910f066627aff8e4
4
+ data.tar.gz: a36a4d62484529f05dfecd1664e7310e944479ef
5
5
  SHA512:
6
- metadata.gz: 48960e3bcdea3d27a3c4bf0b5e3e182b4e2f4d0731c4cffeba7eba89a1e8cd3202663d4a45b49f825edd467db704080f38e0e544b062f03c1b816f0cbad863c8
7
- data.tar.gz: 9c60166e3f63e8b96f3d7c055b86e037b17d955b7182da3be656f10d8be5405df98c83b0f83af10c7cf49e74710cd34d54b9718a5b6f1e21c9905e4df52fea3a
6
+ metadata.gz: 8509763bef19d45729b5b5e932891a4ba30a7c698c64d254d22a2dd954c8c987505697ea0b503f3ff2ecd2568c0bce250136fa90f86fa43f567f20b77b6570b4
7
+ data.tar.gz: 55290754b7ac6ead257b0a2bf6e25b4ef1b662c76ed18b2664e21a0761733b87c39e679c3a325ef8050d206b19fee5de6217b98f47134ea904491717f36398fd
data/bin/lscript CHANGED
@@ -10,14 +10,25 @@ end
10
10
  infile = ARGV.shift
11
11
  outfile = ARGV.shift || infile.gsub(/\.liq\Z/, ".js")
12
12
 
13
- File.open(infile, "r") do |f|
13
+ if infile == '-'
14
+ infile = $stdin
15
+ else
16
+ infile = File.open(infile, "r")
17
+ end
18
+
19
+ if outfile == '-'
20
+ outfile = $stdout
21
+ else
22
+ outfile = File.open(outfile, "w")
23
+ end
14
24
 
15
- begin
16
- out = Liquidscript.compile(f.read)
17
- File.open(outfile, "w") { |o| o.write out }
18
- rescue StandardError => e
25
+ begin
26
+ out = Liquidscript.compile(infile.read)
27
+ outfile.write(out)
28
+ rescue StandardError => e
19
29
  $stderr.puts "ERROR: #{e.class}: #{e.message}"
20
30
  $stderr.puts e.backtrace[0..5].map { |s| "\t#{s.gsub(/^.*?\/lib\/liquidscript\//, "")}" }.join("\n")
21
- end
22
-
31
+ ensure
32
+ [infile, outfile].each(&:close)
23
33
  end
34
+
@@ -177,7 +177,6 @@ module Liquidscript
177
177
 
178
178
  def compile_function_with_parameters(parameters)
179
179
  shift :arrow
180
- shift :lbrace
181
180
 
182
181
  expressions = Liquidscript::ICR::Set.new
183
182
  expressions.context = Liquidscript::ICR::Context.new
@@ -194,9 +193,14 @@ module Liquidscript
194
193
  expressions << compile_expression
195
194
  end
196
195
 
197
- loop do
198
- expect :rbrace => action.end_loop,
199
- :_ => expression
196
+ unless peek?(:lbrace)
197
+ expression.call
198
+ else
199
+ shift :lbrace
200
+ loop do
201
+ expect :rbrace => action.end_loop,
202
+ :_ => expression
203
+ end
200
204
  end
201
205
 
202
206
  code :function, @set.pop
@@ -1,5 +1,5 @@
1
1
  module Liquidscript
2
2
 
3
3
  # The current version of liquidscript.
4
- VERSION = "0.7.1".freeze
4
+ VERSION = "0.7.2".freeze
5
5
  end
@@ -0,0 +1,10 @@
1
+ data: |
2
+ some-function = -> console.log("test")
3
+ some-function()
4
+
5
+ compiled: |
6
+ var someFunction;
7
+ someFunction = function() {
8
+ console.log("test");
9
+ };
10
+ someFunction();
@@ -12,7 +12,7 @@ describe "Node support" do
12
12
  content = YAML.load_file file
13
13
  file =~ /spec\/fixtures\/(.*)\.yml/
14
14
 
15
- it "generates #{$1}" do
15
+ it "runs #{$1}" do
16
16
  expect(content["data"]).to run
17
17
  end
18
18
  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.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Rodi
@@ -165,6 +165,7 @@ files:
165
165
  - spec/fixtures/function.generate.yml
166
166
  - spec/fixtures/get.generate.yml
167
167
  - spec/fixtures/heredoc.generate.yml
168
+ - spec/fixtures/inline.generate.yml
168
169
  - spec/fixtures/literals.generate.yml
169
170
  - spec/fixtures/loop.generate.yml
170
171
  - spec/fixtures/main.compile.yml
@@ -225,6 +226,7 @@ test_files:
225
226
  - spec/fixtures/function.generate.yml
226
227
  - spec/fixtures/get.generate.yml
227
228
  - spec/fixtures/heredoc.generate.yml
229
+ - spec/fixtures/inline.generate.yml
228
230
  - spec/fixtures/literals.generate.yml
229
231
  - spec/fixtures/loop.generate.yml
230
232
  - spec/fixtures/main.compile.yml