ripple 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,10 +11,10 @@ gemspec = Gem::Specification.new do |gem|
11
11
  gem.email = "seancribbs@gmail.com"
12
12
  gem.homepage = "http://seancribbs.github.com/ripple"
13
13
  gem.authors = ["Sean Cribbs"]
14
- gem.add_development_dependency "rspec", "~>2.0.0.beta.18"
15
- gem.add_dependency "riak-client", version
16
- gem.add_dependency "activesupport", "3.0.0"
17
- gem.add_dependency "activemodel", "3.0.0"
14
+ gem.add_development_dependency "rspec", "~>2.0.0"
15
+ gem.add_dependency "riak-client", "~>#{version}"
16
+ gem.add_dependency "activesupport", "~>3.0.0"
17
+ gem.add_dependency "activemodel", "~>3.0.0"
18
18
 
19
19
  files = FileList["**/*"]
20
20
  files.exclude /\.DS_Store/
@@ -27,6 +27,7 @@ gemspec = Gem::Specification.new do |gem|
27
27
  files.exclude /^pkg/
28
28
  files.exclude 'ripple.gemspec'
29
29
  files.exclude 'Gemfile'
30
+ files.exclude 'spec/support/test_server.yml'
30
31
 
31
32
  gem.files = files.to_a
32
33
 
@@ -19,10 +19,15 @@ module Ripple
19
19
 
20
20
  def initialize(*args)
21
21
  super
22
- owner.class.validates reflection.name, :associated => true
22
+ lazy_load_validates_associated
23
23
  end
24
24
 
25
25
  protected
26
+
27
+ def lazy_load_validates_associated
28
+ return if @owner.class.validators_on(@reflection.name).any? {|v| Ripple::Validations::AssociatedValidator === v}
29
+ @owner.class.validates @reflection.name, :associated => true
30
+ end
26
31
 
27
32
  def assign_references(docs)
28
33
  Array(docs).each do |doc|
@@ -62,10 +62,8 @@ class String
62
62
  end
63
63
  end
64
64
 
65
- # Stand-in for true/false property types.
66
- module ::Boolean
67
- extend self
68
- def ripple_cast(value)
65
+ boolean_cast = proc do
66
+ def self.ripple_cast(value)
69
67
  case value
70
68
  when NilClass
71
69
  nil
@@ -83,15 +81,14 @@ module ::Boolean
83
81
  end
84
82
  end
85
83
 
86
- # @private
87
- class TrueClass
88
- extend Boolean
84
+ unless defined?(::Boolean)
85
+ # Stand-in for true/false property types.
86
+ module ::Boolean; end
89
87
  end
90
88
 
91
- # @private
92
- class FalseClass
93
- extend Boolean
94
- end
89
+ ::Boolean.module_eval(&boolean_cast)
90
+ TrueClass.module_eval(&boolean_cast)
91
+ FalseClass.module_eval(&boolean_cast)
95
92
 
96
93
  # @private
97
94
  class Time
@@ -20,9 +20,8 @@ module Ripple
20
20
  module Validations
21
21
  class AssociatedValidator < ActiveModel::EachValidator
22
22
  def validate_each(record, attribute, value)
23
- unless Array(value).map {|r| r.nil? || r.valid? }.all?
24
- record.errors.add(attribute, :invalid, :default => options[:message], :value => value)
25
- end
23
+ return if (value.is_a?(Array) ? value : [value]).collect{ |r| r.nil? || r.valid? }.all?
24
+ record.errors.add(attribute, :invalid, options.merge(:value => value))
26
25
  end
27
26
  end
28
27
 
@@ -127,4 +127,9 @@ describe Ripple::Associations::ManyEmbeddedProxy do
127
127
  lambda { @user.addresses = @address }.should raise_error
128
128
  lambda { @user.addresses = [@note] }.should raise_error
129
129
  end
130
+
131
+ it "should not add the associated validator multiple times" do
132
+ #$stderr.puts User.validators.collect(&:inspect)
133
+ User.validators_on(:addresses).count.should eq(1)
134
+ end
130
135
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 8
8
- - 1
9
- version: 0.8.1
8
+ - 2
9
+ version: 0.8.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sean Cribbs
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-11 00:00:00 -04:00
17
+ date: 2010-10-22 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -29,9 +29,7 @@ dependencies:
29
29
  - 2
30
30
  - 0
31
31
  - 0
32
- - beta
33
- - 18
34
- version: 2.0.0.beta.18
32
+ version: 2.0.0
35
33
  type: :development
36
34
  version_requirements: *id001
37
35
  - !ruby/object:Gem::Dependency
@@ -40,13 +38,13 @@ dependencies:
40
38
  requirement: &id002 !ruby/object:Gem::Requirement
41
39
  none: false
42
40
  requirements:
43
- - - "="
41
+ - - ~>
44
42
  - !ruby/object:Gem::Version
45
43
  segments:
46
44
  - 0
47
45
  - 8
48
- - 1
49
- version: 0.8.1
46
+ - 2
47
+ version: 0.8.2
50
48
  type: :runtime
51
49
  version_requirements: *id002
52
50
  - !ruby/object:Gem::Dependency
@@ -55,7 +53,7 @@ dependencies:
55
53
  requirement: &id003 !ruby/object:Gem::Requirement
56
54
  none: false
57
55
  requirements:
58
- - - "="
56
+ - - ~>
59
57
  - !ruby/object:Gem::Version
60
58
  segments:
61
59
  - 3
@@ -70,7 +68,7 @@ dependencies:
70
68
  requirement: &id004 !ruby/object:Gem::Requirement
71
69
  none: false
72
70
  requirements:
73
- - - "="
71
+ - - ~>
74
72
  - !ruby/object:Gem::Version
75
73
  segments:
76
74
  - 3
@@ -186,7 +184,6 @@ files:
186
184
  - spec/support/models/wheel.rb
187
185
  - spec/support/models/widget.rb
188
186
  - spec/support/test_server.rb
189
- - spec/support/test_server.yml
190
187
  has_rdoc: true
191
188
  homepage: http://seancribbs.github.com/ripple
192
189
  licenses: []
@@ -1,2 +0,0 @@
1
- bin_dir: /Users/sean/Development/riak/rel/riak/bin
2
- temp_dir: /Users/sean/Development/ripple/.riaktest