haml 5.0.1 → 5.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -5
- data/CHANGELOG.md +14 -0
- data/Gemfile +1 -0
- data/README.md +0 -6
- data/REFERENCE.md +9 -8
- data/Rakefile +12 -6
- data/haml.gemspec +0 -1
- data/lib/haml/attribute_compiler.rb +19 -11
- data/lib/haml/buffer.rb +1 -1
- data/lib/haml/compiler.rb +3 -3
- data/lib/haml/exec.rb +6 -1
- data/lib/haml/filters.rb +1 -1
- data/lib/haml/generator.rb +1 -1
- data/lib/haml/helpers.rb +1 -1
- data/lib/haml/helpers/action_view_mods.rb +6 -2
- data/lib/haml/parser.rb +1 -1
- data/lib/haml/sass_rails_filter.rb +1 -1
- data/lib/haml/version.rb +1 -1
- metadata +4 -22
- data/test/attribute_parser_test.rb +0 -105
- data/test/engine_test.rb +0 -2131
- data/test/filters_test.rb +0 -262
- data/test/helper_test.rb +0 -695
- data/test/options_test.rb +0 -22
- data/test/parser_test.rb +0 -172
- data/test/template_test.rb +0 -332
- data/test/temple_line_counter_test.rb +0 -40
- data/test/util_test.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1516ce57a2223bbb3e48b98b360ee5afd000187c
|
4
|
+
data.tar.gz: 4684ec8a3d54757e1b42f3431e5972a99fc3ed3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 815057d4871feeff8fdb368b55d640444fa730f06ef8a0344fcc8f9e23e8d17d444057d2a09531249a2a3905d848c4da4ba0be478a0429b9b1296e7bfe8fb0b4
|
7
|
+
data.tar.gz: d72bf87bad6fdf37a18291cb19dfccbb6a4d10aed7151be5c4461925bf4bddc45fe01dd8eab6c561a936c727e19c0d57017abe3628a2adb56ddcc5d7706e5e08
|
data/.travis.yml
CHANGED
@@ -8,14 +8,15 @@ rvm:
|
|
8
8
|
- 2.2.7
|
9
9
|
- 2.1.10
|
10
10
|
- 2.0.0
|
11
|
-
- jruby-9.1.
|
11
|
+
- jruby-9.1.12.0
|
12
12
|
- rbx-3
|
13
13
|
gemfile:
|
14
|
-
- test/gemfiles/Gemfile.rails-4.0.x
|
15
|
-
- test/gemfiles/Gemfile.rails-4.1.x
|
16
|
-
- test/gemfiles/Gemfile.rails-4.2.x
|
17
|
-
- test/gemfiles/Gemfile.rails-5.0.x
|
18
14
|
- test/gemfiles/Gemfile.rails-5.1.x
|
15
|
+
- test/gemfiles/Gemfile.rails-5.0.x
|
16
|
+
- test/gemfiles/Gemfile.rails-4.2.x
|
17
|
+
- test/gemfiles/Gemfile.rails-4.1.x
|
18
|
+
- test/gemfiles/Gemfile.rails-4.0.x
|
19
|
+
- test/gemfiles/Gemfile.rails-edge
|
19
20
|
matrix:
|
20
21
|
exclude:
|
21
22
|
- rvm: 2.0.0
|
@@ -34,5 +35,6 @@ matrix:
|
|
34
35
|
gemfile: test/gemfiles/Gemfile.rails-4.2.x
|
35
36
|
allow_failures:
|
36
37
|
- rvm: rbx-3
|
38
|
+
- gemfile: test/gemfiles/Gemfile.rails-edge
|
37
39
|
fast_finish: true
|
38
40
|
script: "bundle exec rake submodules test"
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Haml Changelog
|
2
2
|
|
3
|
+
## 5.0.2
|
4
|
+
|
5
|
+
Released on August 1, 2017
|
6
|
+
([diff](https://github.com/haml/haml/compare/v5.0.2...v5.0.1)).
|
7
|
+
|
8
|
+
* Let `haml -c` fail if generated Ruby code is syntax error. [#880](https://github.com/haml/haml/issues/880) (Takashi Kokubun)
|
9
|
+
* Fix `NoMethodError` bug caused with Sprockets 3 and :sass filter. [#930](https://github.com/haml/haml/pull/930) (thanks [Gonzalez Maximiliano](https://github.com/emaxi))
|
10
|
+
* Fix `list_of` helper with multi-line content. [#933](https://github.com/haml/haml/pull/933) (thanks [Benoit Larroque](https://github.com/zetaben))
|
11
|
+
* Optimize rendering performance by changing timing to fix textareas. [#941](https://github.com/haml/haml/pull/941) (Takashi Kokubun)
|
12
|
+
* Fix `TypeError` with empty :ruby filter. [#942](https://github.com/haml/haml/pull/942) (Takashi Kokubun)
|
13
|
+
* Fix inconsitent attribute sort order. (Takashi Kokubun)
|
14
|
+
|
3
15
|
## 5.0.1
|
4
16
|
|
5
17
|
Released on May 3, 2017
|
@@ -19,7 +31,9 @@ Breaking Changes
|
|
19
31
|
* Haml now requires Ruby 2.0.0 or above.
|
20
32
|
* Rails 3 is no longer supported, matching the official
|
21
33
|
[Maintenance Policy for Ruby on Rails](http://weblog.rubyonrails.org/2013/2/24/maintenance-policy-for-ruby-on-rails/).
|
34
|
+
Use Haml 4 if you want to use Rails 3.
|
22
35
|
(Tee Parham)
|
36
|
+
* Remove `:ugly` option ([#894](https://github.com/haml/haml/pull/894))
|
23
37
|
* The `haml` command's debug option (`-d`) no longer executes the Haml code, but
|
24
38
|
rather checks the generated Ruby syntax for errors.
|
25
39
|
* Drop parser/compiler accessor from `Haml::Engine`. Modify `Haml::Engine#initialize` options
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -42,12 +42,6 @@ To use Haml with Rails, simply add Haml to your Gemfile and run `bundle`.
|
|
42
42
|
gem 'haml'
|
43
43
|
~~~
|
44
44
|
|
45
|
-
Haml 5 will require Rails version 4.0 or later. If you are using Rails 3.x, you should use Haml version 4.0.x:
|
46
|
-
|
47
|
-
~~~ruby
|
48
|
-
gem 'haml', '~> 4.0.5'
|
49
|
-
~~~
|
50
|
-
|
51
45
|
If you'd like to replace Rails's Erb-based generators with Haml, add
|
52
46
|
[haml-rails](https://github.com/indirect/haml-rails) to your Gemfile as well.
|
53
47
|
|
data/REFERENCE.md
CHANGED
@@ -1120,8 +1120,8 @@ is compiled to
|
|
1120
1120
|
<p>I <strong>really</strong> prefer <em>raspberry</em> jam.</p>
|
1121
1121
|
</div>
|
1122
1122
|
|
1123
|
-
|
1124
|
-
|
1123
|
+
Note that `#{}` interpolation within filters is HTML-escaped if you specify
|
1124
|
+
{Haml::Options#escape_html `:escape_html`} option.
|
1125
1125
|
|
1126
1126
|
The functionality of some filters such as Markdown can be provided by many
|
1127
1127
|
different libraries. Usually you don't have to worry about this - you can just
|
@@ -1144,9 +1144,9 @@ Surrounds the filtered text with CDATA tags.
|
|
1144
1144
|
|
1145
1145
|
### `:coffee` {#coffee-filter}
|
1146
1146
|
|
1147
|
-
Compiles the filtered text to
|
1148
|
-
reference this filter as `:coffeescript`. This filter is
|
1149
|
-
Tilt.
|
1147
|
+
Compiles the filtered text to JavaScript in `<script>` tag using CoffeeScript.
|
1148
|
+
You can also reference this filter as `:coffeescript`. This filter is
|
1149
|
+
implemented using Tilt.
|
1150
1150
|
|
1151
1151
|
### `:css` {#css-filter}
|
1152
1152
|
|
@@ -1174,7 +1174,7 @@ option} to control when CDATA tags are added.
|
|
1174
1174
|
|
1175
1175
|
### `:less` {#less-filter}
|
1176
1176
|
|
1177
|
-
Parses the filtered text with [Less](http://lesscss.org/) to produce CSS output.
|
1177
|
+
Parses the filtered text with [Less](http://lesscss.org/) to produce CSS output in `<style>` tag.
|
1178
1178
|
This filter is implemented using Tilt.
|
1179
1179
|
|
1180
1180
|
### `:markdown` {#markdown-filter}
|
@@ -1217,12 +1217,13 @@ template.
|
|
1217
1217
|
### `:sass` {#sass-filter}
|
1218
1218
|
|
1219
1219
|
Parses the filtered text with [Sass](http://sass-lang.com/) to produce CSS
|
1220
|
-
output. This filter is implemented using Tilt.
|
1220
|
+
output in `<style>` tag. This filter is implemented using Tilt.
|
1221
1221
|
|
1222
1222
|
### `:scss` {#scss-filter}
|
1223
1223
|
|
1224
1224
|
Parses the filtered text with Sass like the `:sass` filter, but uses the newer
|
1225
|
-
SCSS syntax to produce CSS output. This filter is implemented
|
1225
|
+
SCSS syntax to produce CSS output in `<style>` tag. This filter is implemented
|
1226
|
+
using Tilt.
|
1226
1227
|
|
1227
1228
|
### `:textile` {#textile-filter}
|
1228
1229
|
|
data/Rakefile
CHANGED
@@ -4,13 +4,19 @@ require "bundler/gem_tasks"
|
|
4
4
|
|
5
5
|
task :default => :test
|
6
6
|
|
7
|
-
#FIXME: Redefining :test task to run
|
7
|
+
# FIXME: Redefining :test task to run test/options_test.rb in isolated process since it depends on whether Rails is loaded or not.
|
8
8
|
# Remove this task when we finished changing escape_html option to be true by default.
|
9
|
-
|
10
|
-
|
11
|
-
test_files
|
12
|
-
|
13
|
-
|
9
|
+
isolated_test = Rake::TestTask.new do |t|
|
10
|
+
t.libs << 'test'
|
11
|
+
t.test_files = %w[test/options_test.rb]
|
12
|
+
t.warning = true
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
Rake::TestTask.new do |t|
|
16
|
+
t.libs << 'test'
|
17
|
+
t.test_files = Dir['test/*_test.rb'] + Dir['test/haml-spec/*_test.rb'] - isolated_test.file_list
|
18
|
+
t.warning = true
|
19
|
+
t.verbose = true
|
14
20
|
end
|
15
21
|
|
16
22
|
CLEAN.replace %w(pkg doc coverage .yardoc test/haml vendor)
|
data/haml.gemspec
CHANGED
@@ -16,12 +16,6 @@ module Haml
|
|
16
16
|
value
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
20
|
-
# Key's substring before a hyphen. This is necessary because values with the same
|
21
|
-
# base_key can conflict by Haml::AttributeBuidler#build_data_keys.
|
22
|
-
def base_key
|
23
|
-
key.split('-', 2).first
|
24
|
-
end
|
25
19
|
end
|
26
20
|
|
27
21
|
# Returns a script to render attributes on runtime.
|
@@ -62,14 +56,28 @@ module Haml
|
|
62
56
|
attribute_values = build_attribute_values(attributes, parsed_hashes)
|
63
57
|
AttributeBuilder.verify_attribute_names!(attribute_values.map(&:key))
|
64
58
|
|
65
|
-
|
66
|
-
|
67
|
-
compile_attribute_values(values_by_base_key[base_key])
|
59
|
+
[:multi, *group_values_for_sort(attribute_values).map { |value_group|
|
60
|
+
compile_attribute_values(value_group)
|
68
61
|
}]
|
69
62
|
end
|
70
63
|
|
71
64
|
private
|
72
65
|
|
66
|
+
# Build array of grouped values whose sort order may go back and forth, which is also sorted with key name.
|
67
|
+
# This method needs to group values with the same start because it can be changed in `Haml::AttributeBuidler#build_data_keys`.
|
68
|
+
# @param values [Array<Haml::AttributeCompiler::AttributeValue>]
|
69
|
+
# @return [Array<Array<Haml::AttributeCompiler::AttributeValue>>]
|
70
|
+
def group_values_for_sort(values)
|
71
|
+
sorted_values = values.sort_by(&:key)
|
72
|
+
[].tap do |value_groups|
|
73
|
+
until sorted_values.empty?
|
74
|
+
key = sorted_values.first.key
|
75
|
+
value_group, sorted_values = sorted_values.partition { |v| v.key.start_with?(key) }
|
76
|
+
value_groups << value_group
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
73
81
|
# Returns array of AttributeValue instances from static attributes and dynamic_attributes. For each key,
|
74
82
|
# the values' order in returned value is preserved in the same order as Haml::Buffer#attributes's merge order.
|
75
83
|
#
|
@@ -89,9 +97,9 @@ module Haml
|
|
89
97
|
end
|
90
98
|
end
|
91
99
|
|
92
|
-
# Compiles attribute values with the
|
100
|
+
# Compiles attribute values with the similar key to Temple expression.
|
93
101
|
#
|
94
|
-
# @param values [Array<AttributeValue>] `
|
102
|
+
# @param values [Array<AttributeValue>] whose `key`s are partially or fully the same from left.
|
95
103
|
# @return [Array] Temple expression
|
96
104
|
def compile_attribute_values(values)
|
97
105
|
if values.map(&:key).uniq.size == 1
|
data/lib/haml/buffer.rb
CHANGED
@@ -159,7 +159,7 @@ module Haml
|
|
159
159
|
# @since Haml 4.0.1
|
160
160
|
# @private
|
161
161
|
def fix_textareas!(input)
|
162
|
-
return input unless
|
162
|
+
return input unless input.include?('<textarea'.freeze)
|
163
163
|
|
164
164
|
pattern = /<(textarea)([^>]*)>(\n|
)(.*?)<\/textarea>/im
|
165
165
|
input.gsub!(pattern) do |s|
|
data/lib/haml/compiler.rb
CHANGED
@@ -287,11 +287,11 @@ module Haml
|
|
287
287
|
text = "(#{text}).strip"
|
288
288
|
end
|
289
289
|
if opts[:preserve_tag]
|
290
|
-
text = "::Haml::Helpers.preserve(#{text})"
|
290
|
+
text = "_hamlout.fix_textareas!(::Haml::Helpers.preserve(#{text}))"
|
291
291
|
elsif opts[:preserve_script]
|
292
|
-
text = "::Haml::Helpers.find_and_preserve(#{text}, _hamlout.options[:preserve])"
|
292
|
+
text = "_hamlout.fix_textareas!(::Haml::Helpers.find_and_preserve(#{text}, _hamlout.options[:preserve]))"
|
293
293
|
end
|
294
|
-
"
|
294
|
+
"#{text};"
|
295
295
|
end
|
296
296
|
|
297
297
|
def push_generated_script(text)
|
data/lib/haml/exec.rb
CHANGED
@@ -301,6 +301,11 @@ END
|
|
301
301
|
engine = ::Haml::Engine.new(template, @options[:for_engine])
|
302
302
|
|
303
303
|
if @options[:check_syntax]
|
304
|
+
error = validate_ruby(engine.precompiled)
|
305
|
+
if error
|
306
|
+
puts error.message.split("\n").first
|
307
|
+
exit 1
|
308
|
+
end
|
304
309
|
puts "Syntax OK"
|
305
310
|
return
|
306
311
|
end
|
@@ -333,7 +338,7 @@ END
|
|
333
338
|
|
334
339
|
def validate_ruby(code)
|
335
340
|
begin
|
336
|
-
eval("BEGIN {return nil}; #{code}")
|
341
|
+
eval("BEGIN {return nil}; #{code}", binding, @options[:filename])
|
337
342
|
rescue ::SyntaxError # Not to be confused with Haml::SyntaxError
|
338
343
|
$!
|
339
344
|
end
|
data/lib/haml/filters.rb
CHANGED
@@ -282,7 +282,7 @@ RUBY
|
|
282
282
|
def compile(compiler, text)
|
283
283
|
return if compiler.options[:suppress_eval]
|
284
284
|
compiler.instance_eval do
|
285
|
-
push_silent <<-FIRST.tr("\n", ';')
|
285
|
+
push_silent "#{<<-FIRST.tr("\n", ';')}#{text}#{<<-LAST.tr("\n", ';')}"
|
286
286
|
begin
|
287
287
|
haml_io = StringIO.new(_hamlout.buffer, 'a')
|
288
288
|
FIRST
|
data/lib/haml/generator.rb
CHANGED
data/lib/haml/helpers.rb
CHANGED
@@ -58,11 +58,15 @@ module ActionView
|
|
58
58
|
preserve = haml_buffer.options.fetch(:preserve, %w[textarea pre code]).include?(name.to_s)
|
59
59
|
|
60
60
|
if block_given? && block_is_haml?(block) && preserve
|
61
|
-
return content_tag_without_haml(name, *args)
|
61
|
+
return content_tag_without_haml(name, *args) do
|
62
|
+
haml_buffer.fix_textareas!(Haml::Helpers.preserve(&block)).html_safe
|
63
|
+
end
|
62
64
|
end
|
63
65
|
|
64
66
|
content = content_tag_without_haml(name, *args, &block)
|
65
|
-
|
67
|
+
if preserve && content
|
68
|
+
content = haml_buffer.fix_textareas!(Haml::Helpers.preserve(content)).html_safe
|
69
|
+
end
|
66
70
|
content
|
67
71
|
end
|
68
72
|
|
data/lib/haml/parser.rb
CHANGED
@@ -668,7 +668,7 @@ module Haml
|
|
668
668
|
return attributes_hash, rest, last_line
|
669
669
|
end
|
670
670
|
|
671
|
-
# @return [Array<Hash,String,nil>] - [
|
671
|
+
# @return [Array<Hash,String,nil>] - [static_attributes (Hash), dynamic_attributes (nil or String starting with `{` and ending with `}`)]
|
672
672
|
# @return [String] rest
|
673
673
|
# @return [Integer] last_line
|
674
674
|
def parse_new_attributes(text)
|
@@ -6,7 +6,7 @@ module Haml
|
|
6
6
|
class SassRailsTemplate < ::Sass::Rails::SassTemplate
|
7
7
|
if Gem::Version.new(Sprockets::VERSION) >= Gem::Version.new('3.0.0')
|
8
8
|
def render(scope=Object.new, locals={}, &block)
|
9
|
-
environment = ::Sprockets::Railtie.build_environment(Rails.application)
|
9
|
+
environment = ::Sprockets::Railtie.build_environment(::Rails.application)
|
10
10
|
scope = environment.context_class.new(
|
11
11
|
environment: environment,
|
12
12
|
filename: "/",
|
data/lib/haml/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Natalie Weizenbaum
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-
|
14
|
+
date: 2017-08-01 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: temple
|
@@ -157,15 +157,6 @@ files:
|
|
157
157
|
- lib/haml/temple_line_counter.rb
|
158
158
|
- lib/haml/util.rb
|
159
159
|
- lib/haml/version.rb
|
160
|
-
- test/attribute_parser_test.rb
|
161
|
-
- test/engine_test.rb
|
162
|
-
- test/filters_test.rb
|
163
|
-
- test/helper_test.rb
|
164
|
-
- test/options_test.rb
|
165
|
-
- test/parser_test.rb
|
166
|
-
- test/template_test.rb
|
167
|
-
- test/temple_line_counter_test.rb
|
168
|
-
- test/util_test.rb
|
169
160
|
- yard/default/.gitignore
|
170
161
|
- yard/default/fulldoc/html/css/common.sass
|
171
162
|
- yard/default/layout/html/footer.erb
|
@@ -189,18 +180,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
180
|
version: '0'
|
190
181
|
requirements: []
|
191
182
|
rubyforge_project:
|
192
|
-
rubygems_version: 2.
|
183
|
+
rubygems_version: 2.5.2
|
193
184
|
signing_key:
|
194
185
|
specification_version: 4
|
195
186
|
summary: An elegant, structured (X)HTML/XML templating engine.
|
196
|
-
test_files:
|
197
|
-
- test/attribute_parser_test.rb
|
198
|
-
- test/engine_test.rb
|
199
|
-
- test/filters_test.rb
|
200
|
-
- test/helper_test.rb
|
201
|
-
- test/options_test.rb
|
202
|
-
- test/parser_test.rb
|
203
|
-
- test/template_test.rb
|
204
|
-
- test/temple_line_counter_test.rb
|
205
|
-
- test/util_test.rb
|
187
|
+
test_files: []
|
206
188
|
has_rdoc: false
|
@@ -1,105 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class AttributeParserTeset < Haml::TestCase
|
4
|
-
describe '.parse' do
|
5
|
-
def assert_parse(expected, haml)
|
6
|
-
actual = Haml::AttributeParser.parse(haml)
|
7
|
-
if expected.nil?
|
8
|
-
assert_nil actual
|
9
|
-
else
|
10
|
-
assert_equal expected, actual
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
if Haml::AttributeParser.available?
|
15
|
-
it { assert_parse(nil, '') }
|
16
|
-
it { assert_parse({}, '{}') }
|
17
|
-
|
18
|
-
describe 'invalid hash' do
|
19
|
-
it { assert_parse(nil, '{hash}') }
|
20
|
-
it { assert_parse(nil, '{hash, foo: bar}') }
|
21
|
-
it { assert_parse(nil, '{ {hash} }') }
|
22
|
-
it { assert_parse(nil, '{ { hash, foo: bar } }') }
|
23
|
-
it { assert_parse(nil, '{}.merge({})') }
|
24
|
-
end
|
25
|
-
|
26
|
-
describe 'non single hash' do
|
27
|
-
it { assert_parse(nil, '{ a: 0 };{}') }
|
28
|
-
it { assert_parse(nil, '{ a: 0 }[nil] = {}') }
|
29
|
-
end
|
30
|
-
|
31
|
-
describe 'dynamic key' do
|
32
|
-
it { assert_parse(nil, '{foo => bar}') }
|
33
|
-
it { assert_parse(nil, '{[] => bar}') }
|
34
|
-
it { assert_parse(nil, '{[1,2,3] => bar}') }
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'foo: bar' do
|
38
|
-
it { assert_parse({ '_' => '1' }, '{_:1,}') }
|
39
|
-
it { assert_parse({ 'foo' => 'bar' }, '{ foo: bar }') }
|
40
|
-
it { assert_parse({ 'a' => 'b', 'c' => ':d' }, '{a: b, c: :d}') }
|
41
|
-
it { assert_parse({ 'a' => '[]', 'c' => '"d"' }, '{a: [], c: "d"}') }
|
42
|
-
end
|
43
|
-
|
44
|
-
describe ':foo => bar' do
|
45
|
-
it { assert_parse({ 'foo' => ':bar' }, '{ :foo => :bar }') }
|
46
|
-
it { assert_parse({ '_' => '"foo"' }, '{:_=>"foo"}') }
|
47
|
-
it { assert_parse({ 'a' => '[]', 'c' => '""', 'b' => '"#{3}"' }, '{:a => [], c: "", :b => "#{3}"}') }
|
48
|
-
it { assert_parse(nil, '{:"f#{o}o" => bar}') }
|
49
|
-
it { assert_parse(nil, '{:"#{f}oo" => bar}') }
|
50
|
-
it { assert_parse(nil, '{:"#{foo}" => bar}') }
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '"foo" => bar' do
|
54
|
-
it { assert_parse({ 'foo' => '[1]' }, '{"foo"=>[1]}') }
|
55
|
-
it { assert_parse({ 'foo' => 'nya' }, "{ 'foo' => nya }") }
|
56
|
-
it { assert_parse({ 'foo' => 'bar' }, '{%q[foo] => bar }') }
|
57
|
-
it { assert_parse({ 'foo' => '[1]' }, ' { "foo"=>[1] } ') }
|
58
|
-
it { assert_parse({ 'foo' => 'nya' }, " { 'foo' => nya } ") }
|
59
|
-
it { assert_parse({ 'foo' => 'bar' }, ' { %q[foo] => bar } ') }
|
60
|
-
it { assert_parse(nil, '{"f#{o}o" => bar}') }
|
61
|
-
it { assert_parse(nil, '{"#{f}oo" => bar}') }
|
62
|
-
it { assert_parse(nil, '{"#{foo}" => bar}') }
|
63
|
-
it { assert_parse({ 'f#{o}o' => 'bar' }, '{ %q[f#{o}o] => bar }') }
|
64
|
-
it { assert_parse({ 'f#{o}o' => 'bar' }, '{ %q[f#{o}o] => bar, }') }
|
65
|
-
it { assert_parse(nil, '%Q[f#{o}o] => bar ') }
|
66
|
-
end
|
67
|
-
|
68
|
-
describe 'string interpolation' do
|
69
|
-
it { assert_parse({ 'foo' => %q["#{bar baz, '/abc/'}"] }, %q[{foo: "#{bar baz, '/abc/'}"}]) }
|
70
|
-
end
|
71
|
-
|
72
|
-
describe 'multi lines' do
|
73
|
-
it { assert_parse({ 'a' => 'b', 'c' => 'd' }, "{a: b,\nc: d}") }
|
74
|
-
end
|
75
|
-
|
76
|
-
if RUBY_VERSION >= '2.2.0'
|
77
|
-
describe '"foo": bar' do
|
78
|
-
it { assert_parse({ 'foo' => '()' }, '{"foo":()}') }
|
79
|
-
it { assert_parse({ 'foo' => 'nya' }, " {'foo': nya} ") }
|
80
|
-
it { assert_parse({ 'foo' => '()' }, ' { "foo":() , }') }
|
81
|
-
it { assert_parse({ 'foo' => 'nya' }, " { 'foo': nya , }") }
|
82
|
-
it { assert_parse(nil, '{"f#{o}o": bar}') }
|
83
|
-
it { assert_parse(nil, '{"#{f}oo": bar}') }
|
84
|
-
it { assert_parse(nil, '{"#{foo}": bar}') }
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe 'nested array' do
|
89
|
-
it { assert_parse({ 'foo' => '[1,2,]' }, '{foo: [1,2,],}') }
|
90
|
-
it { assert_parse({ 'foo' => '[1,2,[3,4],5]' }, '{foo: [1,2,[3,4],5],}') }
|
91
|
-
it { assert_parse({ 'foo' => '[1,2,[3,4],5]', 'bar' => '[[1,2],]'}, '{foo: [1,2,[3,4],5],bar: [[1,2],],}') }
|
92
|
-
end
|
93
|
-
|
94
|
-
describe 'nested hash' do
|
95
|
-
it { assert_parse({ 'foo' => '{ }', 'bar' => '{}' }, '{foo: { }, bar: {}}') }
|
96
|
-
it { assert_parse({ 'foo' => '{ bar: baz, hoge: fuga, }' }, '{foo: { bar: baz, hoge: fuga, }, }') }
|
97
|
-
it { assert_parse({ 'data' => '{ confirm: true, disable: false }', 'hello' => '{ world: foo, }' }, '{data: { confirm: true, disable: false }, :hello => { world: foo, },}') }
|
98
|
-
end
|
99
|
-
|
100
|
-
describe 'nested method' do
|
101
|
-
it { assert_parse({ 'foo' => 'bar(a, b)', 'hoge' => 'piyo(a, b,)' }, '{ foo: bar(a, b), hoge: piyo(a, b,), }') }
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|