activemodel 4.0.0 → 4.0.1.rc1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9010096d9a5a2c70cf316ef02ae6204cdd32583b
4
- data.tar.gz: b96b3b73ac4cb59a4ec4d0f547b62d6845186970
3
+ metadata.gz: 727f55a42c89f61745846b591fe62b30e2c3fed7
4
+ data.tar.gz: 0d7b59820bfb10f56102197d265e0bc9ce4f4df2
5
5
  SHA512:
6
- metadata.gz: 62731c37876a8e9a673e48ccca818fe1fda5eff960a017b088a47ef93de0907fb12eb03b121c8b616c1e3ab8f70606219754ea013c41e09b267d471d008b2dc7
7
- data.tar.gz: c9af5c117d95d21d6281f267eebd78651244a3490c03f9996dc1c85405034805110d68ef13d7fd8303cd63b74f1785a311e68ded32458c576b5884c20d34c4ce
6
+ metadata.gz: 6c1dabb2be822153b375a6c1647889a17bac6e708d40ebf1dcc5b15ba5c74562503b651c774de97e3301e55e0ce96424e04c4d3a3dd81a656bd6426d5a1ec136
7
+ data.tar.gz: d0ea427fc1c0028467b4a1d86ea0a6d699fad7af8f6c2dca28797c6017bda6793afbaebf7380833ea654a6aed640cb25f15376b8a523419b8cd6c988304b7a23
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## Rails 4.0.1.rc1 (October 17, 2013) ##
2
+
3
+ * Fix `has_secure_password` to honor bcrypt-ruby's cost attribute.
4
+
5
+ *T.J. Schuck*
6
+
7
+ * `inclusion` / `exclusion` validations with ranges will only use the faster
8
+ `Range#cover` for numerical ranges, and the more accurate `Range#include?`
9
+ for non-numerical ones.
10
+
11
+ Fixes range validations like `:a..:f` that used to pass with values like `:be`.
12
+
13
+ Fixes #10593.
14
+
15
+ *Charles Bergeron*
16
+
17
+
1
18
  ## Rails 4.0.0 (June 25, 2013) ##
2
19
 
3
20
  * Fix regression in has_secure_password. When a password is set, but a
data/README.rdoc CHANGED
@@ -227,7 +227,7 @@ The latest version of Active Model can be installed with RubyGems:
227
227
 
228
228
  Source code can be downloaded as part of the Rails project on GitHub
229
229
 
230
- * https://github.com/rails/rails/tree/master/activemodel
230
+ * https://github.com/rails/rails/tree/4-0-stable/activemodel
231
231
 
232
232
 
233
233
  == License
@@ -1,4 +1,5 @@
1
1
  require 'thread_safe'
2
+ require 'mutex_m'
2
3
 
3
4
  module ActiveModel
4
5
  # Raised when an attribute is not defined.
@@ -324,7 +325,9 @@ module ActiveModel
324
325
 
325
326
  # Returns true if the attribute methods defined have been generated.
326
327
  def generated_attribute_methods #:nodoc:
327
- @generated_attribute_methods ||= Module.new.tap { |mod| include mod }
328
+ @generated_attribute_methods ||= Module.new {
329
+ extend Mutex_m
330
+ }.tap { |mod| include mod }
328
331
  end
329
332
 
330
333
  protected
@@ -50,7 +50,7 @@ module ActiveModel
50
50
  #
51
51
  # The above allows you to do:
52
52
  #
53
- # p = Person.new
53
+ # person = Person.new
54
54
  # person.validate! # => ["can not be nil"]
55
55
  # person.errors.full_messages # => ["name can not be nil"]
56
56
  # # etc..
@@ -238,8 +238,8 @@ module ActiveModel
238
238
  # object. You can pass the <tt>:full_messages</tt> option. This determines
239
239
  # if the json object should contain full messages or not (false by default).
240
240
  #
241
- # person.as_json # => {:name=>["can not be nil"]}
242
- # person.as_json(full_messages: true) # => {:name=>["name can not be nil"]}
241
+ # person.errors.as_json # => {:name=>["can not be nil"]}
242
+ # person.errors.as_json(full_messages: true) # => {:name=>["name can not be nil"]}
243
243
  def as_json(options=nil)
244
244
  to_hash(options && options[:full_messages])
245
245
  end
@@ -247,8 +247,8 @@ module ActiveModel
247
247
  # Returns a Hash of attributes with their error messages. If +full_messages+
248
248
  # is +true+, it will contain full messages (see +full_message+).
249
249
  #
250
- # person.to_hash # => {:name=>["can not be nil"]}
251
- # person.to_hash(true) # => {:name=>["name can not be nil"]}
250
+ # person.errors.to_hash # => {:name=>["can not be nil"]}
251
+ # person.errors.to_hash(true) # => {:name=>["name can not be nil"]}
252
252
  def to_hash(full_messages = false)
253
253
  if full_messages
254
254
  messages = {}
@@ -18,9 +18,9 @@ module ActiveModel
18
18
  # value to the password_confirmation attribute and the the validation
19
19
  # will not be triggered.
20
20
  #
21
- # You need to add bcrypt-ruby (~> 3.0.0) to Gemfile to use #has_secure_password:
21
+ # You need to add bcrypt-ruby (~> 3.1.2) to Gemfile to use #has_secure_password:
22
22
  #
23
- # gem 'bcrypt-ruby', '~> 3.0.0'
23
+ # gem 'bcrypt-ruby', '~> 3.1.2'
24
24
  #
25
25
  # Example using Active Record (which automatically includes ActiveModel::SecurePassword):
26
26
  #
@@ -44,7 +44,7 @@ module ActiveModel
44
44
  # This is to avoid ActiveModel (and by extension the entire framework)
45
45
  # being dependent on a binary library.
46
46
  begin
47
- gem 'bcrypt-ruby', '~> 3.0.0'
47
+ gem 'bcrypt-ruby', '~> 3.1.2'
48
48
  require 'bcrypt'
49
49
  rescue LoadError
50
50
  $stderr.puts "You don't have bcrypt-ruby installed in your application. Please add it to your Gemfile and run bundle install"
@@ -101,7 +101,7 @@ module ActiveModel
101
101
  def password=(unencrypted_password)
102
102
  unless unencrypted_password.blank?
103
103
  @password = unencrypted_password
104
- cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine::DEFAULT_COST
104
+ cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost
105
105
  self.password_digest = BCrypt::Password.create(unencrypted_password, cost: cost)
106
106
  end
107
107
  end
@@ -31,10 +31,11 @@ module ActiveModel
31
31
  end
32
32
 
33
33
  # In Ruby 1.9 <tt>Range#include?</tt> on non-numeric ranges checks all possible values in the
34
- # range for equality, so it may be slow for large ranges. The new <tt>Range#cover?</tt>
35
- # uses the previous logic of comparing a value with the range endpoints.
34
+ # range for equality, which is slower but more accurate. <tt>Range#cover?</tt> uses
35
+ # the previous logic of comparing a value with the range endpoints, which is fast
36
+ # but is only accurate on numeric ranges.
36
37
  def inclusion_method(enumerable)
37
- enumerable.is_a?(Range) ? :cover? : :include?
38
+ (enumerable.is_a?(Range) && enumerable.first.is_a?(Numeric)) ? :cover? : :include?
38
39
  end
39
40
  end
40
41
  end
@@ -28,7 +28,7 @@ module ActiveModel
28
28
  # Configuration options:
29
29
  # * <tt>:in</tt> - An enumerable object of available items. This can be
30
30
  # supplied as a proc, lambda or symbol which returns an enumerable. If the
31
- # enumerable is a range the test is performed with <tt>Range#cover?</tt>,
31
+ # enumerable is a numerical range the test is performed with <tt>Range#cover?</tt>,
32
32
  # otherwise with <tt>include?</tt>.
33
33
  # * <tt>:within</tt> - A synonym(or alias) for <tt>:in</tt>
34
34
  # * <tt>:message</tt> - Specifies a custom error message (default is: "is
@@ -1,7 +1,7 @@
1
1
  module ActiveModel
2
2
  # Returns the version of the currently loaded ActiveModel as a Gem::Version
3
3
  def self.version
4
- Gem::Version.new "4.0.0"
4
+ Gem::Version.new "4.0.1.rc1"
5
5
  end
6
6
 
7
7
  module VERSION #:nodoc:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemodel
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-25 00:00:00.000000000 Z
11
+ date: 2013-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.0
19
+ version: 4.0.1.rc1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 4.0.0
26
+ version: 4.0.1.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -99,12 +99,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
99
  version: 1.9.3
100
100
  required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - '>='
102
+ - - '>'
103
103
  - !ruby/object:Gem::Version
104
- version: '0'
104
+ version: 1.3.1
105
105
  requirements: []
106
106
  rubyforge_project:
107
- rubygems_version: 2.0.2
107
+ rubygems_version: 2.0.6
108
108
  signing_key:
109
109
  specification_version: 4
110
110
  summary: A toolkit for building modeling frameworks (part of Rails).