liquid-validator 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +11 -0
- data/README.md +18 -3
- data/Rakefile +2 -1
- data/bin/appraisal +21 -0
- data/bin/bundle +105 -0
- data/bin/coderay +21 -0
- data/bin/pry +21 -0
- data/bin/rake +21 -0
- data/bin/rubocop +21 -0
- data/bin/ruby-parse +21 -0
- data/bin/ruby-rewrite +21 -0
- data/bin/thor +21 -0
- data/gemfiles/liquid_2.gemfile +7 -0
- data/gemfiles/liquid_2.gemfile.lock +54 -0
- data/gemfiles/liquid_3.gemfile +7 -0
- data/gemfiles/liquid_3.gemfile.lock +54 -0
- data/gemfiles/liquid_4.gemfile +7 -0
- data/gemfiles/liquid_4.gemfile.lock +54 -0
- data/lib/liquid-validator/validator.rb +17 -10
- data/lib/liquid-validator/version.rb +1 -1
- data/liquid-validator.gemspec +12 -5
- metadata +89 -19
- data/test/liquid_validator_test.rb +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d4d8be6ddebd0c7328a7de4c00af42dc62ea7e6
|
4
|
+
data.tar.gz: 6a581e9b1c1ab6cb5602d4a1839735437da5efbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 294cdfc80df1482b86cd92b95532416050918aa9fa5f941c8dbd835e0376950a41f06bf51181a017d625af9b64fb53433bf3b69ff50be7f1dbaa703037327406
|
7
|
+
data.tar.gz: 8452cfa77517fa4292ca4e7747efe4c31696197ac92dbe5ea31f7a54e877bdb620a8278d551bfe09ccb07142f3f17fda22ccd89e60c67583323b349da89f4dd5
|
data/Appraisals
ADDED
data/README.md
CHANGED
@@ -24,17 +24,32 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
good_tmpl = "Your name is {{name}}"
|
27
|
-
validator = LiquidValidator::
|
27
|
+
validator = LiquidValidator::Validator.new(good_tmpl)
|
28
28
|
validator.valid? # true
|
29
29
|
validator.errors # []
|
30
30
|
|
31
31
|
bad_tmpl = "Your name is {{name"
|
32
|
-
validator = LiquidValidator::
|
32
|
+
validator = LiquidValidator::Validator.new(bad_tmpl)
|
33
33
|
validator.valid? # false
|
34
34
|
validator.errors # ["Syntax Error: ..."] (Array of strings)
|
35
35
|
```
|
36
36
|
|
37
|
-
|
37
|
+
If you're using liquid version 3 and greater you can adjust the strictness of template validation.
|
38
|
+
The default is `:strict` which is the suggested level. The levels match [error-modes](https://github.com/Shopify/liquid#error-modes). You can adjust the error mode via:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
good_tmpl = "Your name is {{name}}"
|
42
|
+
validator = LiquidValidator::Validator.new(good_tmpl, error_mode: :lax)
|
43
|
+
validator.valid? # true
|
44
|
+
validator.errors # []
|
45
|
+
|
46
|
+
bad_tmpl = "Your name is {{name"
|
47
|
+
validator = LiquidValidator::Validator.new(bad_tmpl, error_mode: :lax)
|
48
|
+
validator.valid? # true
|
49
|
+
validator.errors # []
|
50
|
+
```
|
51
|
+
|
52
|
+
*Note* - That in ```LiquidValidator::Validator.new(tmpl)``` tmpl is a string.
|
38
53
|
|
39
54
|
## Contributing
|
40
55
|
|
data/Rakefile
CHANGED
data/bin/appraisal
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'appraisal' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
12
|
+
load(bundle_binstub) if File.file?(bundle_binstub)
|
13
|
+
|
14
|
+
require "pathname"
|
15
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
16
|
+
Pathname.new(__FILE__).realpath)
|
17
|
+
|
18
|
+
require "rubygems"
|
19
|
+
require "bundler/setup"
|
20
|
+
|
21
|
+
load Gem.bin_path("appraisal", "appraisal")
|
data/bin/bundle
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1 || ">= 0.a"
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_version
|
64
|
+
@bundler_version ||= begin
|
65
|
+
env_var_version || cli_arg_version ||
|
66
|
+
lockfile_version || "#{Gem::Requirement.default}.a"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def load_bundler!
|
71
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
72
|
+
|
73
|
+
# must dup string for RG < 1.8 compatibility
|
74
|
+
activate_bundler(bundler_version.dup)
|
75
|
+
end
|
76
|
+
|
77
|
+
def activate_bundler(bundler_version)
|
78
|
+
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
|
79
|
+
bundler_version = "< 2"
|
80
|
+
end
|
81
|
+
gem_error = activation_error_handling do
|
82
|
+
gem "bundler", bundler_version
|
83
|
+
end
|
84
|
+
return if gem_error.nil?
|
85
|
+
require_error = activation_error_handling do
|
86
|
+
require "bundler/version"
|
87
|
+
end
|
88
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
89
|
+
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
|
90
|
+
exit 42
|
91
|
+
end
|
92
|
+
|
93
|
+
def activation_error_handling
|
94
|
+
yield
|
95
|
+
nil
|
96
|
+
rescue StandardError, LoadError => e
|
97
|
+
e
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
m.load_bundler!
|
102
|
+
|
103
|
+
if m.invoked_as_script?
|
104
|
+
load Gem.bin_path("bundler", "bundle")
|
105
|
+
end
|
data/bin/coderay
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'coderay' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
12
|
+
load(bundle_binstub) if File.file?(bundle_binstub)
|
13
|
+
|
14
|
+
require "pathname"
|
15
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
16
|
+
Pathname.new(__FILE__).realpath)
|
17
|
+
|
18
|
+
require "rubygems"
|
19
|
+
require "bundler/setup"
|
20
|
+
|
21
|
+
load Gem.bin_path("coderay", "coderay")
|
data/bin/pry
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'pry' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
12
|
+
load(bundle_binstub) if File.file?(bundle_binstub)
|
13
|
+
|
14
|
+
require "pathname"
|
15
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
16
|
+
Pathname.new(__FILE__).realpath)
|
17
|
+
|
18
|
+
require "rubygems"
|
19
|
+
require "bundler/setup"
|
20
|
+
|
21
|
+
load Gem.bin_path("pry", "pry")
|
data/bin/rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
12
|
+
load(bundle_binstub) if File.file?(bundle_binstub)
|
13
|
+
|
14
|
+
require "pathname"
|
15
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
16
|
+
Pathname.new(__FILE__).realpath)
|
17
|
+
|
18
|
+
require "rubygems"
|
19
|
+
require "bundler/setup"
|
20
|
+
|
21
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/rubocop
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rubocop' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
12
|
+
load(bundle_binstub) if File.file?(bundle_binstub)
|
13
|
+
|
14
|
+
require "pathname"
|
15
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
16
|
+
Pathname.new(__FILE__).realpath)
|
17
|
+
|
18
|
+
require "rubygems"
|
19
|
+
require "bundler/setup"
|
20
|
+
|
21
|
+
load Gem.bin_path("rubocop", "rubocop")
|
data/bin/ruby-parse
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ruby-parse' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
12
|
+
load(bundle_binstub) if File.file?(bundle_binstub)
|
13
|
+
|
14
|
+
require "pathname"
|
15
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
16
|
+
Pathname.new(__FILE__).realpath)
|
17
|
+
|
18
|
+
require "rubygems"
|
19
|
+
require "bundler/setup"
|
20
|
+
|
21
|
+
load Gem.bin_path("parser", "ruby-parse")
|
data/bin/ruby-rewrite
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ruby-rewrite' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
12
|
+
load(bundle_binstub) if File.file?(bundle_binstub)
|
13
|
+
|
14
|
+
require "pathname"
|
15
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
16
|
+
Pathname.new(__FILE__).realpath)
|
17
|
+
|
18
|
+
require "rubygems"
|
19
|
+
require "bundler/setup"
|
20
|
+
|
21
|
+
load Gem.bin_path("parser", "ruby-rewrite")
|
data/bin/thor
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'thor' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
12
|
+
load(bundle_binstub) if File.file?(bundle_binstub)
|
13
|
+
|
14
|
+
require "pathname"
|
15
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
16
|
+
Pathname.new(__FILE__).realpath)
|
17
|
+
|
18
|
+
require "rubygems"
|
19
|
+
require "bundler/setup"
|
20
|
+
|
21
|
+
load Gem.bin_path("thor", "thor")
|
@@ -0,0 +1,54 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
liquid-validator (1.0.0)
|
5
|
+
liquid (>= 2.4.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
appraisal (2.2.0)
|
11
|
+
bundler
|
12
|
+
rake
|
13
|
+
thor (>= 0.14.0)
|
14
|
+
ast (2.3.0)
|
15
|
+
coderay (1.1.2)
|
16
|
+
liquid (2.6.3)
|
17
|
+
method_source (0.9.0)
|
18
|
+
minitest (5.10.3)
|
19
|
+
parallel (1.12.0)
|
20
|
+
parser (2.4.0.2)
|
21
|
+
ast (~> 2.3)
|
22
|
+
powerpack (0.1.1)
|
23
|
+
pry (0.11.3)
|
24
|
+
coderay (~> 1.1.0)
|
25
|
+
method_source (~> 0.9.0)
|
26
|
+
rainbow (2.2.2)
|
27
|
+
rake
|
28
|
+
rake (12.3.0)
|
29
|
+
rubocop (0.51.0)
|
30
|
+
parallel (~> 1.10)
|
31
|
+
parser (>= 2.3.3.1, < 3.0)
|
32
|
+
powerpack (~> 0.1)
|
33
|
+
rainbow (>= 2.2.2, < 3.0)
|
34
|
+
ruby-progressbar (~> 1.7)
|
35
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
36
|
+
ruby-progressbar (1.9.0)
|
37
|
+
thor (0.20.0)
|
38
|
+
unicode-display_width (1.3.0)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
appraisal
|
45
|
+
bundler (~> 1.16.0)
|
46
|
+
liquid (= 2.6.3)
|
47
|
+
liquid-validator!
|
48
|
+
minitest
|
49
|
+
pry
|
50
|
+
rake
|
51
|
+
rubocop
|
52
|
+
|
53
|
+
BUNDLED WITH
|
54
|
+
1.16.0
|
@@ -0,0 +1,54 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
liquid-validator (1.0.0)
|
5
|
+
liquid (>= 2.4.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
appraisal (2.2.0)
|
11
|
+
bundler
|
12
|
+
rake
|
13
|
+
thor (>= 0.14.0)
|
14
|
+
ast (2.3.0)
|
15
|
+
coderay (1.1.2)
|
16
|
+
liquid (3.0.6)
|
17
|
+
method_source (0.9.0)
|
18
|
+
minitest (5.10.3)
|
19
|
+
parallel (1.12.0)
|
20
|
+
parser (2.4.0.2)
|
21
|
+
ast (~> 2.3)
|
22
|
+
powerpack (0.1.1)
|
23
|
+
pry (0.11.3)
|
24
|
+
coderay (~> 1.1.0)
|
25
|
+
method_source (~> 0.9.0)
|
26
|
+
rainbow (2.2.2)
|
27
|
+
rake
|
28
|
+
rake (12.3.0)
|
29
|
+
rubocop (0.51.0)
|
30
|
+
parallel (~> 1.10)
|
31
|
+
parser (>= 2.3.3.1, < 3.0)
|
32
|
+
powerpack (~> 0.1)
|
33
|
+
rainbow (>= 2.2.2, < 3.0)
|
34
|
+
ruby-progressbar (~> 1.7)
|
35
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
36
|
+
ruby-progressbar (1.9.0)
|
37
|
+
thor (0.20.0)
|
38
|
+
unicode-display_width (1.3.0)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
appraisal
|
45
|
+
bundler (~> 1.16.0)
|
46
|
+
liquid (= 3.0.6)
|
47
|
+
liquid-validator!
|
48
|
+
minitest
|
49
|
+
pry
|
50
|
+
rake
|
51
|
+
rubocop
|
52
|
+
|
53
|
+
BUNDLED WITH
|
54
|
+
1.16.0
|
@@ -0,0 +1,54 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
liquid-validator (1.0.0)
|
5
|
+
liquid (>= 2.4.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
appraisal (2.2.0)
|
11
|
+
bundler
|
12
|
+
rake
|
13
|
+
thor (>= 0.14.0)
|
14
|
+
ast (2.3.0)
|
15
|
+
coderay (1.1.2)
|
16
|
+
liquid (4.0.0)
|
17
|
+
method_source (0.9.0)
|
18
|
+
minitest (5.10.3)
|
19
|
+
parallel (1.12.0)
|
20
|
+
parser (2.4.0.2)
|
21
|
+
ast (~> 2.3)
|
22
|
+
powerpack (0.1.1)
|
23
|
+
pry (0.11.3)
|
24
|
+
coderay (~> 1.1.0)
|
25
|
+
method_source (~> 0.9.0)
|
26
|
+
rainbow (2.2.2)
|
27
|
+
rake
|
28
|
+
rake (12.3.0)
|
29
|
+
rubocop (0.51.0)
|
30
|
+
parallel (~> 1.10)
|
31
|
+
parser (>= 2.3.3.1, < 3.0)
|
32
|
+
powerpack (~> 0.1)
|
33
|
+
rainbow (>= 2.2.2, < 3.0)
|
34
|
+
ruby-progressbar (~> 1.7)
|
35
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
36
|
+
ruby-progressbar (1.9.0)
|
37
|
+
thor (0.20.0)
|
38
|
+
unicode-display_width (1.3.0)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
appraisal
|
45
|
+
bundler (~> 1.16.0)
|
46
|
+
liquid (= 4.0.0)
|
47
|
+
liquid-validator!
|
48
|
+
minitest
|
49
|
+
pry
|
50
|
+
rake
|
51
|
+
rubocop
|
52
|
+
|
53
|
+
BUNDLED WITH
|
54
|
+
1.16.0
|
@@ -1,21 +1,28 @@
|
|
1
1
|
class LiquidValidator::Validator
|
2
|
-
|
2
|
+
attr_reader :errors, :template, :error_mode
|
3
|
+
|
4
|
+
def initialize(template, error_mode: :strict)
|
3
5
|
@template = template
|
4
|
-
@
|
5
|
-
@
|
6
|
+
@error_mode = error_mode
|
7
|
+
@errors = []
|
8
|
+
@valid = true
|
6
9
|
run_validations_on_template
|
7
10
|
end
|
8
11
|
|
9
|
-
def valid
|
10
|
-
|
12
|
+
def valid?
|
13
|
+
@valid
|
14
|
+
end
|
11
15
|
|
12
16
|
private
|
17
|
+
|
13
18
|
def run_validations_on_template
|
14
|
-
|
15
|
-
::Liquid::Template.parse(
|
16
|
-
|
17
|
-
|
18
|
-
@errors << e.message
|
19
|
+
if Gem.loaded_specs['liquid'].version.release >= Gem::Version.create('3')
|
20
|
+
::Liquid::Template.parse(template, error_mode: :strict)
|
21
|
+
else
|
22
|
+
::Liquid::Template.parse(template)
|
19
23
|
end
|
24
|
+
rescue Liquid::SyntaxError => e
|
25
|
+
@valid = false
|
26
|
+
@errors << e.message
|
20
27
|
end
|
21
28
|
end
|
data/liquid-validator.gemspec
CHANGED
@@ -7,19 +7,26 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "liquid-validator"
|
8
8
|
spec.version = LiquidValidator::VERSION
|
9
9
|
spec.authors = ["Jeremy W. Rowe"]
|
10
|
-
spec.email = ["
|
10
|
+
spec.email = ["jeremywrowe@users.noreply.github.com"]
|
11
11
|
spec.description = %q{Liquid template validator}
|
12
12
|
spec.summary = %q{Validates template strings that are consumed when creating a liquid template. It is simple, that is the point.}
|
13
13
|
spec.homepage = "https://github.com/jeremywrowe/liquid-validator"
|
14
14
|
spec.license = "MIT"
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
15
18
|
|
16
|
-
spec.
|
17
|
-
spec.executables = spec.files.grep(%r{^
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.test_files = spec.files.grep(%r{^(test)/})
|
19
22
|
spec.require_paths = ["lib"]
|
20
23
|
|
21
24
|
spec.add_dependency('liquid', '>= 2.4.0')
|
22
25
|
|
23
|
-
spec.add_development_dependency "bundler", "~> 1.
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16.0"
|
24
27
|
spec.add_development_dependency "rake"
|
28
|
+
spec.add_development_dependency "minitest"
|
29
|
+
spec.add_development_dependency "pry"
|
30
|
+
spec.add_development_dependency "rubocop"
|
31
|
+
spec.add_development_dependency "appraisal"
|
25
32
|
end
|
metadata
CHANGED
@@ -1,75 +1,146 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liquid-validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy W. Rowe
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 2.4.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.16.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.16.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: appraisal
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
53
109
|
- !ruby/object:Gem::Version
|
54
110
|
version: '0'
|
55
111
|
description: Liquid template validator
|
56
112
|
email:
|
57
|
-
-
|
113
|
+
- jeremywrowe@users.noreply.github.com
|
58
114
|
executables: []
|
59
115
|
extensions: []
|
60
116
|
extra_rdoc_files: []
|
61
117
|
files:
|
62
|
-
- .gitignore
|
118
|
+
- ".gitignore"
|
119
|
+
- Appraisals
|
63
120
|
- Gemfile
|
64
121
|
- Gemfile.lock
|
65
122
|
- LICENSE.txt
|
66
123
|
- README.md
|
67
124
|
- Rakefile
|
125
|
+
- bin/appraisal
|
126
|
+
- bin/bundle
|
127
|
+
- bin/coderay
|
128
|
+
- bin/pry
|
129
|
+
- bin/rake
|
130
|
+
- bin/rubocop
|
131
|
+
- bin/ruby-parse
|
132
|
+
- bin/ruby-rewrite
|
133
|
+
- bin/thor
|
134
|
+
- gemfiles/liquid_2.gemfile
|
135
|
+
- gemfiles/liquid_2.gemfile.lock
|
136
|
+
- gemfiles/liquid_3.gemfile
|
137
|
+
- gemfiles/liquid_3.gemfile.lock
|
138
|
+
- gemfiles/liquid_4.gemfile
|
139
|
+
- gemfiles/liquid_4.gemfile.lock
|
68
140
|
- lib/liquid-validator.rb
|
69
141
|
- lib/liquid-validator/validator.rb
|
70
142
|
- lib/liquid-validator/version.rb
|
71
143
|
- liquid-validator.gemspec
|
72
|
-
- test/liquid_validator_test.rb
|
73
144
|
homepage: https://github.com/jeremywrowe/liquid-validator
|
74
145
|
licenses:
|
75
146
|
- MIT
|
@@ -80,20 +151,19 @@ require_paths:
|
|
80
151
|
- lib
|
81
152
|
required_ruby_version: !ruby/object:Gem::Requirement
|
82
153
|
requirements:
|
83
|
-
- -
|
154
|
+
- - ">="
|
84
155
|
- !ruby/object:Gem::Version
|
85
156
|
version: '0'
|
86
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
158
|
requirements:
|
88
|
-
- -
|
159
|
+
- - ">="
|
89
160
|
- !ruby/object:Gem::Version
|
90
161
|
version: '0'
|
91
162
|
requirements: []
|
92
163
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.
|
164
|
+
rubygems_version: 2.6.11
|
94
165
|
signing_key:
|
95
166
|
specification_version: 4
|
96
167
|
summary: Validates template strings that are consumed when creating a liquid template.
|
97
168
|
It is simple, that is the point.
|
98
|
-
test_files:
|
99
|
-
- test/liquid_validator_test.rb
|
169
|
+
test_files: []
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'minitest/spec'
|
2
|
-
require 'minitest/autorun'
|
3
|
-
require_relative '../lib/liquid-validator'
|
4
|
-
|
5
|
-
describe LiquidValidator::Validator do
|
6
|
-
describe "#valid?" do
|
7
|
-
it "returns true for valid templates" do
|
8
|
-
template = <<-TEMPLATE
|
9
|
-
{% if something %}
|
10
|
-
HAPPY DAY
|
11
|
-
{% endif %}
|
12
|
-
TEMPLATE
|
13
|
-
LiquidValidator::Validator.new(template).valid?.must_equal true
|
14
|
-
end
|
15
|
-
|
16
|
-
it "returns false for invalid templates" do
|
17
|
-
template = <<-TEMPLATE
|
18
|
-
{% if something
|
19
|
-
HAPPY DAY
|
20
|
-
{% endif %}
|
21
|
-
TEMPLATE
|
22
|
-
LiquidValidator::Validator.new(template).valid?.must_equal false
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#errors" do
|
27
|
-
it "returns an empty array if the template has no errors" do
|
28
|
-
template = <<-TEMPLATE
|
29
|
-
{% if something %}
|
30
|
-
HAPPY DAY
|
31
|
-
{% endif %}
|
32
|
-
TEMPLATE
|
33
|
-
LiquidValidator::Validator.new(template).errors.must_equal []
|
34
|
-
end
|
35
|
-
|
36
|
-
it "returns an an array of the errors in the template" do
|
37
|
-
template = <<-TEMPLATE
|
38
|
-
{% if something
|
39
|
-
HAPPY DAY
|
40
|
-
{% endif %}
|
41
|
-
TEMPLATE
|
42
|
-
LiquidValidator::Validator.new(template).errors.must_equal ["Tag '{%' was not properly terminated with regexp: /\\%\\}/ "]
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|