active_model_warnings 0.1.1 → 0.1.2
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 +4 -4
- data/Appraisals +6 -0
- data/README.md +29 -7
- data/active_model_warnings.gemspec +5 -3
- data/gemfiles/activemodel_3.0.gemfile +1 -0
- data/gemfiles/activemodel_3.1.gemfile +1 -0
- data/gemfiles/activemodel_3.2.gemfile +1 -0
- data/gemfiles/activemodel_4.0.gemfile +1 -0
- data/gemfiles/activemodel_4.1.gemfile +1 -0
- data/gemfiles/activemodel_4.2.gemfile +1 -0
- data/lib/active_model_warnings/version.rb +1 -1
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 555cf807208b0a5513fda11aee68abb712517606
|
4
|
+
data.tar.gz: 61aefb5a541a9ee3e70abdbb4d54dcca37774d30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f6d78f55f6fe1d72c5a4f4721ea615853d9d17443099103dfbe06bd6d7a7068022464e92c9634de5aa31372ddf0bc006a2be5ec46e2ba46ce99fa9e20a405fa
|
7
|
+
data.tar.gz: 9b77eab9ca6bd5e45f8670a22427edcfa3c90ad4ac9c4425a54c2697527aa3914febda5b10243f8f9b5961bb8e0e67fa03271586dd581286742e0bc0fa79c22f
|
data/Appraisals
CHANGED
@@ -1,23 +1,29 @@
|
|
1
1
|
appraise "activemodel-4.2" do
|
2
2
|
gem "activemodel", "~> 4.2.0"
|
3
|
+
gem "activerecord", "~> 4.2.0"
|
3
4
|
end
|
4
5
|
|
5
6
|
appraise "activemodel-4.1" do
|
6
7
|
gem "activemodel", "~> 4.1.0"
|
8
|
+
gem "activerecord", "~> 4.1.0"
|
7
9
|
end
|
8
10
|
|
9
11
|
appraise "activemodel-4.0" do
|
10
12
|
gem "activemodel", "~> 4.0.0"
|
13
|
+
gem "activerecord", "~> 4.0.0"
|
11
14
|
end
|
12
15
|
|
13
16
|
appraise "activemodel-3.2" do
|
14
17
|
gem "activemodel", "~> 3.2.0"
|
18
|
+
gem "activerecord", "~> 3.2.0"
|
15
19
|
end
|
16
20
|
|
17
21
|
appraise "activemodel-3.1" do
|
18
22
|
gem "activemodel", "~> 3.1.0"
|
23
|
+
gem "activerecord", "~> 3.1.0"
|
19
24
|
end
|
20
25
|
|
21
26
|
appraise "activemodel-3.0" do
|
22
27
|
gem "activemodel", "~> 3.0.0"
|
28
|
+
gem "activerecord", "~> 3.0.0"
|
23
29
|
end
|
data/README.md
CHANGED
@@ -27,9 +27,33 @@ Or install it yourself as:
|
|
27
27
|
$ gem install active_model_warnings
|
28
28
|
|
29
29
|
## Usage
|
30
|
+
### ActiveRecord
|
31
|
+
```ruby
|
32
|
+
class User < ActiveRecord::Base
|
33
|
+
attr_accessor :password
|
34
|
+
validate :password_length # may cause an error
|
35
|
+
validate :blank_password # may cause a warning
|
30
36
|
|
37
|
+
private
|
38
|
+
|
39
|
+
def password_length
|
40
|
+
warnings.add(:password, "min length should be 5") if password.length < 5
|
41
|
+
end
|
42
|
+
|
43
|
+
def blank_password
|
44
|
+
errors.add(:password, 'should not be blank') if password.length == 0
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
user = User.new(:password => 'safe')
|
49
|
+
user.valid?
|
50
|
+
# => true
|
51
|
+
user.compliant?
|
52
|
+
# => false
|
53
|
+
```
|
54
|
+
### ActiveModel
|
31
55
|
```ruby
|
32
|
-
class
|
56
|
+
class User
|
33
57
|
include ActiveModel::Validations
|
34
58
|
attr_accessor :password
|
35
59
|
|
@@ -51,20 +75,18 @@ class Resource
|
|
51
75
|
end
|
52
76
|
end
|
53
77
|
|
54
|
-
|
55
|
-
|
78
|
+
user = User.new('safe')
|
79
|
+
user.valid?
|
56
80
|
# => true
|
57
|
-
|
81
|
+
user.compliant?
|
58
82
|
# => false
|
59
83
|
```
|
60
|
-
|
61
84
|
## Contributing
|
62
85
|
|
63
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/babasbot/active_model_warnings. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
86
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/babasbot/active_model_warnings. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
64
87
|
|
65
88
|
## TODO
|
66
89
|
|
67
|
-
- Test with `ActiveRecord`.
|
68
90
|
- Support for `ActiveModel::Validations::HelperMethods`.
|
69
91
|
|
70
92
|
## License
|
@@ -21,7 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_dependency("activemodel", ">= 3.0.0")
|
23
23
|
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
24
|
+
spec.add_development_dependency("rspec")
|
25
|
+
spec.add_development_dependency("coveralls")
|
26
|
+
spec.add_development_dependency('appraisal')
|
27
|
+
spec.add_development_dependency("sqlite3")
|
28
|
+
spec.add_development_dependency("activerecord", ">= 3.0.0")
|
27
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_model_warnings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis Alfredo Lorenzo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sqlite3
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: activerecord
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.0.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.0.0
|
69
97
|
description: This is useful when you want to define optional validations for a resource
|
70
98
|
and keep it valid.
|
71
99
|
email:
|