rosebud 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 19574b5a177e86648207bb15d1af17e80505121a
4
- data.tar.gz: febfce7937b11d0c6f38a2a9041654910803a9cb
2
+ SHA256:
3
+ metadata.gz: 6754433ae597a94fb170e82268e5ad16d303cccf60299d16f27b2b6573d8869c
4
+ data.tar.gz: 512007825122b56e3c8f438a7cce987cd527d96d561a92ac55e740a0ff208f31
5
5
  SHA512:
6
- metadata.gz: 0f93ff445945fe7f1297c08e7f966834e1b5a241d9a0cf16afd9fb7c76afd82f29d85a33e8f257f886cfd577c566999234d3f2dbfb7fd61158607336394a30b6
7
- data.tar.gz: cf4480d55731be146a74402f5561ff9350ecc42002ec9a9528ed6401d9b9694f059584cbe34d3337716827ddc47be437d8ef93da4b2d978fda9587585c3dbceb
6
+ metadata.gz: fbf29f91b50d76223ec503350ecdd500a513c5cdbc91b4873fdcebda3f67d30bc5f44a0a933888930bda207379d24e52d0fac14e4e8fdb3b8a79ddce5bfff69f
7
+ data.tar.gz: d358f1c6032a7384b9be70bda7d8bf7063c55feabedb615c7c4351334cc9b44666725105fa37cbf15b64cb49459b207243d2ff7f413a7ed16b2d882fa6f8b243
@@ -1,18 +1,14 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.0
6
- - 2.2.0
3
+ - 2.5.0
4
+ - 2.4.3
5
+ - 2.3.6
6
+ - 2.2.9
7
7
  - ruby-head
8
- - jruby-19mode
9
8
  - jruby-head
10
- - rbx
11
9
  env:
12
- - "RAILS_VERSION=3.2.0"
13
- - "RAILS_VERSION=4.0.0"
14
- - "RAILS_VERSION=4.1.0"
15
- - "RAILS_VERSION=4.2.0"
10
+ - "RAILS_VERSION=4.2.10"
11
+ - "RAILS_VERSION=5.1.4"
16
12
  - "RAILS_VERSION=master"
17
13
  matrix:
18
14
  allow_failures:
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ rails_version = case ENV['RAILS_VERSION'] || 'default'
7
7
  when 'master'
8
8
  { git: 'https://github.com/rails/rails.git' }
9
9
  when 'default'
10
- '~> 4.0'
10
+ '~> 5.1'
11
11
  else
12
12
  "~> #{ENV['RAILS_VERSION']}"
13
13
  end
@@ -24,5 +24,4 @@ end
24
24
 
25
25
  group :development do
26
26
  gem 'coveralls', require: false
27
- gem 'test-unit'
28
27
  end
data/README.md CHANGED
@@ -37,14 +37,14 @@ To validate parameters specify a ```params``` block and choose whether the param
37
37
  ```ruby
38
38
  class Api::V1::SomeController < Api::V1::ApplicationController
39
39
  include Rosebud
40
-
40
+
41
41
  params do
42
42
  requires :name
43
43
  optional :phone_number, regex: /\d{10}/, default: '5555555555'
44
44
  end
45
-
45
+
46
46
  ...
47
-
47
+
48
48
  end
49
49
  ```
50
50
 
@@ -53,11 +53,11 @@ It's also possible to define validations for a specific action.
53
53
  ```ruby
54
54
  class Api::V1::SomeController < Api::V1::ApplicationController
55
55
  include Rosebud
56
-
56
+
57
57
  params :create do
58
58
  ...
59
59
  end
60
-
60
+
61
61
  def create
62
62
  ...
63
63
  end
@@ -108,11 +108,11 @@ Add a validation using your custom validator:
108
108
  ```ruby
109
109
  class Api::V1::SomeController < Api::V1::ApplicationController
110
110
  include Rosebud
111
-
111
+
112
112
  params :create do
113
113
  requires :name, length: 2
114
114
  end
115
-
115
+
116
116
  def create
117
117
  ...
118
118
  end
@@ -125,7 +125,7 @@ The following error will be rendered for the ```name``` parameter when provided
125
125
  {
126
126
  "error": "length",
127
127
  "description": "3 characters is too long for name, should be less than or equal to 2",
128
- "additional_info": "Kcik him in the shins!"
128
+ "additional_info": "Kick him in the shins!"
129
129
  }
130
130
  ```
131
131
 
@@ -142,4 +142,4 @@ The following error will be rendered for the ```name``` parameter when provided
142
142
 
143
143
  Rosebud is maintained and funded by [Sticksnleaves](http://www.sticksnleaves.com)
144
144
 
145
- Thanks to all of our [contributors](https://github.com/anthonator/rosebud/graphs/contributors)
145
+ Thanks to all of our [contributors](https://github.com/anthonator/rosebud/graphs/contributors)
@@ -26,7 +26,7 @@ module Rosebud
26
26
  module ClassMethods
27
27
  def params(action = :all, &block)
28
28
  action = action.to_s
29
- before_filter do
29
+ before_action do
30
30
  if action == 'all' || params[:action] == action
31
31
  ParamsScope.new(self, params, &block)
32
32
  end
@@ -1,3 +1,3 @@
1
1
  module Rosebud
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -18,9 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_runtime_dependency 'virtus', '~> 1.0.0'
22
- spec.add_runtime_dependency 'errawr', '>= 1.1.5', '< 1.3.0'
23
- spec.add_runtime_dependency 'errawr-rails', '~> 1.0.0'
21
+ spec.add_runtime_dependency 'virtus', '~> 1.0'
22
+ spec.add_runtime_dependency 'errawr', '~> 1.0'
23
+ spec.add_runtime_dependency 'errawr-rails', '~> 1.0'
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 1.3'
26
26
  spec.add_development_dependency 'rake'
@@ -1,17 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Rosebud::ParamsScope do
4
- context 'RequiresController', type: :controller do
4
+ context 'OptionalController', type: :controller do
5
5
  controller(ApplicationController) do
6
6
  include Rosebud
7
- extend(RSpec::Rails::ControllerExampleGroup::BypassRescue)
8
7
 
9
8
  params do
10
9
  optional :name, type: Integer, default: 1234
11
10
  end
12
11
 
13
12
  def index
14
- render nothing: true
13
+ head :ok
15
14
  end
16
15
  end
17
16
 
@@ -21,7 +20,8 @@ describe Rosebud::ParamsScope do
21
20
  end
22
21
 
23
22
  it 'should render an error if validation fails' do
24
- get :index, name: 'A'
23
+ get :index, params: { name: 'Anthony' } if Rails.version > '4.2'
24
+ get :index, name: 'Anthony' if Rails.version < '5'
25
25
  expect(response.status).to_not eq(200)
26
26
  expect(response.body).to eq({
27
27
  error: 'invalid_parameter',
@@ -4,14 +4,13 @@ describe Rosebud::ParamsScope do
4
4
  context 'RequiresController', type: :controller do
5
5
  controller(ApplicationController) do
6
6
  include Rosebud
7
- extend(RSpec::Rails::ControllerExampleGroup::BypassRescue)
8
7
 
9
8
  params do
10
9
  requires :name
11
10
  end
12
11
 
13
12
  def index
14
- render nothing: true
13
+ head :ok
15
14
  end
16
15
  end
17
16
 
@@ -25,7 +24,8 @@ describe Rosebud::ParamsScope do
25
24
  end
26
25
 
27
26
  it 'should render 200 if a paremeter is not missing' do
28
- get :index, name: 'Anthony'
27
+ get :index, params: { name: 'Anthony' } if Rails.version > '4.2'
28
+ get :index, name: 'Anthony' if Rails.version < '5'
29
29
  expect(response.status).to eq(200)
30
30
  end
31
31
  end
@@ -11,7 +11,7 @@ require 'rspec/rails'
11
11
 
12
12
  # Require supporting ruby files with custom matchers and macros, etc,
13
13
  # in spec/support/ and its subdirectories.
14
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| puts f; require f }
14
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
15
15
 
16
16
  # This file was generated by the `rspec --init` command. Conventionally, all
17
17
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rosebud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-20 00:00:00.000000000 Z
11
+ date: 2018-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus
@@ -16,48 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0
19
+ version: '1.0'
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: 1.0.0
26
+ version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: errawr
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.1.5
34
- - - "<"
31
+ - - "~>"
35
32
  - !ruby/object:Gem::Version
36
- version: 1.3.0
33
+ version: '1.0'
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 1.1.5
44
- - - "<"
38
+ - - "~>"
45
39
  - !ruby/object:Gem::Version
46
- version: 1.3.0
40
+ version: '1.0'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: errawr-rails
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
45
  - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: 1.0.0
47
+ version: '1.0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
52
  - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: 1.0.0
54
+ version: '1.0'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: bundler
63
57
  requirement: !ruby/object:Gem::Requirement
@@ -198,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
192
  version: '0'
199
193
  requirements: []
200
194
  rubyforge_project:
201
- rubygems_version: 2.4.5
195
+ rubygems_version: 2.7.4
202
196
  signing_key:
203
197
  specification_version: 4
204
198
  summary: Finally! An easy way to validate your Rails API parameters.