schema_validations 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +8 -4
- data/README.md +39 -21
- data/gemfiles/Gemfile.base +1 -3
- data/gemfiles/{rails-3.2 → activerecord-4.2.1}/Gemfile.base +1 -1
- data/gemfiles/{rails-3.2/Gemfile.sqlite3 → activerecord-4.2.1/Gemfile.mysql2} +3 -3
- data/gemfiles/{rails-4.1/Gemfile.sqlite3 → activerecord-4.2.1/Gemfile.postgresql} +3 -3
- data/gemfiles/{rails-4.2 → activerecord-4.2.1}/Gemfile.sqlite3 +0 -0
- data/lib/schema_validations/active_record/validations.rb +3 -4
- data/lib/schema_validations/version.rb +1 -1
- data/lib/schema_validations.rb +1 -1
- data/schema_dev.yml +6 -6
- data/schema_validations.gemspec +4 -2
- data/spec/spec_helper.rb +1 -1
- data/spec/validations_spec.rb +5 -3
- metadata +43 -11
- data/gemfiles/rails-4.1/Gemfile.base +0 -3
- data/gemfiles/rails-4.2/Gemfile.base +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ea33d2335e1af126b8d168661412173f65bd12c
|
4
|
+
data.tar.gz: 91b7ba79752b866df0c1184356f5aa9f43ec311f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5d11da519e0fab53b9d494e0e51b203b7a593c22c35e1d68f92a2c442185dd703ea96461566bbb7723b285fe4194db2863f5de3a5d4f2550dbdf3c5831d480b
|
7
|
+
data.tar.gz: 27d023e4d31824c6f85444cdefc34d15002da1efd1f252960c5cb961a1f04abd5cf870d556e9e087baa0361bc993a947eb35fcd18090a6168161e6c23171142f
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -5,10 +5,14 @@
|
|
5
5
|
---
|
6
6
|
sudo: false
|
7
7
|
rvm:
|
8
|
-
- 1.9.3
|
9
8
|
- 2.1.5
|
10
9
|
gemfile:
|
11
|
-
- gemfiles/
|
12
|
-
- gemfiles/
|
13
|
-
- gemfiles/
|
10
|
+
- gemfiles/activerecord-4.2.1/Gemfile.mysql2
|
11
|
+
- gemfiles/activerecord-4.2.1/Gemfile.postgresql
|
12
|
+
- gemfiles/activerecord-4.2.1/Gemfile.sqlite3
|
13
|
+
env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
|
14
|
+
addons:
|
15
|
+
postgresql: '9.4'
|
16
|
+
before_script: bundle exec rake create_databases
|
17
|
+
after_script: bundle exec rake drop_databases
|
14
18
|
script: bundle exec rake travis
|
data/README.md
CHANGED
@@ -45,17 +45,24 @@ hood.
|
|
45
45
|
|
46
46
|
## Compatibility
|
47
47
|
|
48
|
-
SchemaValidations is tested on
|
48
|
+
As of version 1.2.0, SchemaValidations supports and is tested on:
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
<!-- SCHEMA_DEV: MATRIX - begin -->
|
51
|
+
<!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
|
52
|
+
* ruby **2.1.5** with activerecord **4.2.1**, using **mysql2**, **postgresql** or **sqlite3**
|
53
|
+
|
54
|
+
<!-- SCHEMA_DEV: MATRIX - end -->
|
55
|
+
|
56
|
+
Earlier versions of SchemaValidations supported:
|
57
|
+
|
58
|
+
* rails 3.2, 4.1, and 4.2.0
|
59
|
+
* MRI ruby 1.9.3 and 2.1.5
|
53
60
|
|
54
61
|
## Installation
|
55
62
|
|
56
63
|
Simply add schema_validations to your Gemfile.
|
57
64
|
|
58
|
-
gem "schema_validations"
|
65
|
+
gem "schema_validations"
|
59
66
|
|
60
67
|
### What if I want something special?
|
61
68
|
|
@@ -105,15 +112,6 @@ Data types:
|
|
105
112
|
| :float | :validates ... :numericality => true |
|
106
113
|
| :integer | :validates ... :numericality => { :only_integer => true } |
|
107
114
|
|
108
|
-
## Dependency
|
109
|
-
|
110
|
-
SchemaValidations uses the [schema_plus](http://rubygems.org/gems/schema_plus)
|
111
|
-
gem for its schema queries. That gem will by default auto-create foreign key
|
112
|
-
constraints that you probably want -- but if you don't want them, you can
|
113
|
-
disable them using [schema_plus](http://rubygems.org/gems/schema_plus
|
114
|
-
|
115
|
-
|
116
|
-
|
117
115
|
## How do I know what it did?
|
118
116
|
If you're curious (or dubious) about what validations SchemaValidations
|
119
117
|
defines, you can check the log file. For every assocation that
|
@@ -133,6 +131,10 @@ use case.
|
|
133
131
|
|
134
132
|
## Release Notes
|
135
133
|
|
134
|
+
### 1.2.0
|
135
|
+
|
136
|
+
* No longer pull in schema_plus's auto-foreign key behavior. Limited to AR >= 4.2.1
|
137
|
+
|
136
138
|
### 1.1.0
|
137
139
|
|
138
140
|
* Works with Rails 4.2.
|
@@ -147,7 +149,7 @@ use case.
|
|
147
149
|
* No longer support Rails < 3.2 or Ruby < 1.9.3
|
148
150
|
|
149
151
|
### 0.2.2
|
150
|
-
|
152
|
+
|
151
153
|
* Rails 2.3 compatibility (check for Rails::Railties symbol). thanks to https://github.com/thehappycoder
|
152
154
|
|
153
155
|
### 0.2.0
|
@@ -165,14 +167,30 @@ use case.
|
|
165
167
|
|
166
168
|
## Testing
|
167
169
|
|
168
|
-
|
169
|
-
|
170
|
+
Are you interested in contributing to schema_validations? Thanks! Please follow
|
171
|
+
the standard protocol: fork, feature branch, develop, push, and issue pull request.
|
172
|
+
|
173
|
+
Some things to know about to help you develop and test:
|
174
|
+
|
175
|
+
<!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_DEV - begin -->
|
176
|
+
<!-- These lines are auto-inserted from a schema_dev template -->
|
177
|
+
* **schema_dev**: SchemaValidations uses [schema_dev](https://github.com/SchemaPlus/schema_dev) to
|
178
|
+
facilitate running rspec tests on the matrix of ruby, activerecord, and database
|
179
|
+
versions that the gem supports, both locally and on
|
180
|
+
[travis-ci](http://travis-ci.org/SchemaPlus/schema_validations)
|
181
|
+
|
182
|
+
To to run rspec locally on the full matrix, do:
|
183
|
+
|
184
|
+
$ schema_dev bundle install
|
185
|
+
$ schema_dev rspec
|
186
|
+
|
187
|
+
You can also run on just one configuration at a time; For info, see `schema_dev --help` or the [schema_dev](https://github.com/SchemaPlus/schema_dev) README.
|
188
|
+
|
189
|
+
The matrix of configurations is specified in `schema_dev.yml` in
|
190
|
+
the project root.
|
170
191
|
|
171
|
-
$ cd schema_validations
|
172
|
-
$ schema_dev bundle install
|
173
|
-
$ schema_dev rspec
|
174
192
|
|
175
|
-
|
193
|
+
<!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_DEV - end -->
|
176
194
|
|
177
195
|
Code coverage results will be in coverage/index.html -- it should be at 100% coverage.
|
178
196
|
|
data/gemfiles/Gemfile.base
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
gemspec :path => File.expand_path('..', __FILE__)
|
3
3
|
|
4
|
-
|
5
|
-
gem "byebug" if RUBY_VERSION > "2"
|
6
|
-
end
|
4
|
+
File.exist?(gemfile_local = File.expand_path('../Gemfile.local', __FILE__)) and eval File.read(gemfile_local), binding, gemfile_local
|
@@ -2,9 +2,9 @@ require "pathname"
|
|
2
2
|
eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
|
3
3
|
|
4
4
|
platform :ruby do
|
5
|
-
gem "
|
5
|
+
gem "mysql2"
|
6
6
|
end
|
7
7
|
|
8
8
|
platform :jruby do
|
9
|
-
gem 'activerecord-
|
10
|
-
end
|
9
|
+
gem 'activerecord-jdbcmysql-adapter'
|
10
|
+
end
|
@@ -2,9 +2,9 @@ require "pathname"
|
|
2
2
|
eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
|
3
3
|
|
4
4
|
platform :ruby do
|
5
|
-
gem "
|
5
|
+
gem "pg"
|
6
6
|
end
|
7
7
|
|
8
8
|
platform :jruby do
|
9
|
-
gem 'activerecord-
|
10
|
-
end
|
9
|
+
gem 'activerecord-jdbcpostgresql-adapter'
|
10
|
+
end
|
File without changes
|
@@ -100,8 +100,7 @@ module SchemaValidations
|
|
100
100
|
when respond_to?(:defined_enums) && defined_enums.has_key?(column.name) then :enum
|
101
101
|
when column.type == :integer then :integer
|
102
102
|
when column.number? then :numeric
|
103
|
-
when column.
|
104
|
-
when [:string, :text].include?(column.type) then :text
|
103
|
+
when column.text? then :text
|
105
104
|
when column.type == :boolean then :boolean
|
106
105
|
end
|
107
106
|
|
@@ -155,7 +154,7 @@ module SchemaValidations
|
|
155
154
|
end
|
156
155
|
|
157
156
|
def validate_logged(method, arg, opts={}) #:nodoc:
|
158
|
-
if _filter_validation(method, arg)
|
157
|
+
if _filter_validation(method, arg)
|
159
158
|
msg = "[schema_validations] #{self.name}.#{method} #{arg.inspect}"
|
160
159
|
msg += ", #{opts.inspect[1...-1]}" if opts.any?
|
161
160
|
logger.info msg
|
@@ -166,7 +165,7 @@ module SchemaValidations
|
|
166
165
|
def _filter_validation(macro, name) #:nodoc:
|
167
166
|
config = schema_validations_config
|
168
167
|
types = [macro]
|
169
|
-
if match = macro.to_s.match(/^validates_(.*)_of$/)
|
168
|
+
if match = macro.to_s.match(/^validates_(.*)_of$/)
|
170
169
|
types << match[1].to_sym
|
171
170
|
end
|
172
171
|
return false if config.only and not Array.wrap(config.only).include?(name)
|
data/lib/schema_validations.rb
CHANGED
data/schema_dev.yml
CHANGED
data/schema_validations.gemspec
CHANGED
@@ -20,9 +20,11 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
|
-
s.add_dependency("
|
23
|
+
s.add_dependency("schema_plus_columns")
|
24
|
+
s.add_dependency("activerecord", "~> 4.2", ">= 4.2.1")
|
25
|
+
s.add_dependency("valuable")
|
24
26
|
|
25
|
-
s.add_development_dependency("schema_dev", "~>
|
27
|
+
s.add_development_dependency("schema_dev", "~> 3.5")
|
26
28
|
s.add_development_dependency("rake")
|
27
29
|
s.add_development_dependency("rdoc")
|
28
30
|
s.add_development_dependency("rspec")
|
data/spec/spec_helper.rb
CHANGED
data/spec/validations_spec.rb
CHANGED
@@ -34,9 +34,11 @@ describe "Validations" do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should create validations for introspection with validators_on" do
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
expected = case
|
38
|
+
when SchemaDev::Rspec::Helpers.mysql? then %W[PresenceValidator LengthValidator]
|
39
|
+
else %W[PresenceValidator]
|
40
|
+
end
|
41
|
+
expect(Article.validators_on(:content).map{|v| v.class.name.demodulize}.uniq).to match_array(expected)
|
40
42
|
end
|
41
43
|
|
42
44
|
it "should be valid with valid attributes" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ronen Barzel
|
@@ -9,10 +9,44 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: schema_plus_columns
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: activerecord
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '4.2'
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 4.2.1
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - "~>"
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '4.2'
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 4.2.1
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: valuable
|
16
50
|
requirement: !ruby/object:Gem::Requirement
|
17
51
|
requirements:
|
18
52
|
- - ">="
|
@@ -31,14 +65,14 @@ dependencies:
|
|
31
65
|
requirements:
|
32
66
|
- - "~>"
|
33
67
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
68
|
+
version: '3.5'
|
35
69
|
type: :development
|
36
70
|
prerelease: false
|
37
71
|
version_requirements: !ruby/object:Gem::Requirement
|
38
72
|
requirements:
|
39
73
|
- - "~>"
|
40
74
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
75
|
+
version: '3.5'
|
42
76
|
- !ruby/object:Gem::Dependency
|
43
77
|
name: rake
|
44
78
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,12 +175,10 @@ files:
|
|
141
175
|
- README.md
|
142
176
|
- Rakefile
|
143
177
|
- gemfiles/Gemfile.base
|
144
|
-
- gemfiles/
|
145
|
-
- gemfiles/
|
146
|
-
- gemfiles/
|
147
|
-
- gemfiles/
|
148
|
-
- gemfiles/rails-4.2/Gemfile.base
|
149
|
-
- gemfiles/rails-4.2/Gemfile.sqlite3
|
178
|
+
- gemfiles/activerecord-4.2.1/Gemfile.base
|
179
|
+
- gemfiles/activerecord-4.2.1/Gemfile.mysql2
|
180
|
+
- gemfiles/activerecord-4.2.1/Gemfile.postgresql
|
181
|
+
- gemfiles/activerecord-4.2.1/Gemfile.sqlite3
|
150
182
|
- init.rb
|
151
183
|
- lib/schema_validations.rb
|
152
184
|
- lib/schema_validations/active_record/validations.rb
|