ratatouille 1.4.2 → 1.4.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.
@@ -1,3 +1,9 @@
1
+ ## 1.4.3
2
+
3
+ ### Updates
4
+
5
+ * Fixing error array output so that it is actually useful and readable.
6
+
1
7
  ## 1.4.2
2
8
 
3
9
  ### Corrections
@@ -41,7 +41,7 @@ module Ratatouille
41
41
  unless @unwrap_block == true
42
42
  unless @is_a.nil?
43
43
  unless @is_a === @ratifiable_object[key]
44
- validation_error("key value is not of type #{@is_a}")
44
+ validation_error("value is not of type #{@is_a}", key.to_s)
45
45
  return
46
46
  end
47
47
  end
@@ -40,7 +40,7 @@ module Ratatouille
40
40
  # @return [String]
41
41
  def name
42
42
  @name ||= @ratifiable_object.class.to_s
43
- end
43
+ end#name
44
44
 
45
45
 
46
46
  # Set name of instance
@@ -53,22 +53,22 @@ module Ratatouille
53
53
  @name = namein unless namein.blank?
54
54
  end
55
55
  @name
56
- end
56
+ end#name=
57
57
 
58
58
 
59
59
  # Add validation error. Useful for custom validations.
60
60
  # @param [String] err_in
61
61
  # @param [String] context
62
62
  # @return [void]
63
- def validation_error(err_in, context="/")
63
+ def validation_error(err_in, context="/" )
64
64
  case err_in
65
65
  when String
66
66
  return if err_in.blank?
67
67
  @errors[context] = [] unless @errors[context]
68
- @errors[context] << "#{@name}: #{err_in}"
68
+ @errors[context] << err_in
69
69
  end
70
70
  rescue Exception => e
71
- @errors["/"] << "#{@name}: #{e.message}"
71
+ @errors[context] << "#{e.message}"
72
72
  end#validation_error
73
73
 
74
74
 
@@ -104,7 +104,7 @@ module Ratatouille
104
104
  else []
105
105
  end
106
106
 
107
- all_errs << namespace_error_array(item_errs, "[#{i}]")
107
+ all_errs << namespace_error_array(item_errs, "#{i}")
108
108
  all_errs.flatten!
109
109
  end
110
110
  when Hash
@@ -159,7 +159,7 @@ module Ratatouille
159
159
  when TrueClass, FalseClass
160
160
  # OK to enter block
161
161
  else
162
- validation_error("object is not a boolean")
162
+ validation_error("#{name} is not a boolean")
163
163
  return
164
164
  end
165
165
  end
@@ -204,14 +204,14 @@ module Ratatouille
204
204
  when id.to_s =~ /^is_not_(.*)$/
205
205
  if @ratifiable_object.respond_to?("#{$1}?")
206
206
  if @ratifiable_object.send("#{$1}?") == true
207
- validation_error("is #{$1}")
207
+ validation_error("#{name} is #{$1}")
208
208
  return
209
209
  end
210
210
  end
211
211
  when id.to_s =~ /^is_(.*)$/
212
212
  if @ratifiable_object.respond_to?("#{$1}?")
213
213
  if @ratifiable_object.send("#{$1}?") == false
214
- validation_error("is not #{$1}")
214
+ validation_error("#{name} is not #{$1}")
215
215
  return
216
216
  end
217
217
  end
@@ -1,4 +1,4 @@
1
1
  module Ratatouille
2
2
  # Gem Version
3
- VERSION = "1.4.2"
3
+ VERSION = "1.4.3"
4
4
  end
@@ -77,12 +77,6 @@ describe Ratatouille::Ratifier do
77
77
  validation_error("some error")
78
78
  end
79
79
  test.errors_array.should have(1).String
80
-
81
- test = RatifierTest.new({}) do
82
- validation_error("some error")
83
- validation_error("another error")
84
- end
85
- test.errors_array.should have(2).String
86
80
  end
87
81
 
88
82
  it "should not create an error when called with a non-string argument" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ratatouille
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 2
10
- version: 1.4.2
9
+ - 3
10
+ version: 1.4.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Johnson