filigree 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/filigree/match.rb +1 -1
- data/lib/filigree/version.rb +1 -1
- data/test/tc_match.rb +8 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 508a55d16a4f1321ba4c9042758b1a497bf85827
|
4
|
+
data.tar.gz: d5ce1b0d135d319bb5a20425bf74ce6d8ade72c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0683038d43739552cd653c997fd28b8c1f435db879166bc2c50475817528fb8061ef2b5fd11c3c948b8c005e237ab6d81d24963e77d8ca0b60534cb6af8eead
|
7
|
+
data.tar.gz: 1bc7acb9d54d99a95ff8229c384d57b3929e6ab24b3478fbe6ebeb19888d4339c6f058ca39bbc078db452f568f69c011cb46874d90b27819abbbeb4f0c3c8411
|
data/README.md
CHANGED
@@ -73,7 +73,7 @@ The most basic pattern is the literal. Here, the object or objects being matche
|
|
73
73
|
foo(42) # => :other
|
74
74
|
```
|
75
75
|
|
76
|
-
You may also match against variables. This can sometimes conflict with the next kind of pattern, which is a binding pattern. Here, the pattern will match any object, and then make the object it matched available to the *with block* via an attribute reader. This is accomplished using the method_missing callback, so if there is a variable or function with that name you might accidentally compare against a variable or returned value. To bind to a name that is already in scope you can use either the {Filigree::MatchEnvironment#Bind} method or the
|
76
|
+
You may also match against variables. This can sometimes conflict with the next kind of pattern, which is a binding pattern. Here, the pattern will match any object, and then make the object it matched available to the *with block* via an attribute reader. This is accomplished using the method_missing callback, so if there is a variable or function with that name you might accidentally compare against a variable or returned value. To bind to a name that is already in scope you can use either the {Filigree::MatchEnvironment#Bind} method or the `~` Symbol method. In addition, class and destructuring pattern results (see bellow) can be bound to a variable by using the {Filigree::BasicPattern#as} method.
|
77
77
|
|
78
78
|
```Ruby
|
79
79
|
var = 42
|
@@ -94,7 +94,7 @@ x = 3
|
|
94
94
|
match 42 do
|
95
95
|
with(Bind(:x)) { x }
|
96
96
|
# Equivalent to the line above.
|
97
|
-
with(
|
97
|
+
with(~:x) { x }
|
98
98
|
with(42) { :hoopy }
|
99
99
|
end
|
100
100
|
```
|
data/lib/filigree/match.rb
CHANGED
data/lib/filigree/version.rb
CHANGED
data/test/tc_match.rb
CHANGED
@@ -111,11 +111,11 @@ class MatchTester < Minitest::Test
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
def
|
114
|
+
def match_tester_squiggle_bind(o)
|
115
115
|
match o do
|
116
|
-
with(Fixnum.as(
|
117
|
-
with(Float.as(
|
118
|
-
with(String.as(
|
116
|
+
with(Fixnum.as(~:a)) { [:Fixnum, a] }
|
117
|
+
with(Float.as(~:a)) { [:Float, a] }
|
118
|
+
with(String.as(~:a)) { [:String, a] }
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
@@ -239,10 +239,10 @@ class MatchTester < Minitest::Test
|
|
239
239
|
assert_equal :Regexp, match_tester_literal(/a/)
|
240
240
|
end
|
241
241
|
|
242
|
-
def
|
243
|
-
assert_equal [:Fixnum, 42],
|
244
|
-
assert_equal [:Float, 42.0],
|
245
|
-
assert_equal [:String, 'foo'],
|
242
|
+
def test_squiggle_bind
|
243
|
+
assert_equal [:Fixnum, 42], match_tester_squiggle_bind(42)
|
244
|
+
assert_equal [:Float, 42.0], match_tester_squiggle_bind(42.0)
|
245
|
+
assert_equal [:String, 'foo'], match_tester_squiggle_bind('foo')
|
246
246
|
end
|
247
247
|
|
248
248
|
def test_manual_bind
|
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.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wailes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|