filigree 0.2.1 → 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: dccb22f2a08a333864492679856a0b37cc014b31
4
- data.tar.gz: 7bff283cd79b85f5c54bdd6d1dcc54a1ab93cc20
3
+ metadata.gz: f712ddbd29650262ea478bff2b9742c840929dee
4
+ data.tar.gz: 130669091a1246adac6601a9ec76848ac3772fc7
5
5
  SHA512:
6
- metadata.gz: 26ef0356f6547ae4a8cfac5b3b3972e228d2fa8807f2f98b4a85adec6f96244f8f525ba9ee7ad9742cff1361c3bbbdcf554a8847c97a3f8dee95448cfe719148
7
- data.tar.gz: 48a9e5758c19cdb3c31c3e59069044a073ffced5dfc60928dd8ac1cbc2e13245c826283917ecfdc27726efd7b05d0e8429ab51140bc205c58d016164a44e0b1c
6
+ metadata.gz: 896a8a4972016b0166c616c7115f598e5e43cd621451765e5435f39809818cc066fb751963531db5138030ade28096a1af08866067fb2fd8750bbda0c20e2af7
7
+ data.tar.gz: b008d5b0221615918e45a6a40bffa1619f19626aea7150b82a46b6ad3a8be8b7d185d80a659ed6ec9cafc79f75006f6961ac073a9c0b945755fd2f965658de25
@@ -15,7 +15,8 @@
15
15
  # Methods #
16
16
  ###########
17
17
 
18
- # Require a file, but fail gracefully if it isn't found.
18
+ # Require a file, but fail gracefully if it isn't found. If a block is given
19
+ # it will be called if the file is successfully required.
19
20
  #
20
21
  # @param [String] file File to be requested
21
22
  # @param [Boolean] print_failure To print a message on failure or not
@@ -4,5 +4,5 @@
4
4
  # Description: This file specifies the version number of Filigree.
5
5
 
6
6
  module Filigree
7
- VERSION = '0.2.1'
7
+ VERSION = '0.3.0'
8
8
  end
@@ -35,7 +35,7 @@ module Filigree
35
35
  # @return [Object] Result of calling the matched pattern's block
36
36
  #
37
37
  # @raise [MatchError] Raised when no matching pattern is found
38
- def call(*objects)
38
+ def visit(*objects)
39
39
  self.class.patterns.each do |pattern|
40
40
  @match_bindings = OpenStruct.new
41
41
 
@@ -45,7 +45,6 @@ module Filigree
45
45
  # If we didn't find anything we raise a MatchError.
46
46
  raise MatchError
47
47
  end
48
- alias :visit :call
49
48
 
50
49
  #############
51
50
  # Callbacks #
@@ -176,8 +175,8 @@ module Filigree
176
175
  # @param [Object] objects Objects to be visited
177
176
  #
178
177
  # @return [Array<Visitor>] The wrapped visitors
179
- def call(*objects)
180
- @visitors.each { |visitor| visitor.(*objects) }
178
+ def visit(*objects)
179
+ @visitors.each { |visitor| visitor.visit(*objects) }
181
180
  end
182
181
 
183
182
  # Construct a tour guide for a list of visitors.
@@ -203,7 +202,7 @@ module Filigree
203
202
  def visit(visitor, method = :preorder)
204
203
  case method
205
204
  when :preorder
206
- visitor.(self)
205
+ visitor.visit(self)
207
206
  children.compact.each { |child| child.visit(visitor, :preorder) }
208
207
 
209
208
  when :inorder
@@ -211,12 +210,12 @@ module Filigree
211
210
 
212
211
  while node = nodes.shift
213
212
  nodes += node.children.compact
214
- visitor.(node)
213
+ visitor.visit(node)
215
214
  end
216
215
 
217
216
  when :postorder
218
217
  children.compact.each { |child| child.visit(visitor, :postorder) }
219
- visitor.(self)
218
+ visitor.visit(self)
220
219
  end
221
220
  end
222
221
  end
data/test/tc_visitor.rb CHANGED
@@ -35,7 +35,7 @@ class VisitorTester < Minitest::Test
35
35
  end
36
36
 
37
37
  def visit(visitor)
38
- visitor.(self)
38
+ visitor.visit(self)
39
39
  end
40
40
  end
41
41
 
@@ -186,12 +186,12 @@ class VisitorTester < Minitest::Test
186
186
  def test_simple_visitor
187
187
  sv = SimpleVisitor.new
188
188
 
189
- assert_equal :one, sv.(1)
190
- assert_equal :two, sv.(:two)
191
- assert_equal :three, sv.('three')
192
- assert_equal :four, sv.(Foo.new(4))
193
- assert_equal :five, sv.(Foo.new(5))
194
- assert_equal :six, sv.(Foo.new('six'))
189
+ assert_equal :one, sv.visit(1)
190
+ assert_equal :two, sv.visit(:two)
191
+ assert_equal :three, sv.visit('three')
192
+ assert_equal :four, sv.visit(Foo.new(4))
193
+ assert_equal :five, sv.visit(Foo.new(5))
194
+ assert_equal :six, sv.visit(Foo.new('six'))
195
195
  end
196
196
 
197
197
  def test_stateful_visitor
@@ -216,7 +216,7 @@ class VisitorTester < Minitest::Test
216
216
  def test_visibility
217
217
  hmv = HelperMethodVisitor.new
218
218
 
219
- assert_equal :foo, hmv.(Foo.new(42))
219
+ assert_equal :foo, hmv.visit(Foo.new(42))
220
220
  end
221
221
 
222
222
  def test_visitable
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filigree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wailes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-25 00:00:00.000000000 Z
11
+ date: 2014-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -175,33 +175,33 @@ files:
175
175
  - AUTHORS
176
176
  - README.md
177
177
  - Rakefile
178
- - lib/filigree/request_file.rb
179
- - lib/filigree/class_methods_module.rb
180
- - lib/filigree/visitor.rb
181
178
  - lib/filigree/types.rb
182
- - lib/filigree/object.rb
183
- - lib/filigree/string.rb
184
- - lib/filigree/commands.rb
185
- - lib/filigree/abstract_class.rb
186
179
  - lib/filigree/boolean.rb
180
+ - lib/filigree/match.rb
187
181
  - lib/filigree/application.rb
182
+ - lib/filigree/abstract_class.rb
183
+ - lib/filigree/class.rb
184
+ - lib/filigree/string.rb
188
185
  - lib/filigree/version.rb
189
186
  - lib/filigree/configuration.rb
190
- - lib/filigree/match.rb
191
- - lib/filigree/class.rb
187
+ - lib/filigree/visitor.rb
188
+ - lib/filigree/object.rb
189
+ - lib/filigree/commands.rb
190
+ - lib/filigree/request_file.rb
191
+ - lib/filigree/class_methods_module.rb
192
192
  - lib/filigree.rb
193
- - test/tc_commands.rb
193
+ - test/tc_boolean.rb
194
+ - test/tc_object.rb
194
195
  - test/tc_types.rb
195
- - test/tc_class.rb
196
+ - test/tc_configuration.rb
197
+ - test/tc_commands.rb
196
198
  - test/tc_string.rb
197
- - test/tc_application.rb
198
- - test/tc_match.rb
199
199
  - test/tc_abstract_class.rb
200
- - test/tc_object.rb
201
- - test/tc_class_methods_module.rb
202
- - test/tc_configuration.rb
203
- - test/tc_boolean.rb
204
200
  - test/tc_visitor.rb
201
+ - test/tc_class_methods_module.rb
202
+ - test/tc_match.rb
203
+ - test/tc_class.rb
204
+ - test/tc_application.rb
205
205
  - test/ts_filigree.rb
206
206
  homepage: https://github.com/chriswailes/filigree
207
207
  licenses:
@@ -228,17 +228,17 @@ signing_key:
228
228
  specification_version: 4
229
229
  summary: Extra functionality for Ruby.
230
230
  test_files:
231
- - test/tc_commands.rb
231
+ - test/tc_boolean.rb
232
+ - test/tc_object.rb
232
233
  - test/tc_types.rb
233
- - test/tc_class.rb
234
+ - test/tc_configuration.rb
235
+ - test/tc_commands.rb
234
236
  - test/tc_string.rb
235
- - test/tc_application.rb
236
- - test/tc_match.rb
237
237
  - test/tc_abstract_class.rb
238
- - test/tc_object.rb
239
- - test/tc_class_methods_module.rb
240
- - test/tc_configuration.rb
241
- - test/tc_boolean.rb
242
238
  - test/tc_visitor.rb
239
+ - test/tc_class_methods_module.rb
240
+ - test/tc_match.rb
241
+ - test/tc_class.rb
242
+ - test/tc_application.rb
243
243
  - test/ts_filigree.rb
244
244
  has_rdoc: