faml 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 328702b10e441bb1ae9badaa46916346ae4ce107
4
- data.tar.gz: bb21f995e912c1730b63248d03ec0c53950edb0c
3
+ metadata.gz: f5be22673d059f3065d3e748acab1499879a0808
4
+ data.tar.gz: 493d64d87e95ee62a3f2567a60233de635a7ab69
5
5
  SHA512:
6
- metadata.gz: 61e63a2853364b69ffccdc59a1ceac429eba475a4a7cfa93c67a354a2cf74f75d66fa062a52b2a0f6dc7c0d09cf572663cf47772e5c8f91c9f584aebfee258ca
7
- data.tar.gz: 47fffa94adedb8d3197076b5a1bf7ecef6a95a7e4a52606a710d7e08eb5f9959f9cb866df51d725a92001db941d2bdba5a6990fec056c76c8e9b46f3e6ea21b3
6
+ metadata.gz: ed6b5e9ef55122c50b410dc412f403f781a80ba99193f415a3eb8a6a188598e6861a8afb71362733acb71039856c4fc3d5fb7e9710e337f5cde92882eba5ca3f
7
+ data.tar.gz: bca6c7834c44dab97238d108da0ee99db1f9152c15e6609e5e506ac2af6039b208c8aee57aab5bff4479ed27d5469810fb85ea83fd0f99a9164705ee9dde1c4d
@@ -1,3 +1,7 @@
1
+ ## 0.2.5 (2015-03-30)
2
+ - Fix parser when parsing attributes in `{'foo': 'bar'}` form
3
+ - The syntax was introduced in Ruby 2.2.
4
+
1
5
  ## 0.2.4 (2015-03-26)
2
6
  - Fix parser when parsing `>` or `<` after attribute lists
3
7
  - `%div{foo: :bar} <br>` was incorrectly parsed as `%div{foo: :bar}< br>` .
@@ -56,9 +56,15 @@ module Faml
56
56
  end
57
57
  end
58
58
 
59
+ SYMBOL_FIRST_CHARS = [
60
+ ':', # { :'foo' => 'bar' } or { :"foo" => 'bar' }
61
+ "'", # { 'foo': 'bar' }
62
+ '"', # { "foo": 'bar' }
63
+ ].freeze
64
+
59
65
  def eval_symbol(code)
60
- if code.start_with?(':')
61
- eval(code)
66
+ if SYMBOL_FIRST_CHARS.include?(code[0])
67
+ eval(code).to_sym
62
68
  else
63
69
  code.to_sym
64
70
  end
@@ -1,3 +1,3 @@
1
1
  module Faml
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -19,6 +19,15 @@ RSpec.describe 'Attributes rendering', type: :render do
19
19
  expect(render_string("%span{:'foo-bar' => 'baz'}")).to eq("<span foo-bar='baz'></span>\n")
20
20
  end
21
21
 
22
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
23
+ it 'renders attributes with 2.2-style symbol literals' do
24
+ expect(render_string(%Q|%span{"foo": 'bar'}|)).to eq("<span foo='bar'></span>\n")
25
+ expect(render_string(%Q|- x = 'bar'\n%span{"foo": x}|)).to eq("<span foo='bar'></span>\n")
26
+ expect(render_string(%Q|%span{'foo': 'bar'}|)).to eq("<span foo='bar'></span>\n")
27
+ expect(render_string(%Q|- x = 'bar'\n%span{'foo': x}|)).to eq("<span foo='bar'></span>\n")
28
+ end
29
+ end
30
+
22
31
  it 'renders dynamic attributes' do
23
32
  expect(render_string(%q|%span#main{class: "na#{'ni'}ka"} hello|)).to eq(%Q{<span class='nanika' id='main'>hello</span>\n})
24
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kohei Suzuki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-26 00:00:00.000000000 Z
11
+ date: 2015-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: escape_utils
@@ -406,7 +406,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
406
406
  version: '0'
407
407
  requirements: []
408
408
  rubyforge_project:
409
- rubygems_version: 2.2.2
409
+ rubygems_version: 2.4.5
410
410
  signing_key:
411
411
  specification_version: 4
412
412
  summary: Faster implementation of Haml template language.