hamlit 2.2.1 → 2.2.2

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: ae467344339ea7b431086ed4b87764ae4b0a580e
4
- data.tar.gz: 2fbd25588f7006d077e6dfd96ba2cf239dc49c0b
3
+ metadata.gz: bdbcd9855ceed711ca31e228ae8d9eb034868259
4
+ data.tar.gz: 7b0e66130cefe424a2463a283c6a930ad6ae2e60
5
5
  SHA512:
6
- metadata.gz: 8e9fd2852146dc3e1a89d4a473ee2ab3be195c9fedd4b10f94b3dfc93bb9a9b093c3b8320658e1d658ed3b440dbdd8939d0e1f6dc6cb6ecfeca1dbc934bd89ab
7
- data.tar.gz: d63c28302915ff6b297899f93a60e95fa587b99bef7ea4e12509e3a0c3f711f8c806a7c987401790a64e59e056c43bb952a2452508c945a844436fd7c1a3d06c
6
+ metadata.gz: da1b2dc6acad532b7983ad4fe19ff39a4dc3fe94869c7a90b68f0fb8f3d1689d1168edbcf8ba0eeae4ec43d1ad6ad9ee88394b604eaa723c371f01e3520e404c
7
+ data.tar.gz: 099914dd8eb91a102613b42290f5aa87bd0332c87f83fef8f74c88d0d0ac9848f2ad1644744f817d29efd5cd93da1940c5a33b43385bd4fa53433526aa4290a7
data/.travis.yml CHANGED
@@ -7,8 +7,6 @@ script:
7
7
  - "bundle exec rake $TASK"
8
8
  matrix:
9
9
  include:
10
- - rvm: 2.0.0
11
- env: TASK=test
12
10
  - rvm: 2.1
13
11
  env: TASK=test
14
12
  - rvm: 2.2
data/CHANGELOG.md CHANGED
@@ -4,7 +4,18 @@ All notable changes to this project will be documented in this file. This
4
4
  project adheres to [Semantic Versioning](http://semver.org/). This change log is based upon
5
5
  [keep-a-changelog](https://github.com/olivierlacan/keep-a-changelog).
6
6
 
7
- ## [2.2.1](https://github.com/k0kubun/hamlit/compare/v2.1.2...v2.2.0) - 2016-02-06
7
+ ## [2.2.2](https://github.com/k0kubun/hamlit/compare/v2.2.1...v2.2.2) - 2016-02-21
8
+
9
+ ### Added
10
+
11
+ - Optimize performance of plain filter
12
+
13
+ ### Fixed
14
+
15
+ - Escape only interpolated text for plain filter
16
+ [#58](https://github.com/k0kubun/hamlit/issues/58). *Thanks to @shaneog*
17
+
18
+ ## [2.2.1](https://github.com/k0kubun/hamlit/compare/v2.2.0...v2.2.1) - 2016-02-06
8
19
 
9
20
  ### Added
10
21
 
data/Gemfile CHANGED
@@ -7,8 +7,7 @@ gem 'benchmark-ips', '2.3.0'
7
7
  gem 'minitest-line'
8
8
  gem 'pry-byebug'
9
9
 
10
- is_windows = RUBY_PLATFORM =~ /mswin|mingw|bccwin|wince/
11
- if RUBY_VERSION >= '2.1.0' && !is_windows
10
+ if RUBY_PLATFORM !~ /mswin|mingw|bccwin|wince/
12
11
  gem 'faml'
13
12
  gem 'lineprof'
14
13
  gem 'stackprof'
@@ -16,7 +16,7 @@ module Benchmark
16
16
  end
17
17
  end
18
18
  end
19
- Entry.send(:prepend, EntryExtension)
19
+ Entry.prepend(EntryExtension)
20
20
  end
21
21
  end
22
22
 
data/bin/test CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/bin/bash
2
2
 
3
3
  VERSIONS=(
4
- 2.0.0
5
4
  2.1.7
6
5
  2.2.3
7
6
  2.3.0
@@ -1,15 +1,26 @@
1
+ require 'hamlit/string_splitter'
2
+
1
3
  module Hamlit
2
4
  class Filters
3
5
  class Plain < Base
4
6
  def compile(node)
5
- text = node.value[:text].rstrip
6
- if ::Hamlit::HamlUtil.contains_interpolation?(text)
7
- # FIXME: Confirm whether this is correct or not
8
- text << "\n".freeze
9
- text = ::Hamlit::HamlUtil.slow_unescape_interpolation(text)
10
- [:escape, true, [:dynamic, text]]
11
- else
12
- [:static, text]
7
+ text = node.value[:text]
8
+ text = text.rstrip unless ::Hamlit::HamlUtil.contains_interpolation?(text) # for compatibility
9
+ [:multi, *compile_plain(text)]
10
+ end
11
+
12
+ private
13
+
14
+ def compile_plain(text)
15
+ string_literal = ::Hamlit::HamlUtil.unescape_interpolation(text)
16
+ StringSplitter.compile(string_literal).map do |temple|
17
+ type, str = temple
18
+ case type
19
+ when :dynamic
20
+ [:escape, true, [:dynamic, str]]
21
+ else
22
+ temple
23
+ end
13
24
  end
14
25
  end
15
26
  end
@@ -199,6 +199,8 @@ MSG
199
199
  end
200
200
 
201
201
  # Original Haml::Util.unescape_interpolation
202
+ # ex) slow_unescape_interpolation('foo#{bar}baz"', escape_html: true)
203
+ # #=> "\"foo\#{::Hamlit::HamlHelpers.html_escape((bar))}baz\\\"\""
202
204
  def slow_unescape_interpolation(str, escape_html = nil)
203
205
  res = ''
204
206
  rest = ::Hamlit::HamlUtil.handle_interpolation str.dump do |scan|
@@ -223,7 +225,10 @@ MSG
223
225
  res + rest
224
226
  end
225
227
 
226
- # Customized Haml::Util.unescape_interpolation to handle escape by Hamlit
228
+ # Customized Haml::Util.unescape_interpolation to handle escape by Hamlit.
229
+ # It wraps double quotes to given `str` with escaping `"`.
230
+ #
231
+ # ex) unescape_interpolation('foo#{bar}baz"') #=> "\"foo\#{bar}baz\\\"\""
227
232
  def unescape_interpolation(str)
228
233
  res = ''
229
234
  rest = ::Hamlit::HamlUtil.handle_interpolation str.dump do |scan|
@@ -1,3 +1,3 @@
1
1
  module Hamlit
2
- VERSION = '2.2.1'
2
+ VERSION = '2.2.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hamlit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-06 00:00:00.000000000 Z
11
+ date: 2016-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: temple