object-template 0.3 → 0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26ea40dd81c9a57d0aa33469adf8d6408bb3682f
4
- data.tar.gz: 683ee591d159652402b2f213751193accbde5bca
3
+ metadata.gz: 76d8da44dc2938f0d1e550a68f8db2bbd036b748
4
+ data.tar.gz: 523ee826c82b15d1ce165dde2f379ba565c6e4c4
5
5
  SHA512:
6
- metadata.gz: 931b827d49c540ff50ad42d562a5bc2ac29e54bd17a83eb49faefa8f1e65fbd5e7caa55347d02ee66fd21927d66087d383dce8e09682c038457a90f5ecdeb07a
7
- data.tar.gz: e62e883bc92e2d0740791fc27b416283ff0345851c15d61605ee8da4049e5ec297061c3a019eb08540c8c9d7f7983a0db8f396af24ffed4e3aec58d0fc718050
6
+ metadata.gz: b841e59e678cf59835379afd5378a91c87c1cfd5090c7e41b332f75ee94f1633f4361147da8ced800a7576fddb62ecbd4e7294ead0bedd6930384f8570ff16b2
7
+ data.tar.gz: b12e0c975089a8315a7e0a2643c36ced151d43d75012553f491786db5596bc822fb188903648ea44a67a51e474cefa6d318631c66bf7b247f6846b1058600cbd
@@ -2,7 +2,7 @@ require 'set'
2
2
 
3
3
  # Base class for classes of templates used to match somewhat arbitrary objects.
4
4
  class ObjectTemplate
5
- VERSION = "0.3"
5
+ VERSION = "0.4"
6
6
 
7
7
  attr_reader :spec
8
8
 
@@ -133,11 +133,14 @@ class PortableObjectTemplate < ObjectTemplate
133
133
  end
134
134
  end
135
135
 
136
+ BOOLEAN = MemberMatchingSet.new([true, false])
137
+
136
138
  CLASS_FOR = {
137
- "number" => Numeric,
138
- "string" => String,
139
- "list" => Array,
140
- "map" => Hash
139
+ "boolean" => BOOLEAN,
140
+ "number" => Numeric,
141
+ "string" => String,
142
+ "list" => Array,
143
+ "map" => Hash
141
144
  }
142
145
 
143
146
  CLASS_FOR.default_proc = proc do |h,k|
data/test/test-match.rb CHANGED
@@ -110,15 +110,19 @@ ne3 ["foo"], [/o{3,}/], [{regex: "o{3,}"}]
110
110
  #= 6. every test that can be expressed in terms of a type in the
111
111
  #= template
112
112
  #=
113
+ eq3 [true], [TrueClass], [{type: "boolean"}]
114
+ eq3 [false], [FalseClass], [{type: "boolean"}]
113
115
  eq3 [42], [Numeric], [{type: "number"}]
114
116
  eq3 ["foo"], [String], [{type: "string"}]
115
117
  eq3 [[1,2,3]], [Array], [{type: "list"}]
116
- eq3 [{a:1, b:2}], [Hash], [{type: "map"}]
118
+ eq3 [{a:1, b:2}], [Hash], [{type: "map"}]
117
119
  #=========================================================
120
+ ne3 ["42"], [TrueClass], [{type: "boolean"}]
121
+ ne3 [0], [FalseClass], [{type: "boolean"}]
118
122
  ne3 ["42"], [Numeric], [{type: "number"}]
119
123
  ne3 [123], [String], [{type: "string"}]
120
124
  ne3 [{a:1, b:2}], [Array], [{type: "list"}]
121
- ne3 [[1,2,3]], [Hash], [{type: "map"}]
125
+ ne3 [[1,2,3]], [Hash], [{type: "map"}]
122
126
  #=========================================================
123
127
  end
124
128
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: object-template
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel VanderWerf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-21 00:00:00.000000000 Z
11
+ date: 2013-12-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Templates for matching objects.
14
14
  email: vjoel@users.sourceforge.net
@@ -22,13 +22,13 @@ files:
22
22
  - COPYING
23
23
  - Rakefile
24
24
  - lib/object-template.rb
25
- - bench/bench-match.rb
26
25
  - bench/lib/bench.rb
27
- - test/test-key-conv.rb
28
- - test/test-match.rb
29
- - test/test-errors.rb
26
+ - bench/bench-match.rb
30
27
  - test/lib/assert-threequal.rb
31
28
  - test/lib/eq3.rb
29
+ - test/test-match.rb
30
+ - test/test-key-conv.rb
31
+ - test/test-errors.rb
32
32
  homepage: https://github.com/vjoel/object-template
33
33
  licenses:
34
34
  - BSD
@@ -62,7 +62,7 @@ signing_key:
62
62
  specification_version: 4
63
63
  summary: Templates for matching objects
64
64
  test_files:
65
- - test/test-key-conv.rb
66
65
  - test/test-match.rb
66
+ - test/test-key-conv.rb
67
67
  - test/test-errors.rb
68
68
  has_rdoc: