haml_parser 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1ee2e978b5969cf7f28d4b58df013a97988d26e
4
- data.tar.gz: 2c18d9f3232488d668794f0c920b2fd3fc58a989
3
+ metadata.gz: 2018bdc583b86d3e184e4f98d1ac356d41641ef7
4
+ data.tar.gz: ce85adf4d59e27557bfa16670094a771be76d6bd
5
5
  SHA512:
6
- metadata.gz: 70f270214c9c7bf34807e4b30fe70bed2d6e67c21f1d94541257739b3cddc6c012dbacd6a41d9feba25e8647c3c7bb13cf79cb1f9f6b47a0d5de4cb737cee1b6
7
- data.tar.gz: 77c69264173959110a1e28661c06c1694d5f73b5c37306d6f205d2e7a08187f4d37c94ac091c5c2edd9c8f04c9e203ba43e969d3fa1b4414f6de253d08ac0315
6
+ metadata.gz: adf34f95177de3d6cedc65536405fe387b5b9ff10ffd9b7a3fc21344731d692253468629ddc87aa2b2d536163462e71e3323f529710f402fd05375e9cef98b28
7
+ data.tar.gz: 5cee1370ebfa90524568fec5948549b7cbd890872eb6a538ba7c5825e5d12450859ff5b3547da54d94fb31e7d3cad29570fefbc7b9fa192269135c49a89db75a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.2.0 (2015-11-15)
2
+ - Remove `Ast::SilentScript#mid_block_keyword` attribute
3
+ - Add `Ast::Script#keyword` and `Ast::SilentScript#keyword` attribute
4
+
1
5
  # 0.1.1 (2015-10-13)
2
6
  - Fix missing require in CLI
3
7
 
@@ -65,6 +65,7 @@ module HamlParser
65
65
  Script = Struct.new(
66
66
  :children,
67
67
  :script,
68
+ :keyword,
68
69
  :escape_html,
69
70
  :preserve,
70
71
  :filename,
@@ -87,16 +88,9 @@ module HamlParser
87
88
  end
88
89
  end
89
90
 
90
- SilentScript = Struct.new(:children, :script, :mid_block_keyword, :filename, :lineno) do
91
+ SilentScript = Struct.new(:children, :script, :keyword, :filename, :lineno) do
91
92
  include HasChildren
92
93
 
93
- def initialize(*)
94
- super
95
- if mid_block_keyword.nil?
96
- self.mid_block_keyword = false
97
- end
98
- end
99
-
100
94
  def to_h
101
95
  super.merge(type: 'silent_script')
102
96
  end
@@ -141,7 +141,11 @@ module HamlParser
141
141
  end
142
142
 
143
143
  def parse_script(text)
144
- @ast << ScriptParser.new(@line_parser).parse(text)
144
+ node = ScriptParser.new(@line_parser).parse(text)
145
+ if node.is_a?(Ast::Script)
146
+ node.keyword = block_keyword(node.script)
147
+ end
148
+ @ast << node
145
149
  end
146
150
 
147
151
  def parse_silent_script(text)
@@ -152,6 +156,7 @@ module HamlParser
152
156
  node = create_node(Ast::SilentScript)
153
157
  script = text[/\A- *(.*)\z/, 1]
154
158
  node.script = [script, *RubyMultiline.read(@line_parser, script)].join("\n")
159
+ node.keyword = block_keyword(node.script)
155
160
  @ast << node
156
161
  end
157
162
 
@@ -191,14 +196,8 @@ module HamlParser
191
196
  nil
192
197
  end
193
198
 
194
- def indent_leave(indent_level, text)
199
+ def indent_leave(_indent_level, _text)
195
200
  parent_ast = @stack.pop
196
- case @ast
197
- when Ast::SilentScript
198
- if indent_level == @indent_tracker.current_level
199
- @ast.mid_block_keyword = mid_block_keyword?(text)
200
- end
201
- end
202
201
  @ast = parent_ast
203
202
  nil
204
203
  end
@@ -216,10 +215,6 @@ module HamlParser
216
215
  end
217
216
  end
218
217
 
219
- def mid_block_keyword?(text)
220
- MID_BLOCK_KEYWORDS.include?(block_keyword(text))
221
- end
222
-
223
218
  def syntax_error!(message)
224
219
  raise Error.new(message, @line_parser.lineno)
225
220
  end
@@ -1,3 +1,3 @@
1
1
  module HamlParser
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kohei Suzuki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-13 00:00:00.000000000 Z
11
+ date: 2015-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  version: '0'
192
192
  requirements: []
193
193
  rubyforge_project:
194
- rubygems_version: 2.5.0
194
+ rubygems_version: 2.4.5.1
195
195
  signing_key:
196
196
  specification_version: 4
197
197
  summary: Parser of Haml template language