jievro-ast 0.2.0 → 0.3.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: ebd32482a1dcf426a1e265165b5378b6e7da8bbb
4
- data.tar.gz: 468191cc766d63b829e675fc2792805aca7b8942
3
+ metadata.gz: 33a181a0534dd9330f5d1c5b89ac33661b9342c3
4
+ data.tar.gz: ecd41b90443142d815da9d22bd4d710345d1489d
5
5
  SHA512:
6
- metadata.gz: 8431d195cc533931b204b6ff0be6e6eca9f6fa5935ddfdd969497d683719ae13608fe77f3be3071e4ee5838526eb68ccc3b4c282b67cf033594b6d61fc4c50a6
7
- data.tar.gz: 84d519c7f63362c3728698d70672b5383072316c1b4ad08d8396a4a1887e0eaf0f82b9a43c570037a8e7e1b813c7f9e8d13f5a8406d9c855fde2d01c6b4bfaaa
6
+ metadata.gz: 7919d97abb207eaf55de1462937a435b497ec1905a1833a9b1c5626f6e09a0c121aceb732f7bc121f35939c56fd06e7a19ceb34c395e966c201568ad66c7aa12
7
+ data.tar.gz: aea2150135592b1f5ea645b59a154d177a2b1be91ec668a74ac80dc4f1f1d324e879b4c4ff7e03867600180188faf964e65a441bc33f53aa6404f217d196a4cc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jievro-ast (0.1.0)
4
+ jievro-ast (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  module Jievro
2
2
  module Ast
3
3
  class Node
4
- attr_reader :parent, :type, :key, :value
4
+ attr_reader :parent, :type, :value
5
5
 
6
6
  def initialize(initializer, parent = nil, key = nil)
7
7
  @parent = parent
@@ -29,6 +29,10 @@ module Jievro
29
29
  @value[key]
30
30
  end
31
31
 
32
+ def key
33
+ @key.to_s
34
+ end
35
+
32
36
  def keys
33
37
  @value.keys
34
38
  end
@@ -44,6 +48,21 @@ module Jievro
44
48
  {}
45
49
  end
46
50
 
51
+ def each
52
+ each_with_index do |v, i|
53
+ yield v
54
+ end
55
+ end
56
+
57
+ def each_with_index
58
+ fatal Exception, 'Cannot loop a literal node' \
59
+ if @type == '__literal'
60
+
61
+ @value.keys.each do |v|
62
+ yield @value[v], v
63
+ end
64
+ end
65
+
47
66
  private
48
67
 
49
68
  def initialize_as_literal(initializer)
@@ -68,12 +87,10 @@ module Jievro
68
87
  @type = initializer[:__type]
69
88
 
70
89
  initializer.keys.each do |k|
71
- key = k.to_s
72
-
73
90
  # skip all the meta info
74
- next if key.to_s.start_with?('__')
91
+ next if k.to_s.to_s.start_with?('__')
75
92
 
76
- @value[k] = Node.new(initializer[k], self, key)
93
+ @value[k] = Node.new(initializer[k], self, k)
77
94
  end
78
95
  end
79
96
  end
@@ -1,5 +1,5 @@
1
1
  module Jievro
2
2
  module Ast
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jievro-ast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Azzalini