liquidscript 0.9.1 → 0.9.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: 57668156cbed92dc8694537e87be8befb53b04ec
4
- data.tar.gz: 53b033136d7808ce56d70de4528ad4a6426f989f
3
+ metadata.gz: de4a6e4e30f2ba12fbd6acd8e61710c6f3d730a0
4
+ data.tar.gz: 28f06c96c546b9acce2cb1a2454dddf36063734b
5
5
  SHA512:
6
- metadata.gz: f161d8b85ce48ac8437565a835d815232ba647a6fb61dc674ac67b4f09ae88e201240243c974852fd57816686e6e6ffa011b8d6ddf8be9f59359cafa81fee1e1
7
- data.tar.gz: 93c142ef0d3c677dc54c334c0c312565bea1be8a9a121a7f3e2ffe43625e52bb0f28be249a601acdeb744f7c8fbcadc09e776a1d90d93ca2c4029cc1eb36be3c
6
+ metadata.gz: f9b1a7c09cdaa877e8f87b3ba3df38c43a3cc159841ded598c6f414e9b201b496674e30615580341ab58bea73f16a86454e91c8608d729006938def214b9d2ea
7
+ data.tar.gz: 0583b8399b2af491b2d9c44fd05ac7dfe824f1e5da99e3d6a5ddf1f983591283c71e520883803da4b0e9e90888aa714ab08a568b41a6152b2843f15b2ea48881
@@ -23,6 +23,24 @@ module Liquidscript
23
23
  puts "COMPILING: #{file}"
24
24
  perform_compiliation(file,
25
25
  options[:out] || file.gsub('.liq', '.js'))
26
+ end
27
+ end
28
+
29
+ desc "syntax FILES", "Syntax check given file"
30
+ long_desc <<-LONGDESC
31
+ It will run a syntax check on the file listed. If the file does
32
+ not pass the syntax check it will return the error code 1. If
33
+ the file give is - it will check the standard input.
34
+ LONGDESC
35
+ def syntax(*files)
36
+ errored = files.select do |file|
37
+ print "CHECKING: #{file} "
38
+ !preform_syntax_check(file)
39
+ end
40
+
41
+ if errored.size > 0
42
+ puts "#{errored.join(', ')} did not pass the syntax check"
43
+ exit 1
26
44
  end
27
45
  end
28
46
 
@@ -45,9 +63,29 @@ module Liquidscript
45
63
  outfile.write(out)
46
64
  rescue StandardError => e
47
65
  $stderr.puts "ERROR: #{e.class}: #{e.message}"
66
+
48
67
  $stderr.puts e.backtrace[0..5].map { |s| "\t#{s.gsub(/^.*?\/lib\/liquidscript\//, "")}" }.join("\n")
68
+ exit 1
49
69
  ensure
50
70
  ([infile, outfile] - [$stdin, $stdout]).each(&:close)
51
71
  end
72
+
73
+ def preform_syntax_check(file)
74
+ infile = if file == '-'
75
+ $stdin
76
+ else
77
+ File.open(file, "r")
78
+ end
79
+
80
+ Liquidscript.compile(infile.read)
81
+ puts "OK"
82
+ return true
83
+ rescue StandardError => e
84
+ puts "FAIL"
85
+ $stderr.puts "ERROR: #{e.class}: #{e.message}"
86
+ return false
87
+ ensure
88
+ ([infile] - [$stdin]).each(&:close)
89
+ end
52
90
  end
53
91
  end
@@ -4,7 +4,18 @@ module Liquidscript
4
4
  module Literals
5
5
 
6
6
  def compile_number
7
- code :number, pop.value
7
+ #code :number, pop.value
8
+ n = shift(:number)
9
+
10
+ if peek?(:prop)
11
+ shift(:prop)
12
+ shift(:prop)
13
+ n2 = shift(:number)
14
+
15
+ code :range, n.value, n2.value
16
+ else
17
+ code :number, n.value
18
+ end
8
19
  end
9
20
 
10
21
  def compile_action
@@ -16,6 +16,13 @@ module Liquidscript
16
16
  "#{code.first}"
17
17
  end
18
18
 
19
+ def generate_range(code)
20
+ start = code[1]
21
+ ending = code[2]
22
+
23
+ (start..ending).to_a.join(', ')
24
+ end
25
+
19
26
  def generate_action(code)
20
27
  code[1].value
21
28
  end
@@ -1,5 +1,5 @@
1
1
  module Liquidscript
2
2
 
3
3
  # The current version of liquidscript.
4
- VERSION = "0.9.1".freeze
4
+ VERSION = "0.9.2".freeze
5
5
  end
@@ -1,6 +1,7 @@
1
1
  data: |
2
2
  object = { hello: "world" }
3
3
  test = [1, 2]
4
+ range = [0x1..0x9]
4
5
  regex = r/^\/test/
5
6
  block = ///
6
7
  ^test # comment
@@ -8,9 +9,10 @@ data: |
8
9
  regex == block
9
10
 
10
11
  compiled: |
11
- var object, test, regex, block;
12
+ var object, test, range, regex, block;
12
13
  object = { "hello": "world" };
13
14
  test = [1, 2];
15
+ range = [0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9];
14
16
  regex = /^\/test/;
15
17
  block = /^test/;
16
18
  regex === block;
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.9.1
4
+ version: 0.9.2
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-11 00:00:00.000000000 Z
11
+ date: 2014-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler