hamlit 1.6.6 → 1.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +6 -1
- data/hamlit.gemspec +2 -0
- data/lib/hamlit/attribute.rb +2 -2
- data/lib/hamlit/compilers/new_attribute.rb +2 -3
- data/lib/hamlit/compilers/old_attribute.rb +7 -7
- data/lib/hamlit/compilers/text.rb +1 -2
- data/lib/hamlit/concerns/balanceable.rb +5 -4
- data/lib/hamlit/concerns/indentable.rb +6 -5
- data/lib/hamlit/parsers/script.rb +1 -1
- data/lib/hamlit/parsers/tag.rb +2 -2
- data/lib/hamlit/version.rb +1 -1
- data/spec/spec_helper.rb +8 -0
- data/spec/spec_helper/render_helper.rb +9 -1
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed569855be3cfd062957586173c438777bbad1bf
|
4
|
+
data.tar.gz: cb9f5d24e5290a801e38a9c1558e01e18dfd2c8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c599f0dcbac927f422137f528949f4ee6111a3f8104caf062e7abe1e23dc861f8ba4f3aae4119bf4dc72b2b5d86265250e7d7dd1d8a967d1d0d887fa2f04c98c
|
7
|
+
data.tar.gz: 8f53b9e6279a35eb5430846173017b09a3b88350b8c29c8f113c2bef31735524760ea9b19e8a12d185f7b35df5fd8e4a3b5938af6f8a705ca71d9259c3be260e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
# Hamlit
|
1
|
+
# Hamlit
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/hamlit.svg)](http://badge.fury.io/rb/hamlit)
|
4
|
+
[![Build Status](https://travis-ci.org/k0kubun/hamlit.svg?branch=master)](https://travis-ci.org/k0kubun/hamlit)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/k0kubun/hamlit/badge.svg?branch=master)](https://coveralls.io/r/k0kubun/hamlit?branch=master)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/k0kubun/hamlit/badges/gpa.svg)](https://codeclimate.com/github/k0kubun/hamlit)
|
2
7
|
|
3
8
|
Hamlit is a high performance [haml](https://github.com/haml/haml) implementation.
|
4
9
|
|
data/hamlit.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency "benchmark-ips"
|
27
27
|
spec.add_development_dependency "bundler"
|
28
28
|
spec.add_development_dependency "coffee-script"
|
29
|
+
spec.add_development_dependency "coveralls"
|
29
30
|
spec.add_development_dependency "erubis"
|
30
31
|
spec.add_development_dependency "faml"
|
31
32
|
spec.add_development_dependency "haml"
|
@@ -35,6 +36,7 @@ Gem::Specification.new do |spec|
|
|
35
36
|
spec.add_development_dependency "redcarpet"
|
36
37
|
spec.add_development_dependency "rspec", ">= 3"
|
37
38
|
spec.add_development_dependency "sass"
|
39
|
+
spec.add_development_dependency "simplecov"
|
38
40
|
spec.add_development_dependency "slim"
|
39
41
|
spec.add_development_dependency "therubyracer"
|
40
42
|
spec.add_development_dependency "unindent"
|
data/lib/hamlit/attribute.rb
CHANGED
@@ -21,8 +21,8 @@ module Hamlit
|
|
21
21
|
|
22
22
|
def build(*args)
|
23
23
|
result = ''
|
24
|
-
attributes = args.inject({}) do |
|
25
|
-
merge_attributes(
|
24
|
+
attributes = args.inject({}) do |attrs, arg|
|
25
|
+
merge_attributes(attrs, arg)
|
26
26
|
end
|
27
27
|
|
28
28
|
attributes.each do |key, value|
|
@@ -58,7 +58,7 @@ module Hamlit
|
|
58
58
|
|
59
59
|
def read_value!(tokens)
|
60
60
|
skip_tokens!(tokens, :on_sp)
|
61
|
-
|
61
|
+
_, _, str = tokens.shift
|
62
62
|
return nil if str != '='
|
63
63
|
|
64
64
|
skip_tokens!(tokens, :on_sp)
|
@@ -79,8 +79,7 @@ module Hamlit
|
|
79
79
|
open_count = 0
|
80
80
|
|
81
81
|
all_tokens.each do |token|
|
82
|
-
(
|
83
|
-
case type
|
82
|
+
case type_of(token)
|
84
83
|
when :on_tstring_beg then open_count += 1
|
85
84
|
when :on_tstring_end then open_count -= 1
|
86
85
|
end
|
@@ -73,16 +73,16 @@ module Hamlit
|
|
73
73
|
# Give up static compilation when variables are detected.
|
74
74
|
def assert_static_value!(value)
|
75
75
|
tokens = Ripper.lex(value)
|
76
|
-
tokens.each do |
|
77
|
-
raise RuntimeBuild if
|
76
|
+
tokens.each do |token|
|
77
|
+
raise RuntimeBuild if type_of(token) == :on_ident
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
# Give up static compilation when the value is a variable or an array.
|
82
82
|
def detect_joinable_value!(value)
|
83
83
|
tokens = Ripper.lex(value)
|
84
|
-
tokens.each do |
|
85
|
-
raise RuntimeBuild if JOINABLE_TOKENS.include?(
|
84
|
+
tokens.each do |token|
|
85
|
+
raise RuntimeBuild if JOINABLE_TOKENS.include?(type_of(token))
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -138,7 +138,7 @@ module Hamlit
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def read_string!(tokens)
|
141
|
-
|
141
|
+
_, type, str = tokens.shift
|
142
142
|
return '' if type == :on_tstring_end
|
143
143
|
|
144
144
|
raise SyntaxError if type_of(tokens.shift) != :on_tstring_end
|
@@ -147,7 +147,7 @@ module Hamlit
|
|
147
147
|
|
148
148
|
def assert_rocket!(tokens, *types)
|
149
149
|
skip_tokens!(tokens, :on_sp)
|
150
|
-
|
150
|
+
_, type, str = tokens.shift
|
151
151
|
|
152
152
|
raise SyntaxError unless type == :on_op && str == '=>'
|
153
153
|
end
|
@@ -175,7 +175,7 @@ module Hamlit
|
|
175
175
|
bracket: 0,
|
176
176
|
}
|
177
177
|
|
178
|
-
Ripper.lex(str).each do |(
|
178
|
+
Ripper.lex(str).each do |(_, col), type, _|
|
179
179
|
if columns.include?(col) && open_count == 1 && count.values.all?(&:zero?)
|
180
180
|
result << col
|
181
181
|
end
|
@@ -46,7 +46,6 @@ module Hamlit
|
|
46
46
|
|
47
47
|
offset = 2 # 2 is the length of '%' and marker
|
48
48
|
open_pos = nil
|
49
|
-
close_pos = nil
|
50
49
|
open_count = 0
|
51
50
|
literal = literalify_string(exp, marker)
|
52
51
|
|
@@ -74,7 +73,7 @@ module Hamlit
|
|
74
73
|
literal = literalify_string(exp, marker)
|
75
74
|
open_count = 0
|
76
75
|
|
77
|
-
Ripper.lex(literal).each do |
|
76
|
+
Ripper.lex(literal).each do |_, type, str|
|
78
77
|
case type
|
79
78
|
when :on_embexpr_beg
|
80
79
|
open_count += 1
|
@@ -1,8 +1,11 @@
|
|
1
1
|
require 'ripper'
|
2
|
+
require 'hamlit/concerns/lexable'
|
2
3
|
|
3
4
|
module Hamlit
|
4
5
|
module Concerns
|
5
6
|
module Balanceable
|
7
|
+
include Lexable
|
8
|
+
|
6
9
|
def fetch_balanced_braces(all_tokens)
|
7
10
|
fetch_balanced_tokens(all_tokens, :on_lbrace, :on_rbrace)
|
8
11
|
end
|
@@ -34,8 +37,7 @@ module Hamlit
|
|
34
37
|
open_count = start_count
|
35
38
|
|
36
39
|
all_tokens.each_with_index do |token, index|
|
37
|
-
(
|
38
|
-
case type
|
40
|
+
case type_of(token)
|
39
41
|
when open_token then open_count += 1
|
40
42
|
when close_token then open_count -= 1
|
41
43
|
end
|
@@ -51,8 +53,7 @@ module Hamlit
|
|
51
53
|
open_count = start_count
|
52
54
|
|
53
55
|
tokens.each do |token|
|
54
|
-
(
|
55
|
-
case type
|
56
|
+
case type_of(token)
|
56
57
|
when open_token then open_count += 1
|
57
58
|
when close_token then open_count -= 1
|
58
59
|
end
|
@@ -15,7 +15,7 @@ module Hamlit
|
|
15
15
|
# Return nearest line's indent level since next line. This method ignores
|
16
16
|
# empty line. It returns -1 if next_line does not exist.
|
17
17
|
def next_indent
|
18
|
-
return 1 if
|
18
|
+
return 1 if !defined?(@indent_space) && fetch_indent(next_line).length > 0
|
19
19
|
count_indent(next_line)
|
20
20
|
end
|
21
21
|
|
@@ -48,7 +48,7 @@ module Hamlit
|
|
48
48
|
end
|
49
49
|
@indent_logs << indent
|
50
50
|
|
51
|
-
if
|
51
|
+
if !defined?(@indent_space) && @indent_logs.last != ''
|
52
52
|
@indent_space = @indent_logs.last
|
53
53
|
end
|
54
54
|
validate_indentation_consistency!(indent)
|
@@ -59,7 +59,7 @@ module Hamlit
|
|
59
59
|
|
60
60
|
def has_block?
|
61
61
|
return false unless next_line
|
62
|
-
return fetch_indent(next_line).length > 0 unless @indent_space
|
62
|
+
return fetch_indent(next_line).length > 0 unless defined?(@indent_space)
|
63
63
|
|
64
64
|
next_indent > @current_indent
|
65
65
|
end
|
@@ -69,7 +69,7 @@ module Hamlit
|
|
69
69
|
# Validate the template is using consitent indentation, 2 spaces or a tab.
|
70
70
|
def validate_indentation_consistency!(indent)
|
71
71
|
return false if indent.empty?
|
72
|
-
return false if
|
72
|
+
return false if !defined?(@indent_space) || @indent_space.empty?
|
73
73
|
|
74
74
|
unless acceptable_indent?(indent)
|
75
75
|
syntax_error!("Inconsistent indentation: #{indent_label(indent)} used for indentation, "\
|
@@ -105,7 +105,8 @@ module Hamlit
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def indent_rule
|
108
|
-
(@indent_space
|
108
|
+
return 0 unless defined?(@indent_space)
|
109
|
+
@indent_space.length
|
109
110
|
end
|
110
111
|
|
111
112
|
def fetch_indent(str)
|
data/lib/hamlit/parsers/tag.rb
CHANGED
data/lib/hamlit/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
|
+
require 'coveralls'
|
2
|
+
require 'simplecov'
|
1
3
|
require 'unindent'
|
2
4
|
require_relative 'spec_helper/document_generator'
|
3
5
|
require_relative 'spec_helper/render_helper'
|
4
6
|
require_relative 'spec_helper/test_case'
|
5
7
|
|
8
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
9
|
+
SimpleCov::Formatter::HTMLFormatter,
|
10
|
+
Coveralls::SimpleCov::Formatter
|
11
|
+
]
|
12
|
+
SimpleCov.start
|
13
|
+
|
6
14
|
RSpec.configure do |config|
|
7
15
|
config.include RenderHelper
|
8
16
|
|
@@ -80,7 +80,7 @@ module RenderHelper
|
|
80
80
|
|
81
81
|
def expect_implementation(impl, test, options, type, &block)
|
82
82
|
if type == :error
|
83
|
-
|
83
|
+
expect_any_error { block.call(test, options) }
|
84
84
|
begin
|
85
85
|
block.call(test, options)
|
86
86
|
rescue Exception => e
|
@@ -101,6 +101,14 @@ module RenderHelper
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
+
def expect_any_error(&block)
|
105
|
+
origin = RSpec::Expectations.configuration.warn_about_potential_false_positives?
|
106
|
+
RSpec::Expectations.configuration.warn_about_potential_false_positives = false
|
107
|
+
expect { block.call(test, options) }.to raise_error
|
108
|
+
ensure
|
109
|
+
RSpec::Expectations.configuration.warn_about_potential_false_positives = origin
|
110
|
+
end
|
111
|
+
|
104
112
|
def array_wrap(arr)
|
105
113
|
return arr if arr.is_a?(Array)
|
106
114
|
[arr]
|
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: 1.6.
|
4
|
+
version: 1.6.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: escape_utils
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: coveralls
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: erubis
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -234,6 +248,20 @@ dependencies:
|
|
234
248
|
- - ">="
|
235
249
|
- !ruby/object:Gem::Version
|
236
250
|
version: '0'
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: simplecov
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - ">="
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '0'
|
258
|
+
type: :development
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - ">="
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '0'
|
237
265
|
- !ruby/object:Gem::Dependency
|
238
266
|
name: slim
|
239
267
|
requirement: !ruby/object:Gem::Requirement
|