indentation-parser 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
File without changes
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "indentation-parser"
5
- gem.version = "1.0.2"
5
+ gem.version = "1.0.3"
6
6
 
7
7
  gem.authors = ["Samuel Müller"]
8
8
  gem.email = ["mueller.samu@gmail.com"]
@@ -47,7 +47,7 @@ class IndentationParser
47
47
  handle_less_indentation previous_node, new_node, node_stack
48
48
  end
49
49
  end
50
- handle_leaf node_stack.last
50
+ handle_node node_stack.last, true
51
51
  root
52
52
  end
53
53
 
@@ -59,14 +59,14 @@ class IndentationParser
59
59
 
60
60
  def handle_same_indentation new_node, node_stack
61
61
  leaf = node_stack.pop
62
- handle_leaf leaf
62
+ handle_node leaf, true
63
63
  node_stack.last.add new_node
64
64
  node_stack.push new_node
65
65
  end
66
66
 
67
67
  def handle_less_indentation previous_node, new_node, node_stack
68
68
  leaf = node_stack.pop
69
- handle_leaf leaf
69
+ handle_node leaf, true
70
70
  (previous_node.indentation - new_node.indentation).times do
71
71
  node_stack.pop
72
72
  end
@@ -33,25 +33,39 @@ class IndentationParser
33
33
  handled
34
34
  end
35
35
 
36
- def handle_node node
36
+ def handle_node node, leaf = false
37
37
  handled = execute_child_of_handler node
38
-
39
- return handled if handled
40
-
38
+ return true if handled
39
+
41
40
  handled = try_to_handle @node_handlers, node
42
- if not handled and @default
41
+ return true if handled
42
+
43
+ if leaf
44
+ handled = handle_leaf node
45
+ end
46
+
47
+ return true if handled
48
+
49
+ if @default
43
50
  node_value = call_handler @default, node if @default
44
51
  node.set_value node_value
52
+ return true
53
+ else
54
+ return false
45
55
  end
46
56
  end
47
57
 
48
58
  def handle_leaf node
49
59
  handled = try_to_handle @leaf_handlers, node
50
- if not handled and @on_leaf
60
+
61
+ return true if handled
62
+
63
+ if @on_leaf
51
64
  node_value = call_handler @on_leaf, node
52
65
  node.set_value node_value
66
+ return true
53
67
  else
54
- handle_node node
68
+ return false
55
69
  end
56
70
  end
57
71
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: indentation-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-21 00:00:00.000000000 Z
12
+ date: 2012-09-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec