params_for 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +93 -0
- data/Rakefile +2 -0
- data/lib/params_validator/base.rb +84 -0
- data/lib/params_validator/connectors/params_for.rb +55 -0
- data/lib/params_validator/version.rb +3 -0
- data/lib/params_validator.rb +12 -0
- data/params_for.gemspec +30 -0
- data/spec/params_validator/base_spec.rb +100 -0
- data/spec/params_validator/connectors/params_for_spec.rb +37 -0
- data/spec/shared/support/dummy_controller.rb +67 -0
- data/spec/spec_helper.rb +16 -0
- metadata +176 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e0dbdd78b6a02ac4ceed14c171469d058e2563c7
|
4
|
+
data.tar.gz: 27ae31f222ad064a9e1a991510f29d2f797f98c2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d863599ede3d87d9a7554a138119512fa6a168a05b45c56b28bf1e47946ea649dba49b2405553588566022b97e116ec38c174e99365bd7127f09cae5828a9996
|
7
|
+
data.tar.gz: 0a774e716966a38dd460e15907ffae3bb515b6f4d9512f4bd8590bb15cedbb76f6164e14a04872c77308af696c0aa254d26aa4ceb5016017d111b5e7dc95f075
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 andresbravog
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# ParamsFor
|
2
|
+
|
3
|
+
Use service objects and the power of `ActiveModel::Validations` to easy validate params in controller.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'params_for'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install params_validator
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
In your controller:
|
24
|
+
|
25
|
+
|
26
|
+
```Ruby
|
27
|
+
# app/controllers/fancy_controller.rb
|
28
|
+
|
29
|
+
class Fancycontroller < ApplicationController
|
30
|
+
include ParamsValidator::Connectors::ParamsFor
|
31
|
+
|
32
|
+
params_for :fancy, only: [:create]
|
33
|
+
|
34
|
+
# Creates a Fancy object by checking and validating params
|
35
|
+
# before that
|
36
|
+
#
|
37
|
+
def create
|
38
|
+
...
|
39
|
+
@fancy = Fancy.new(fancy_params)
|
40
|
+
...
|
41
|
+
end
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
Or you can play with it yourself
|
46
|
+
|
47
|
+
```Ruby
|
48
|
+
# app/controllers/fancy_controller.rb
|
49
|
+
|
50
|
+
class Fancycontroller < ApplicationController
|
51
|
+
include ParamsValidator::Connectors::ParamsFor
|
52
|
+
|
53
|
+
# Creates a Fancy object by checking and validating params
|
54
|
+
# before that
|
55
|
+
#
|
56
|
+
def create
|
57
|
+
...
|
58
|
+
@fancy = Fancy.new(fancy_params)
|
59
|
+
...
|
60
|
+
end
|
61
|
+
|
62
|
+
protected
|
63
|
+
|
64
|
+
# Strong params delegated to ParamValidator::Fancy
|
65
|
+
# and memoized in @fancy_params var returned by this method
|
66
|
+
#
|
67
|
+
# @return [HashwithIndifferentAccess]
|
68
|
+
def fancy_params
|
69
|
+
params_for :fancy
|
70
|
+
end
|
71
|
+
end
|
72
|
+
```
|
73
|
+
|
74
|
+
Some place in your application ( suggested `app/validators/params_validator/` )
|
75
|
+
|
76
|
+
```Ruby
|
77
|
+
# app/validators/param_validator/fancy.rb
|
78
|
+
|
79
|
+
class ParamValidator::Fancy < ParamValidator::Base
|
80
|
+
attr_accessor :user_id, :fancy_name, :fancy_description
|
81
|
+
|
82
|
+
validates :user_id, :fancy_name, presence: true
|
83
|
+
validates :user_id, integer: true
|
84
|
+
end
|
85
|
+
```
|
86
|
+
|
87
|
+
## Contributing
|
88
|
+
|
89
|
+
1. Fork it ( https://github.com/[my-github-username]/params_validator/fork )
|
90
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
91
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
92
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
93
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# app/validators/param_validator/base.rb
|
2
|
+
|
3
|
+
module ParamsValidator
|
4
|
+
class Base
|
5
|
+
include ActiveModel::Validations
|
6
|
+
|
7
|
+
# Memoizes the accessor atrributes in the @attributes variable to be able
|
8
|
+
# to list them and access them
|
9
|
+
#
|
10
|
+
def self.attr_accessor(*vars)
|
11
|
+
@attributes ||= []
|
12
|
+
@attributes.concat vars
|
13
|
+
super(*vars)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Accessor method to the memoized attrubutes setted by the attr_accessor method
|
17
|
+
#
|
18
|
+
# @return [Array(Symbols)]
|
19
|
+
def self.attributes
|
20
|
+
@attributes ||= []
|
21
|
+
|
22
|
+
super_attributes = superclass.attributes if superclass && superclass.respond_to?(:attributes)
|
23
|
+
(super_attributes || []) + @attributes
|
24
|
+
end
|
25
|
+
|
26
|
+
# Initializes the param validator object with the given controller params
|
27
|
+
# HashwithIndifferentAccess object and feeds any defined attribute with the given param key
|
28
|
+
# if they exists
|
29
|
+
#
|
30
|
+
def initialize(params = {})
|
31
|
+
params.each do |key, value|
|
32
|
+
attribute?(key) && send("#{key}=", value)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Alias for the attributes class method
|
37
|
+
#
|
38
|
+
# @return [Array(Symbol)]
|
39
|
+
def attributes
|
40
|
+
self.class.attributes
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns the given attibutes validated and parsed if needed
|
44
|
+
# to be used in the controller
|
45
|
+
#
|
46
|
+
# @return [HashWithIndifferentAccess]
|
47
|
+
def to_params
|
48
|
+
::HashWithIndifferentAccess.new(attributes_hash)
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
# Whenever the given they is a valid attribute or not
|
54
|
+
#
|
55
|
+
# @return [Boolean]
|
56
|
+
def attribute?(key)
|
57
|
+
self.class.instance_methods.include? key.to_sym
|
58
|
+
end
|
59
|
+
|
60
|
+
# Return the attributes of the validator filtered by
|
61
|
+
# attributes has been set in the initializer with params
|
62
|
+
#
|
63
|
+
# @return [Array<Symbol>]
|
64
|
+
def settled_attributes
|
65
|
+
instance_vars = self.instance_variables.map do |attr|
|
66
|
+
attr.to_s[1..-1].to_sym
|
67
|
+
end
|
68
|
+
|
69
|
+
instance_vars & attributes
|
70
|
+
end
|
71
|
+
|
72
|
+
# Return a hash with the attributes and values that
|
73
|
+
# will be sent to the controller
|
74
|
+
#
|
75
|
+
# @return [Hash] {attribute1: value, attribute2: value}
|
76
|
+
def attributes_hash
|
77
|
+
settled_attributes.inject({}) do |out, attribute|
|
78
|
+
value = public_send(attribute)
|
79
|
+
out[attribute] = value
|
80
|
+
out
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module ParamsValidator
|
4
|
+
module Connectors
|
5
|
+
module ParamsFor
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
# Define params for and before_action all in the same method
|
10
|
+
#
|
11
|
+
# @param name [Symbol] camelcased validator class name
|
12
|
+
# @param options [Hash] optional
|
13
|
+
# @option options [Boolean] :class class of the validator
|
14
|
+
# @option options [Array] any option that before_action takes
|
15
|
+
def params_for(name, options = {})
|
16
|
+
method_name = "#{name}_params"
|
17
|
+
define_method(method_name) do
|
18
|
+
return params_for(name, options)
|
19
|
+
end
|
20
|
+
return if options[:before_action] == false
|
21
|
+
send(:before_action, method_name.to_sym, options)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Strong params checker
|
28
|
+
#
|
29
|
+
# @param name [Symbol] camelcased validator class name
|
30
|
+
# @param options [Hash] optional
|
31
|
+
# @option options [Boolean] :class class of the validator
|
32
|
+
# @return [Hash]
|
33
|
+
def params_for(name, options = {})
|
34
|
+
instance_var_name = "@#{name.to_s}_params"
|
35
|
+
instance_var = instance_variable_get(instance_var_name)
|
36
|
+
return instance_var if instance_var.present?
|
37
|
+
|
38
|
+
if options[:class]
|
39
|
+
validator_klass = options[:class]
|
40
|
+
else
|
41
|
+
validator_name = "ParamsValidator::#{name.to_s.classify}"
|
42
|
+
validator_klass = validator_name.constantize
|
43
|
+
end
|
44
|
+
|
45
|
+
validator = validator_klass.new(params)
|
46
|
+
|
47
|
+
unless validator.valid?
|
48
|
+
render status: :bad_request, json: validator.errors.to_json and return false
|
49
|
+
end
|
50
|
+
|
51
|
+
instance_variable_set(instance_var_name, validator.to_params)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'active_support/hash_with_indifferent_access'
|
2
|
+
require 'active_model'
|
3
|
+
require 'params_validator/version'
|
4
|
+
|
5
|
+
module ParamsValidator
|
6
|
+
|
7
|
+
autoload :Base, 'params_validator/base'
|
8
|
+
|
9
|
+
module Connectors
|
10
|
+
autoload :ParamsFor, 'params_validator/connectors/params_for'
|
11
|
+
end
|
12
|
+
end
|
data/params_for.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'params_validator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "params_for"
|
8
|
+
spec.version = ParamsValidator::VERSION
|
9
|
+
spec.authors = ["andresbravog"]
|
10
|
+
spec.email = ["andresbravog@gmail.com"]
|
11
|
+
spec.summary = %q{Params Validatior for controllers using active_model validations.}
|
12
|
+
spec.description = %q{With Params validator oyu should be able to perform controller params validation easy and with any kind of type, format, or custom validation you already know and use in oyur models. }
|
13
|
+
spec.homepage = "https://github.com/andresbravog/params_for"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "activemodel"
|
22
|
+
spec.add_dependency "activesupport"
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'pry'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
|
+
spec.add_development_dependency 'actionpack', '>= 3.0.0'
|
29
|
+
spec.add_development_dependency 'railties', '>= 3.0.0'
|
30
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ParamsValidator::Base do
|
4
|
+
|
5
|
+
let(:validator_klass) do
|
6
|
+
unless defined?(DummyValidator)
|
7
|
+
class DummyValidator < ParamsValidator::Base
|
8
|
+
attr_accessor :id, :name, :type
|
9
|
+
|
10
|
+
validates :type, inclusion: { in: %w{task project}, allow_nil: true }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
DummyValidator
|
14
|
+
end
|
15
|
+
let(:validator) do
|
16
|
+
validator_klass.new(id: 'asd', name: 3, new_param: 'ads')
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'attr_accessor' do
|
20
|
+
it 'assigns every attribute accessor to a attributes variable' do
|
21
|
+
expect(validator_klass.attributes).to eql([:id, :name, :type])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
describe 'initialize' do
|
25
|
+
it 'assigns the given param to the attribute if exists' do
|
26
|
+
expect(validator.id).to eql('asd')
|
27
|
+
end
|
28
|
+
it 'not assigns the given param to the attribute if not exists' do
|
29
|
+
expect { validator.new_param }.to raise_error
|
30
|
+
end
|
31
|
+
end
|
32
|
+
describe 'to_params' do
|
33
|
+
it 'returns a hash with indifferent access' do
|
34
|
+
expect(validator.to_params.class).to eql(HashWithIndifferentAccess)
|
35
|
+
end
|
36
|
+
it 'uses attributes_hash to create the hash' do
|
37
|
+
expect(HashWithIndifferentAccess).to receive(:new).with(validator.send(:attributes_hash))
|
38
|
+
|
39
|
+
validator.to_params
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'attributes_hash' do
|
44
|
+
let(:validator_klass_with_modified_accessor) do
|
45
|
+
unless defined?(NewDummyValidator)
|
46
|
+
class NewDummyValidator < ParamsValidator::Base
|
47
|
+
attr_accessor :id, :name
|
48
|
+
|
49
|
+
def id
|
50
|
+
'foo'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
NewDummyValidator
|
55
|
+
end
|
56
|
+
let(:validator_with_modified_accessor) do
|
57
|
+
validator_klass_with_modified_accessor.new(
|
58
|
+
id: 'asd',
|
59
|
+
name: 3,
|
60
|
+
new_param: 'ads'
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
let(:validator_with_only_one_attribute_set) do
|
65
|
+
validator_klass_with_modified_accessor.new(
|
66
|
+
name: 3,
|
67
|
+
param_to_ignore: 'ads'
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'is protected' do
|
72
|
+
expect { validator.attributes_hash }.to raise_error
|
73
|
+
end
|
74
|
+
it 'returns a hash' do
|
75
|
+
expect(validator.send(:attributes_hash).class).to eql(Hash)
|
76
|
+
end
|
77
|
+
it 'contains every attribute' do
|
78
|
+
[:id, :name].each do |attribute|
|
79
|
+
expect(validator.send(:attributes_hash)).to include(attribute)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'contains attributes set to nil if the nil is explicit' do
|
84
|
+
validator.id = nil
|
85
|
+
expect(validator.send(:attributes_hash)).to include(:id)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'uses accessors to get the attributes' do
|
89
|
+
expect(validator_with_modified_accessor.send(:attributes_hash)[:id]).to eql('foo')
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'return only the attributes explicitly set' do
|
93
|
+
expect(validator_with_only_one_attribute_set.send(:attributes_hash).keys).to eq([:name])
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'is valid with no type given' do
|
97
|
+
expect(validator).to be_valid
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe DummyController, type: :controller do
|
5
|
+
|
6
|
+
describe '.params_for' do
|
7
|
+
it 'defines a before_action with given attributes'
|
8
|
+
it 'defines a instance method to retrieve the params'
|
9
|
+
it 'uses the class option if given'
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '.index' do
|
13
|
+
let(:valid_params) { { id: 123, name: 'new_name' } }
|
14
|
+
let(:response_data) { JSON.parse(subject.body) }
|
15
|
+
before { get :index, valid_params }
|
16
|
+
subject { response }
|
17
|
+
|
18
|
+
it { should be_success }
|
19
|
+
it { expect(response_data).to include('id') }
|
20
|
+
it { expect(response_data['id']).to eql('123') }
|
21
|
+
it { expect(response_data).to include('name') }
|
22
|
+
it { expect(response_data['name']).to eql('new_name') }
|
23
|
+
|
24
|
+
context 'whithout id param' do
|
25
|
+
let(:valid_params) { { id: nil, name: 'new_name' } }
|
26
|
+
|
27
|
+
it { expect(subject.status).to eql(400) }
|
28
|
+
it { expect(response_data['id']).to include('can\'t be blank') }
|
29
|
+
end
|
30
|
+
context 'with a different param' do
|
31
|
+
let(:valid_params) { { id: 123, other_param: 'new_value' } }
|
32
|
+
|
33
|
+
it { should be_success }
|
34
|
+
it { expect(response_data).to_not include('other_param') }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'action_controller'
|
2
|
+
require 'params_validator'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
module Rails
|
6
|
+
def self.application
|
7
|
+
@application ||= begin
|
8
|
+
routes = ActionDispatch::Routing::RouteSet.new
|
9
|
+
OpenStruct.new(:routes => routes, :env_config => {})
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.app
|
14
|
+
application
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module ControllerExampleGroup
|
19
|
+
def self.included(base)
|
20
|
+
base.extend ClassMethods
|
21
|
+
base.send(:include, ActionController::TestCase::Behavior)
|
22
|
+
|
23
|
+
base.prepend_before do
|
24
|
+
@routes = Rails.application.routes
|
25
|
+
@controller = described_class.new
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
module ClassMethods
|
30
|
+
def setup(*methods)
|
31
|
+
methods.each do |method|
|
32
|
+
if method.to_s =~ /^setup_(fixtures|controller_request_and_response)$/
|
33
|
+
prepend_before { send method }
|
34
|
+
else
|
35
|
+
before { send method }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def teardown(*methods)
|
41
|
+
methods.each { |method| after { send method } }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Rails.application.routes.draw do
|
47
|
+
resources :dummy, only: [:index]
|
48
|
+
end
|
49
|
+
|
50
|
+
class ParamsValidator::Dummy < ParamsValidator::Base
|
51
|
+
attr_accessor :id, :name
|
52
|
+
|
53
|
+
validates :id, presence: true
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
class DummyController < ActionController::Base
|
58
|
+
include Rails.application.routes.url_helpers
|
59
|
+
include ParamsValidator::Connectors::ParamsFor
|
60
|
+
|
61
|
+
params_for :dummy
|
62
|
+
|
63
|
+
def index
|
64
|
+
render status: 200, json: dummy_params.to_json
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# require "codeclimate-test-reporter"
|
2
|
+
# CodeClimate::TestReporter.start
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
+
require 'params_validator'
|
7
|
+
require 'rspec'
|
8
|
+
require 'pry'
|
9
|
+
|
10
|
+
# Requires support files
|
11
|
+
Dir[File.join(File.dirname(__FILE__), 'shared/**/*.rb')].each {|f| require f}
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.include Rack::Test::Methods
|
15
|
+
config.include ControllerExampleGroup, type: :controller
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: params_for
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- andresbravog
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
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: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.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'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: actionpack
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 3.0.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 3.0.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: railties
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 3.0.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 3.0.0
|
125
|
+
description: 'With Params validator oyu should be able to perform controller params
|
126
|
+
validation easy and with any kind of type, format, or custom validation you already
|
127
|
+
know and use in oyur models. '
|
128
|
+
email:
|
129
|
+
- andresbravog@gmail.com
|
130
|
+
executables: []
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- ".gitignore"
|
135
|
+
- Gemfile
|
136
|
+
- LICENSE.txt
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- lib/params_validator.rb
|
140
|
+
- lib/params_validator/base.rb
|
141
|
+
- lib/params_validator/connectors/params_for.rb
|
142
|
+
- lib/params_validator/version.rb
|
143
|
+
- params_for.gemspec
|
144
|
+
- spec/params_validator/base_spec.rb
|
145
|
+
- spec/params_validator/connectors/params_for_spec.rb
|
146
|
+
- spec/shared/support/dummy_controller.rb
|
147
|
+
- spec/spec_helper.rb
|
148
|
+
homepage: https://github.com/andresbravog/params_for
|
149
|
+
licenses:
|
150
|
+
- MIT
|
151
|
+
metadata: {}
|
152
|
+
post_install_message:
|
153
|
+
rdoc_options: []
|
154
|
+
require_paths:
|
155
|
+
- lib
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
requirements: []
|
167
|
+
rubyforge_project:
|
168
|
+
rubygems_version: 2.4.2
|
169
|
+
signing_key:
|
170
|
+
specification_version: 4
|
171
|
+
summary: Params Validatior for controllers using active_model validations.
|
172
|
+
test_files:
|
173
|
+
- spec/params_validator/base_spec.rb
|
174
|
+
- spec/params_validator/connectors/params_for_spec.rb
|
175
|
+
- spec/shared/support/dummy_controller.rb
|
176
|
+
- spec/spec_helper.rb
|