valle 1.0.1 → 1.1.0
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/.dockerignore +2 -0
- data/.travis.yml +17 -4
- data/CHANGELOG.md +4 -0
- data/Dockerfile +13 -0
- data/Gemfile +3 -3
- data/LICENSE +1 -1
- data/Makefile +7 -0
- data/README.md +20 -8
- data/features/configuration.feature +5 -6
- data/features/sets_validations.feature +2 -2
- data/lib/valle/railtie.rb +1 -1
- data/test/lib/abstract_adapter/character_limited_column_test.rb +3 -3
- data/test/lib/abstract_adapter/column_wrapper_test.rb +2 -2
- data/test/test_helper.rb +1 -0
- data/valle.gemspec +1 -2
- metadata +6 -4
- data/lib/valle/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03548fc5db23ebbefcdbfd0215fd6b770b37ae5b
|
4
|
+
data.tar.gz: c5254b2a714721e09610e9f7b958a00f61813a3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79dcc9f84474cd7578106b21aad7c6533cfb13e526867d14a5846307ccfcf7f2bf511c98f71a892da3e5666dae71dac882d28d0cd334850f016120c352d3a84a
|
7
|
+
data.tar.gz: ab8ec2d290146f03dfd7e1a139ecc7e75d3ee02c4944487fdb344050526d2fb54b6ef4ff2516ca3dd689eb3af77b3895e2c0759ae78ee73423f4cfc54629fd71
|
data/.dockerignore
ADDED
data/.travis.yml
CHANGED
@@ -1,8 +1,21 @@
|
|
1
|
-
|
1
|
+
sudo: false
|
2
|
+
|
2
3
|
rvm:
|
3
|
-
-
|
4
|
-
-
|
5
|
-
- 2
|
4
|
+
- 2.3.0
|
5
|
+
- ruby-head
|
6
|
+
- rbx-2
|
7
|
+
- jruby-head
|
8
|
+
|
9
|
+
matrix:
|
10
|
+
allow_failures:
|
11
|
+
- rvm: ruby-head
|
12
|
+
- rvm: rbx-2
|
13
|
+
- rvm: jruby-head
|
14
|
+
fast_finish: true
|
15
|
+
|
6
16
|
branches:
|
7
17
|
only:
|
8
18
|
- master
|
19
|
+
|
20
|
+
before_install:
|
21
|
+
- gem update bundler
|
data/CHANGELOG.md
CHANGED
data/Dockerfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
FROM ruby:latest
|
2
|
+
|
3
|
+
# fixes cucumber bug where it cannot find bundler
|
4
|
+
RUN gem install bundler --no-ri --no-rdoc
|
5
|
+
|
6
|
+
RUN mkdir -p /usr/src/lib
|
7
|
+
WORKDIR /usr/src/lib
|
8
|
+
|
9
|
+
COPY Gemfile* /usr/src/lib/
|
10
|
+
COPY *.gemspec /usr/src/lib/
|
11
|
+
RUN bundle install
|
12
|
+
|
13
|
+
COPY . /usr/src/lib/
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/Makefile
ADDED
data/README.md
CHANGED
@@ -15,11 +15,6 @@ Example:
|
|
15
15
|
PG::Error: ERROR: value "2147483648" is out of range for type integer
|
16
16
|
: SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1
|
17
17
|
|
18
|
-
### Rails versions currently supported
|
19
|
-
|
20
|
-
- 3.x
|
21
|
-
- 4.x
|
22
|
-
|
23
18
|
### Supported ActiveRecord field types
|
24
19
|
|
25
20
|
- `:primary_key`
|
@@ -41,6 +36,8 @@ Or install it yourself:
|
|
41
36
|
|
42
37
|
$ gem install valle
|
43
38
|
|
39
|
+
If you are using other framework than Rails (e.g. Sinatra), call `Valle::Hooks.init` method during the boot process.
|
40
|
+
|
44
41
|
## Usage
|
45
42
|
|
46
43
|
By default, this gem adds validators to all your ActiveRecord models. If that is the behavior you want, you don't need to tweak it.
|
@@ -77,6 +74,23 @@ end
|
|
77
74
|
|
78
75
|
There is a similar gem, called [validates_lengths_from_database](http://github.com/rubiety/validates_lengths_from_database). It solves only one part of the problem — applicable to strings. Valle, however, is designed to work with all possible field types.
|
79
76
|
|
77
|
+
## Docker container
|
78
|
+
|
79
|
+
If you have [docker](http://www.docker.com/) installed on your machine, you can
|
80
|
+
spin up a sandbox and run test suite in a few seconds:
|
81
|
+
|
82
|
+
```
|
83
|
+
$ docker build -t valle .
|
84
|
+
$ docker run -it --rm -v "$PWD":/usr/src/lib valle bundle exec rake
|
85
|
+
```
|
86
|
+
|
87
|
+
Or simply use Makefile commands:
|
88
|
+
|
89
|
+
```
|
90
|
+
$ make docker_build
|
91
|
+
$ make docker_test
|
92
|
+
```
|
93
|
+
|
80
94
|
## Contributing
|
81
95
|
|
82
96
|
1. Fork it
|
@@ -88,14 +102,12 @@ There is a similar gem, called [validates_lengths_from_database](http://github.c
|
|
88
102
|
|
89
103
|
## Credits
|
90
104
|
|
91
|
-
|
105
|
+
Original authors:
|
92
106
|
|
93
107
|
- [Anton Kalyaev](http://github.com/akalyaev)
|
94
108
|
- [Andrew Kulakov](http://github.com/Andrew8xx8)
|
95
109
|
- [Alexander Kirillov](http://github.com/saratovsource)
|
96
110
|
|
97
|
-
Maintained by kaize team.
|
98
|
-
|
99
111
|
Thank you to all our amazing [contributors](http://github.com/kaize/valle/contributors)!
|
100
112
|
|
101
113
|
## License
|
@@ -1,4 +1,3 @@
|
|
1
|
-
@disable-bundler
|
2
1
|
Feature:
|
3
2
|
In order to temporary disable Valle or apply it only to a subset of models,
|
4
3
|
as a user of Rails, I would like to use valle initializer options.
|
@@ -10,7 +9,7 @@ Feature:
|
|
10
9
|
And I add "valle" from this project as a dependency
|
11
10
|
And I successfully run `bundle install`
|
12
11
|
And I successfully run `bundle exec rails g model User name:string`
|
13
|
-
And I successfully run `bundle exec rake db:migrate
|
12
|
+
And I successfully run `bundle exec rake db:migrate -v`
|
14
13
|
|
15
14
|
Scenario: Setting enabled option to false disable Valle
|
16
15
|
When I write to "config/initializers/valle.rb" with:
|
@@ -34,12 +33,12 @@ Feature:
|
|
34
33
|
end
|
35
34
|
end
|
36
35
|
"""
|
37
|
-
When I successfully run `bundle exec rake test
|
36
|
+
When I successfully run `bundle exec rake test -v`
|
38
37
|
Then the output should contain "1 runs, 1 assertions, 0 failures, 0 errors"
|
39
38
|
|
40
39
|
Scenario: Using the exclude_models option should skip the models specified in the list
|
41
40
|
When I successfully run `bundle exec rails g model Post title:string`
|
42
|
-
And I successfully run `bundle exec rake db:migrate
|
41
|
+
And I successfully run `bundle exec rake db:migrate -v`
|
43
42
|
And I write to "config/initializers/valle.rb" with:
|
44
43
|
"""
|
45
44
|
Valle.configure do |config|
|
@@ -75,7 +74,7 @@ Feature:
|
|
75
74
|
end
|
76
75
|
end
|
77
76
|
"""
|
78
|
-
When I successfully run `bundle exec rake test
|
77
|
+
When I successfully run `bundle exec rake test -v`
|
79
78
|
Then the output should contain "2 runs, 3 assertions, 0 failures, 0 errors"
|
80
79
|
|
81
80
|
Scenario: Using exclude_attributes option should allow us to skip some attributes
|
@@ -102,5 +101,5 @@ Feature:
|
|
102
101
|
end
|
103
102
|
end
|
104
103
|
"""
|
105
|
-
When I successfully run `bundle exec rake test
|
104
|
+
When I successfully run `bundle exec rake test -v`
|
106
105
|
Then the output should contain "1 runs, 1 assertions, 0 failures, 0 errors"
|
@@ -6,7 +6,7 @@ Feature: sets validations
|
|
6
6
|
And I add "valle" from this project as a dependency
|
7
7
|
And I successfully run `bundle install`
|
8
8
|
And I successfully run `bundle exec rails g model User name:string`
|
9
|
-
And I successfully run `bundle exec rake db:migrate
|
9
|
+
And I successfully run `bundle exec rake db:migrate -v`
|
10
10
|
|
11
11
|
@disable-bundler
|
12
12
|
Scenario: Using Valle automatically sets validations
|
@@ -27,5 +27,5 @@ Feature: sets validations
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
"""
|
30
|
-
When I successfully run `bundle exec rake test
|
30
|
+
When I successfully run `bundle exec rake test -v`
|
31
31
|
Then the output should contain "1 runs, 2 assertions, 0 failures, 0 errors"
|
data/lib/valle/railtie.rb
CHANGED
@@ -3,21 +3,21 @@ require "test_helper"
|
|
3
3
|
class CharacterLimitedColumnTest < TestCase
|
4
4
|
|
5
5
|
def test_maximum_should_return_value_for_string_column
|
6
|
-
original_column = ::ActiveRecord::ConnectionAdapters::Column.new("test_column", "",
|
6
|
+
original_column = ::ActiveRecord::ConnectionAdapters::Column.new("test_column", "", ::ActiveRecord::Type::String.new(limit: 255))
|
7
7
|
column = Valle::AbstractAdapter::CharacterLimitedColumn.new(original_column)
|
8
8
|
|
9
9
|
assert column.maximum
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_maximum_should_return_correct_value_for_string_column_if_user_redefine_limit
|
13
|
-
original_column = ::ActiveRecord::ConnectionAdapters::Column.new("test_column", "",
|
13
|
+
original_column = ::ActiveRecord::ConnectionAdapters::Column.new("test_column", "", ::ActiveRecord::Type::String.new(limit: 200))
|
14
14
|
column = Valle::AbstractAdapter::CharacterLimitedColumn.new(original_column)
|
15
15
|
|
16
16
|
assert_equal 200, column.maximum
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_minimum_should_return_nil
|
20
|
-
original_column = ::ActiveRecord::ConnectionAdapters::Column.new("test_column", "",
|
20
|
+
original_column = ::ActiveRecord::ConnectionAdapters::Column.new("test_column", "", ::ActiveRecord::Type::String.new)
|
21
21
|
column = Valle::AbstractAdapter::CharacterLimitedColumn.new(original_column)
|
22
22
|
|
23
23
|
assert_nil column.minimum
|
@@ -4,14 +4,14 @@ require "active_record"
|
|
4
4
|
class ColumnWrapperTest < TestCase
|
5
5
|
|
6
6
|
def test_wrap_should_return_instance_of_character_limited_column_for_string_column
|
7
|
-
column = ::ActiveRecord::ConnectionAdapters::Column.new("test_column", "",
|
7
|
+
column = ::ActiveRecord::ConnectionAdapters::Column.new("test_column", "", ::ActiveRecord::Type::String.new(limit: 255))
|
8
8
|
wrapped_column = Valle::AbstractAdapter::ColumnWrapper.wrap(column)
|
9
9
|
|
10
10
|
assert wrapped_column.is_a?(Valle::AbstractAdapter::CharacterLimitedColumn)
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_wrap_should_return_instance_of_byte_limited_column_for_int_column
|
14
|
-
column = ::ActiveRecord::ConnectionAdapters::Column.new("test_column",
|
14
|
+
column = ::ActiveRecord::ConnectionAdapters::Column.new("test_column", 25, ::ActiveRecord::Type::Integer.new)
|
15
15
|
wrapped_column = Valle::AbstractAdapter::ColumnWrapper.wrap(column)
|
16
16
|
|
17
17
|
assert wrapped_column.is_a?(Valle::AbstractAdapter::ByteLimitedColumn)
|
data/test/test_helper.rb
CHANGED
data/valle.gemspec
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../lib/valle/version', __FILE__)
|
3
2
|
|
4
3
|
Gem::Specification.new do |gem|
|
5
4
|
gem.authors = ["Anton Kalyaev"]
|
@@ -14,7 +13,7 @@ Gem::Specification.new do |gem|
|
|
14
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
14
|
gem.name = "valle"
|
16
15
|
gem.require_paths = ["lib"]
|
17
|
-
gem.version =
|
16
|
+
gem.version = "1.1.0"
|
18
17
|
|
19
18
|
gem.add_dependency 'activerecord', '>= 3.0'
|
20
19
|
gem.add_dependency 'activesupport'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Kalyaev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -47,12 +47,15 @@ executables: []
|
|
47
47
|
extensions: []
|
48
48
|
extra_rdoc_files: []
|
49
49
|
files:
|
50
|
+
- ".dockerignore"
|
50
51
|
- ".gitignore"
|
51
52
|
- ".travis.yml"
|
52
53
|
- CHANGELOG.md
|
53
54
|
- CONTRIBUTING.md
|
55
|
+
- Dockerfile
|
54
56
|
- Gemfile
|
55
57
|
- LICENSE
|
58
|
+
- Makefile
|
56
59
|
- README.md
|
57
60
|
- Rakefile
|
58
61
|
- features/configuration.feature
|
@@ -70,7 +73,6 @@ files:
|
|
70
73
|
- lib/valle/manager.rb
|
71
74
|
- lib/valle/railtie.rb
|
72
75
|
- lib/valle/validation_setter.rb
|
73
|
-
- lib/valle/version.rb
|
74
76
|
- test/lib/abstract_adapter/character_limited_column_test.rb
|
75
77
|
- test/lib/abstract_adapter/column_wrapper_test.rb
|
76
78
|
- test/test_helper.rb
|
@@ -95,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
97
|
version: '0'
|
96
98
|
requirements: []
|
97
99
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
100
|
+
rubygems_version: 2.6.2
|
99
101
|
signing_key:
|
100
102
|
specification_version: 4
|
101
103
|
summary: Built-in limit validations for your ActiveRecord model.
|
data/lib/valle/version.rb
DELETED