gris 0.6.6 → 0.6.7

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
2
  SHA1:
3
- metadata.gz: 3e873c93a03313d5d1e706a28ad8efff97185e80
4
- data.tar.gz: e8b54a0b863554344ae8e543ced87fb93d1ebd94
3
+ metadata.gz: 6c44dfcc1ac685c2d2dd3f8787f5c262ed88a99f
4
+ data.tar.gz: d1c4ce0d276cd10afb464d291bffc7ce6a22ca8c
5
5
  SHA512:
6
- metadata.gz: 745b005e79f390c1c50e96d0fc3ab852e8f6c017d522d5d03d871c48c4efd1ec8e60b15b2e47a28261f3cfb2ab607603249752302fce5e405a7a4949e47bfe7c
7
- data.tar.gz: a010026c06521641c8bb4666d0ff0b9ed1cb6c6d47706281f758f759316526e5f19861c2a4421a9f3e94145e9defb256f77468eed38776f1038d2b30f0e72588
6
+ metadata.gz: dc33036643c5d94bbf4c5b2460931eb5cce1165643cbaef8ff5c98157a333bd619417e3ca819c760a7da57af43e4fe31fcb73658a79ead079f829c87dceea68e
7
+ data.tar.gz: fff258722ca3bca8cb98730173a82228c29e0a950bb7c14a82b11f238396c8e85caf3a5b98b6eab9f6b6dcf4b9486a6898c20060466055957347e2ed73701902
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gris (0.6.6)
4
+ gris (0.6.7)
5
5
  activesupport (~> 4.2, >= 4.2.0)
6
6
  chronic (~> 0.10.0)
7
7
  dalli (~> 2.7)
@@ -112,7 +112,7 @@ GEM
112
112
  little-plugger (~> 1.1)
113
113
  multi_json (~> 1.10)
114
114
  minitest (5.8.4)
115
- multi_json (1.11.2)
115
+ multi_json (1.11.3)
116
116
  multi_xml (0.5.5)
117
117
  multipart-post (2.0.0)
118
118
  mustermann19 (0.4.3)
@@ -16,6 +16,8 @@ require 'gris/caching'
16
16
  require 'gris/grape_extensions/crud_helpers'
17
17
  require 'gris/grape_extensions/date_time_helpers'
18
18
  require 'gris/grape_extensions/error_helpers'
19
+ require 'gris/grape_extensions/maximum_length'
20
+ require 'gris/grape_extensions/minimum_length'
19
21
  require 'gris/identity'
20
22
  require 'gris/middleware/health'
21
23
  require 'gris/middleware/error_handlers'
@@ -0,0 +1,9 @@
1
+ module Gris
2
+ class MaximumLength < Grape::Validations::Base
3
+ def validate_param!(attr_name, params)
4
+ unless params[attr_name].length <= @option
5
+ raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: "must be at most #{@option} characters long"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Gris
2
+ class MinimumLength < Grape::Validations::Base
3
+ def validate_param!(attr_name, params)
4
+ unless params[attr_name].length > @option
5
+ raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: "must be at least #{@option} characters long"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  module Gris
2
- VERSION = '0.6.6'.freeze
2
+ VERSION = '0.6.7'.freeze
3
3
 
4
4
  class Version
5
5
  class << self
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gris::MaximumLength do
4
+ include Rack::Test::Methods
5
+
6
+ module MaximumLengthSpec
7
+ class API < Grape::API
8
+ default_format :json
9
+
10
+ params do
11
+ requires :name, maximum_length: 3
12
+ end
13
+
14
+ get do
15
+ end
16
+ end
17
+ end
18
+
19
+ def app
20
+ MaximumLengthSpec::API
21
+ end
22
+
23
+ it 'raises an error for invalid inputs' do
24
+ get '/', name: 'hello'
25
+ expect(last_response.status).to eq(400)
26
+ expect(last_response.body).to eq('{"error":"name must be at most 3 characters long"}')
27
+ end
28
+
29
+ it 'accepts valid input' do
30
+ get '/', name: 'hi'
31
+ expect(last_response.status).to eq(200)
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gris::MinimumLength do
4
+ include Rack::Test::Methods
5
+
6
+ module MinimumLengthSpec
7
+ class API < Grape::API
8
+ default_format :json
9
+
10
+ params do
11
+ requires :name, minimum_length: 3
12
+ end
13
+
14
+ get do
15
+ end
16
+ end
17
+ end
18
+
19
+ def app
20
+ MinimumLengthSpec::API
21
+ end
22
+
23
+ it 'raises an error for invalid inputs' do
24
+ get '/', name: 'hi'
25
+ expect(last_response.status).to eq(400)
26
+ expect(last_response.body).to eq('{"error":"name must be at least 3 characters long"}')
27
+ end
28
+
29
+ it 'accepts valid input' do
30
+ get '/', name: 'hello'
31
+ expect(last_response.status).to eq(200)
32
+ end
33
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Fareed
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-13 00:00:00.000000000 Z
11
+ date: 2016-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -363,6 +363,8 @@ files:
363
363
  - lib/gris/grape_extensions/crud_helpers.rb
364
364
  - lib/gris/grape_extensions/date_time_helpers.rb
365
365
  - lib/gris/grape_extensions/error_helpers.rb
366
+ - lib/gris/grape_extensions/maximum_length.rb
367
+ - lib/gris/grape_extensions/minimum_length.rb
366
368
  - lib/gris/identity.rb
367
369
  - lib/gris/middleware/error_handlers.rb
368
370
  - lib/gris/middleware/health.rb
@@ -385,6 +387,8 @@ files:
385
387
  - spec/grape_extensions/crud_helpers_spec.rb
386
388
  - spec/grape_extensions/date_time_helpers_spec.rb
387
389
  - spec/grape_extensions/error_helpers_spec.rb
390
+ - spec/grape_extensions/maximum_length_spec.rb
391
+ - spec/grape_extensions/minimum_length_spec.rb
388
392
  - spec/identity_spec.rb
389
393
  - spec/integration/application_accept_content_types_spec.rb
390
394
  - spec/integration/application_error_response_spec.rb
@@ -434,6 +438,8 @@ test_files:
434
438
  - spec/grape_extensions/crud_helpers_spec.rb
435
439
  - spec/grape_extensions/date_time_helpers_spec.rb
436
440
  - spec/grape_extensions/error_helpers_spec.rb
441
+ - spec/grape_extensions/maximum_length_spec.rb
442
+ - spec/grape_extensions/minimum_length_spec.rb
437
443
  - spec/identity_spec.rb
438
444
  - spec/integration/application_accept_content_types_spec.rb
439
445
  - spec/integration/application_error_response_spec.rb