mallow 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +5 -5
- data/lib/mallow/version.rb +1 -1
- data/mallow.gemspec +1 -1
- data/test/case/control.rb +3 -3
- data/test/unit/meta.rb +1 -1
- data/test/unit/monad_laws.rb +1 -1
- data/test/unit/rule.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -10,7 +10,7 @@ To mallow it is very easy little boy. First marshal, then mallow:
|
|
10
10
|
|
11
11
|
```ruby
|
12
12
|
mallow = Mallow.build do |match|
|
13
|
-
match.
|
13
|
+
match.a(Hash).to {"#{keys.first} #{values.first}"}
|
14
14
|
end
|
15
15
|
```
|
16
16
|
Now feed your mallow some iterable data:
|
@@ -18,14 +18,14 @@ Now feed your mallow some iterable data:
|
|
18
18
|
data = [{:hay => :good_buddy}]
|
19
19
|
mallow.fluff data #=> ["hay good_buddy"]
|
20
20
|
```
|
21
|
-
Mallow's DSL has a
|
21
|
+
Mallow's DSL has a fairly rich vocabulary of built-in helpers:
|
22
22
|
```ruby
|
23
23
|
Mallow.build { |match|
|
24
24
|
match.a(Float).to &:to_i
|
25
25
|
match.tuple(3).where{last != 0}.to {|a,b,c| (a + b) / c}
|
26
26
|
match.an(Array).and_hashify_with( :name, :age ).and_make_a( Person ).and &:save!
|
27
|
-
match.
|
28
|
-
match.
|
27
|
+
match.a(Fixnum).of_size(8).to {'8bit'}
|
28
|
+
match.a(String).to{upcase}
|
29
29
|
match.*.to { WILDCARD }
|
30
30
|
}.fluff( data )
|
31
31
|
```
|
@@ -46,7 +46,7 @@ Luckily the second reason is that this should be done as part of some kind of po
|
|
46
46
|
```ruby
|
47
47
|
doubler = Mallow.build do |m|
|
48
48
|
m.a(Fixnum).^(type: Fixnum).to {|n| n*2}
|
49
|
-
m
|
49
|
+
m.*.to {nil}.^(matched: false)
|
50
50
|
end
|
51
51
|
|
52
52
|
data = doubler.fluff [1,2,:moo] #=> [2, 4, nil]
|
data/lib/mallow/version.rb
CHANGED
data/mallow.gemspec
CHANGED
@@ -12,6 +12,6 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.homepage = 'http://github.com/gwentacle/mallow'
|
13
13
|
spec.summary = 'Tiny universal data pattern matcher / dispatcher'
|
14
14
|
spec.description = 'Tiny universal data pattern matcher / dispatcher'
|
15
|
-
spec.add_development_dependency 'graham', '>=0.0.
|
15
|
+
spec.add_development_dependency 'graham', '>=0.0.3'
|
16
16
|
end
|
17
17
|
|
data/test/case/control.rb
CHANGED
@@ -32,11 +32,11 @@ class Exceptions
|
|
32
32
|
|
33
33
|
end
|
34
34
|
|
35
|
-
Graham.pp(Cases) {|that|
|
36
|
-
that.test_case_1.
|
35
|
+
Graham.pp(Cases.new) {|that|
|
36
|
+
that.test_case_1.returns_an(Array).that_is [ 198, 'ASDF', 'QWER', 15, 94, 'coolstorybro' ]
|
37
37
|
}
|
38
38
|
|
39
|
-
Graham.pp(Exceptions) {|that|
|
39
|
+
Graham.pp(Exceptions.new) {|that|
|
40
40
|
that.division_by_zero.raises_a ZeroDivisionError
|
41
41
|
that.calling_a_nonexistent_method.raises_a NoMethodError
|
42
42
|
that.an_unmatched_element.raises_a Mallow::MatchException
|
data/test/unit/meta.rb
CHANGED
data/test/unit/monad_laws.rb
CHANGED
data/test/unit/rule.rb
CHANGED
@@ -39,7 +39,7 @@ class RuleTests
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
Graham.pp(RuleTests) do |that|
|
42
|
+
Graham.pp(RuleTests.new) do |that|
|
43
43
|
that.unwrapping_an_empty_rule.raises_a Mallow::MatchException
|
44
44
|
that.unwrapping_a_failing_rule.raises_a Mallow::MatchException
|
45
45
|
that.unwrapping_a_passing_rule.returns_a(Mallow::Meta).such_that { val == :value }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mallow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
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-11-
|
12
|
+
date: 2012-11-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: graham
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.0.
|
21
|
+
version: 0.0.3
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.0.
|
29
|
+
version: 0.0.3
|
30
30
|
description: Tiny universal data pattern matcher / dispatcher
|
31
31
|
email: feivel@sdf.org
|
32
32
|
executables: []
|