valuedate 0.0.2 → 0.0.3

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.rdoc CHANGED
@@ -43,7 +43,22 @@ Following matchers are defined:
43
43
  * is_a(Class)
44
44
  * equals(expected)
45
45
  * any(list of validators)
46
- * is(range, array or anything that responds_to #include?)
46
+ * in(range, array or anything that responds_to #include?)
47
+ * is { |value| boolean }
48
+ * not { |value| boolean }
49
+
50
+ === Missing matchers?
51
+
52
+ Use #is and #not:
53
+ schema = Valuedate.schema do
54
+ value.hash(
55
+ :array => value.not { |value| value.empty? },
56
+ :rgb => value.is { |value| value.size == 3 }
57
+ )
58
+ end
59
+
60
+ schema.validate(:array => [1], :rgb => [1,2,3]) # => true
61
+ schema.validate(:array => [1], :rgb => [1,2]) # => false
47
62
 
48
63
  == Defining matchers
49
64
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/lib/valuedate.rb CHANGED
@@ -52,7 +52,7 @@ class Valuedate
52
52
 
53
53
  def method_missing(method, *args, &block)
54
54
  if matcher = Valuedate.matchers[method]
55
- valid? { |value| matcher.call(value, *args) }
55
+ valid? { |value| matcher.call(value, *args, &block) }
56
56
  else
57
57
  super
58
58
  end
@@ -84,3 +84,5 @@ Valuedate.matcher(:any) do |value, *validators|
84
84
  validators.any? { |validator| validator.validate(value) }
85
85
  end
86
86
  Valuedate.matcher(:in) { |value, expected| expected.include?(value) }
87
+ Valuedate.matcher(:is) { |*value, &block| block.call(*value) }
88
+ Valuedate.matcher(:not) { |*value, &block| !block.call(*value) }
@@ -169,4 +169,14 @@ context "Valuedate" do
169
169
  asserts("invalid array") { !v(0) { value.in([1,2,3]) } }
170
170
  end
171
171
 
172
+ context "is and not" do
173
+ asserts("valid Fixnum") { v(1) { value.is { |value| value == 1 } } }
174
+ asserts("valid not Fixnum") { v(1) { value.not { |value| value == 2 } } }
175
+ asserts("invalid is Fixnum") { v(1) { !value.is { |value| value == 2 } } }
176
+ asserts("invalid not Fixnum") { v(1) { !value.not { |value| value == 1 } } }
177
+
178
+ asserts("valid empty array") { v([]) { value.is_a(Array).is { |value| value.empty? } } }
179
+ asserts("valid array size") { v([1,2]) { value.is { |value| value.size == 2 } } }
180
+ asserts("invalid array size") { !v([1,2]) { value.not { |value| value.size == 2 } } }
181
+ end
172
182
  end
data/valuedate.gemspec ADDED
@@ -0,0 +1,53 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{valuedate}
8
+ s.version = "0.0.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Peter Suschlik"]
12
+ s.date = %q{2010-01-28}
13
+ s.email = %q{peter-valuedate@suschlik.de}
14
+ s.extra_rdoc_files = [
15
+ "README.rdoc"
16
+ ]
17
+ s.files = [
18
+ ".gitignore",
19
+ "README.rdoc",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "lib/valuedate.rb",
23
+ "test.watchr",
24
+ "test/helper.rb",
25
+ "test/test_valuedate.rb",
26
+ "valuedate.gemspec"
27
+ ]
28
+ s.homepage = %q{http://github.com/splattael/valuedate}
29
+ s.rdoc_options = ["--charset=UTF-8"]
30
+ s.require_paths = ["lib"]
31
+ s.rubygems_version = %q{1.3.5}
32
+ s.summary = %q{Validates values.}
33
+ s.test_files = [
34
+ "test/test_valuedate.rb"
35
+ ]
36
+
37
+ if s.respond_to? :specification_version then
38
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
39
+ s.specification_version = 3
40
+
41
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
42
+ s.add_runtime_dependency(%q<riot>, [">= 0.10.11"])
43
+ s.add_development_dependency(%q<riot_notifier>, [">= 0"])
44
+ else
45
+ s.add_dependency(%q<riot>, [">= 0.10.11"])
46
+ s.add_dependency(%q<riot_notifier>, [">= 0"])
47
+ end
48
+ else
49
+ s.add_dependency(%q<riot>, [">= 0.10.11"])
50
+ s.add_dependency(%q<riot_notifier>, [">= 0"])
51
+ end
52
+ end
53
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valuedate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Suschlik
@@ -49,6 +49,7 @@ files:
49
49
  - test.watchr
50
50
  - test/helper.rb
51
51
  - test/test_valuedate.rb
52
+ - valuedate.gemspec
52
53
  has_rdoc: true
53
54
  homepage: http://github.com/splattael/valuedate
54
55
  licenses: []