jnunemaker-validatable 1.8.3 → 1.8.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,18 +1,23 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
 
4
- require File.dirname(__FILE__) + '/lib/validatable'
4
+ require File.expand_path('../lib/validatable', __FILE__)
5
5
 
6
6
  require 'jeweler'
7
7
  Jeweler::Tasks.new do |gem|
8
- gem.name = "jnunemaker-validatable"
9
- gem.summary = %Q{Validatable is a library for adding validations.}
10
- gem.description = %Q{Validatable is a library for adding validations.}
11
- gem.email = "nunemaker@gmail.com"
12
- gem.homepage = "http://github.com/jnunemaker/validatable"
8
+ gem.name = 'jnunemaker-validatable'
9
+ gem.summary = 'Validatable is a library for adding validations.'
10
+ gem.description = 'Validatable is a library for adding validations.'
11
+ gem.email = 'nunemaker@gmail.com'
12
+ gem.homepage = 'http://github.com/jnunemaker/validatable'
13
13
  gem.authors = ['Jay Fields', 'John Nunemaker']
14
14
  gem.files = FileList['lib/**/*.rb', '[A-Z]*', 'test/**/*'].to_a
15
15
  gem.version = Validatable::Version
16
+
17
+ gem.add_dependency('activesupport', '>= 2.3.4')
18
+ gem.add_development_dependency('mocha', '>= 0.9.8')
19
+ gem.add_development_dependency('dust')
20
+ gem.add_development_dependency('expectations')
16
21
  end
17
22
 
18
23
  Jeweler::GemcutterTasks.new
@@ -1,5 +1,11 @@
1
+ # gem 'activesupport', '2.3.5'
2
+
3
+ begin
4
+ require 'active_support/core_ext/object/blank' # newer versions of active_support (>= 3.0)
5
+ rescue LoadError => e
6
+ require 'active_support/all' # support older versions of active_support (<= 2.3.5)
7
+ end
1
8
  require 'forwardable'
2
- require 'active_support/all'
3
9
 
4
10
  require 'validatable/object_extension'
5
11
  require 'validatable/errors'
@@ -24,5 +30,5 @@ require 'validatable/validations/validates_each'
24
30
  require 'validatable/validations/validates_associated'
25
31
 
26
32
  module Validatable
27
- Version = '1.8.3'
33
+ Version = '1.8.4'
28
34
  end
@@ -19,6 +19,19 @@ module Validatable
19
19
  !@errors[attribute.to_sym].nil?
20
20
  end
21
21
 
22
+ # Adds an error to the base object instead of any particular attribute. This is used
23
+ # to report errors that don't tie to any specific attribute, but rather to the object
24
+ # as a whole. These error messages don't get prepended with any field name when iterating
25
+ # with +each_full+, so they should be complete sentences.
26
+ def add_to_base(msg)
27
+ add(:base, msg)
28
+ end
29
+
30
+ # Returns errors assigned to the base object through +add_to_base+ according to the normal rules of <tt>on(attribute)</tt>.
31
+ def on_base
32
+ on(:base)
33
+ end
34
+
22
35
  # call-seq: on(attribute)
23
36
  #
24
37
  # * Returns nil, if no errors are associated with the specified +attribute+.
@@ -1,7 +1,7 @@
1
+ require 'set'
1
2
  require 'test/unit'
2
3
  require 'mocha'
3
4
  require 'dust'
4
- require 'set'
5
5
  require 'expectations'
6
6
 
7
7
  require File.expand_path(File.dirname(__FILE__) + '/../lib/validatable')
@@ -19,12 +19,6 @@ class << Test::Unit::TestCase
19
19
  end
20
20
  end
21
21
 
22
- class Test::Unit::TestCase
23
- def assert_array_equal a, b
24
- assert_equal Set.new(a), Set.new(b)
25
- end
26
- end
27
-
28
22
  class Array
29
23
  def to_blank_options_hash
30
24
  self.inject({}) {|hash, value| hash[value] = nil; hash }
@@ -7,6 +7,12 @@ Expectations do
7
7
  errors.on(:attribute)
8
8
  end
9
9
 
10
+ expect "message" do
11
+ errors = Validatable::Errors.new
12
+ errors.add_to_base("message")
13
+ errors.on_base
14
+ end
15
+
10
16
  expect ["message"] do
11
17
  errors = Validatable::Errors.new
12
18
  errors.add(:attribute, "message")
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jnunemaker-validatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 8
8
+ - 4
9
+ version: 1.8.4
5
10
  platform: ruby
6
11
  authors:
7
12
  - Jay Fields
@@ -10,10 +15,61 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2010-03-01 00:00:00 -05:00
18
+ date: 2010-04-18 00:00:00 -04:00
14
19
  default_executable:
15
- dependencies: []
16
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: activesupport
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 2
30
+ - 3
31
+ - 4
32
+ version: 2.3.4
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: mocha
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 0
44
+ - 9
45
+ - 8
46
+ version: 0.9.8
47
+ type: :development
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: dust
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ type: :development
60
+ version_requirements: *id003
61
+ - !ruby/object:Gem::Dependency
62
+ name: expectations
63
+ prerelease: false
64
+ requirement: &id004 !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ type: :development
72
+ version_requirements: *id004
17
73
  description: Validatable is a library for adding validations.
18
74
  email: nunemaker@gmail.com
19
75
  executables: []
@@ -88,18 +144,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
144
  requirements:
89
145
  - - ">="
90
146
  - !ruby/object:Gem::Version
147
+ segments:
148
+ - 0
91
149
  version: "0"
92
- version:
93
150
  required_rubygems_version: !ruby/object:Gem::Requirement
94
151
  requirements:
95
152
  - - ">="
96
153
  - !ruby/object:Gem::Version
154
+ segments:
155
+ - 0
97
156
  version: "0"
98
- version:
99
157
  requirements: []
100
158
 
101
159
  rubyforge_project:
102
- rubygems_version: 1.3.5
160
+ rubygems_version: 1.3.6
103
161
  signing_key:
104
162
  specification_version: 3
105
163
  summary: Validatable is a library for adding validations.