membrane 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -12,3 +12,4 @@ RSpec::Core::RakeTask.new("spec:ci" => "ci:setup:rspec") do |t|
12
12
  t.rspec_opts = %w[--no-color --format documentation]
13
13
  end
14
14
 
15
+ task :default => [:spec]
@@ -16,15 +16,13 @@ class Membrane::Schemas::Bool < Membrane::Schemas::Base
16
16
  end
17
17
 
18
18
  def validate
19
- if !TRUTH_VALUES.include?(@object)
20
- fail!
21
- end
19
+ fail!(@object) if !TRUTH_VALUES.include?(@object)
22
20
  end
23
21
 
24
22
  private
25
23
 
26
- def fail!
27
- emsg = "Expected instance of true or false, given #{@object}"
24
+ def fail!(object)
25
+ emsg = "Expected instance of true or false, given #{object}"
28
26
  raise Membrane::SchemaValidationError.new(emsg)
29
27
  end
30
28
  end
@@ -21,14 +21,14 @@ class Membrane::Schemas::Class < Membrane::Schemas::Base
21
21
  end
22
22
 
23
23
  def validate
24
- fail! if !@object.kind_of?(@klass)
24
+ fail!(@klass, @object) if !@object.kind_of?(@klass)
25
25
  end
26
26
 
27
27
  private
28
28
 
29
- def fail!
30
- emsg = "Expected instance of #{@klass}," \
31
- + " given an instance of #{@object.class}"
29
+ def fail!(klass, object)
30
+ emsg = "Expected instance of #{klass}," \
31
+ + " given an instance of #{object.class}"
32
32
  raise Membrane::SchemaValidationError.new(emsg)
33
33
  end
34
34
  end
@@ -32,15 +32,15 @@ class Membrane::Schemas::Enum < Membrane::Schemas::Base
32
32
  end
33
33
  end
34
34
 
35
- fail!(@elem_schemas)
35
+ fail!(@elem_schemas, @object)
36
36
  end
37
37
 
38
38
  private
39
39
 
40
- def fail!(elem_schemas)
40
+ def fail!(elem_schemas, object)
41
41
  elem_schema_str = elem_schemas.map { |s| s.to_s }.join(", ")
42
42
 
43
- emsg = "Object #{@object} doesn't validate" \
43
+ emsg = "Object #{object} doesn't validate" \
44
44
  + " against any of #{elem_schema_str}"
45
45
  raise Membrane::SchemaValidationError.new(emsg)
46
46
  end
@@ -24,13 +24,13 @@ class Membrane::Schemas::List < Membrane::Schemas::Base
24
24
  end
25
25
 
26
26
  def validate
27
- fail! if !@object.kind_of?(Array)
27
+ fail!(@object) if !@object.kind_of?(Array)
28
28
  end
29
29
 
30
30
  private
31
31
 
32
- def fail!
33
- emsg = "Expected instance of Array, given instance of #{@object.class}"
32
+ def fail!(object)
33
+ emsg = "Expected instance of Array, given instance of #{object.class}"
34
34
  raise Membrane::SchemaValidationError.new(emsg)
35
35
  end
36
36
  end
@@ -83,13 +83,13 @@ class Membrane::Schemas::Record < Membrane::Schemas::Base
83
83
  end
84
84
 
85
85
  def validate
86
- fail! unless @object.kind_of?(Hash)
86
+ fail!(@object) unless @object.kind_of?(Hash)
87
87
  end
88
88
 
89
89
  private
90
90
 
91
- def fail!
92
- emsg = "Expected instance of Hash, given instance of #{@object.class}"
91
+ def fail!(object)
92
+ emsg = "Expected instance of Hash, given instance of #{object.class}"
93
93
  raise Membrane::SchemaValidationError.new(emsg)
94
94
  end
95
95
  end
@@ -27,13 +27,13 @@ class Membrane::Schemas::Regexp < Membrane::Schemas::Base
27
27
  end
28
28
 
29
29
  def validate
30
- fail! if !@object.kind_of?(String)
30
+ fail!(@object) if !@object.kind_of?(String)
31
31
  end
32
32
 
33
33
  private
34
34
 
35
- def fail!
36
- emsg = "Expected instance of String, given instance of #{@object.class}"
35
+ def fail!(object)
36
+ emsg = "Expected instance of String, given instance of #{object.class}"
37
37
  raise Membrane::SchemaValidationError.new(emsg)
38
38
  end
39
39
 
@@ -47,13 +47,13 @@ class Membrane::Schemas::Regexp < Membrane::Schemas::Base
47
47
  end
48
48
 
49
49
  def validate
50
- fail! if !@regexp.match(@object)
50
+ fail!(@regexp, @object) if !@regexp.match(@object)
51
51
  end
52
52
 
53
53
  private
54
54
 
55
- def fail!
56
- emsg = "Value #{@object} doesn't match regexp #{@regexp}"
55
+ def fail!(regexp, object)
56
+ emsg = "Value #{object} doesn't match regexp #{regexp.inspect}"
57
57
  raise Membrane::SchemaValidationError.new(emsg)
58
58
  end
59
59
  end
@@ -27,13 +27,13 @@ class Membrane::Schemas::Tuple < Membrane::Schemas::Base
27
27
  end
28
28
 
29
29
  def validate
30
- fail! if !@object.kind_of?(Array)
30
+ fail!(@object) if !@object.kind_of?(Array)
31
31
  end
32
32
 
33
33
  private
34
34
 
35
- def fail!
36
- emsg = "Expected instance of Array, given instance of #{@object.class}"
35
+ def fail!(object)
36
+ emsg = "Expected instance of Array, given instance of #{object.class}"
37
37
  raise Membrane::SchemaValidationError.new(emsg)
38
38
  end
39
39
  end
@@ -1,3 +1,3 @@
1
1
  module Membrane
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -4,7 +4,6 @@ require File.expand_path('../lib/membrane/version', __FILE__)
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "membrane"
6
6
  gem.version = Membrane::VERSION
7
- gem.date = "2012-07-09"
8
7
  gem.summary = "A DSL for validating data."
9
8
  gem.homepage = "http://www.cloudfoundry.org"
10
9
  gem.authors = ["mpage"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: membrane
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
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-07-09 00:00:00.000000000 Z
12
+ date: 2014-02-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ci_reporter