sinatra-param 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -10
- data/Gemfile.lock +13 -17
- data/README.md +9 -8
- data/example/Gemfile +6 -3
- data/example/Gemfile.lock +24 -15
- data/example/Procfile +1 -1
- data/example/app.rb +0 -6
- data/example/config.ru +3 -0
- data/lib/sinatra/param/version.rb +1 -1
- data/sinatra-param.gemspec +6 -4
- data/spec/dummy/app.rb +1 -0
- metadata +38 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18a23f0baef3417d12254ac4083df075ffe7b05c
|
4
|
+
data.tar.gz: 854af92a66e992f5c1b86dc14600f4715b6dc338
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25576e0184a0adabe22e38f05c7b2a717506b1692e8c90e604f8af2a09214a1609bdf1b12cae630843a72f02d0660f75022cc7449763cd4dc972d011f9b8f536
|
7
|
+
data.tar.gz: abbcb391d35a4cde22b8d5a1acc97bd8a312d494edeb27b399618e7b997f5edfa5ef0f264b332a75ac767b4dbb62d969682f6bd8d545a077960c1a231952f223
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sinatra-param (0.
|
4
|
+
sinatra-param (1.0.0)
|
5
5
|
sinatra (~> 1.3)
|
6
6
|
|
7
7
|
GEM
|
@@ -12,34 +12,30 @@ GEM
|
|
12
12
|
rack (1.5.2)
|
13
13
|
rack-protection (1.5.0)
|
14
14
|
rack
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
rspec-
|
20
|
-
|
21
|
-
|
22
|
-
rspec-core (2.13.1)
|
23
|
-
rspec-expectations (2.13.0)
|
15
|
+
rake (10.1.0)
|
16
|
+
rspec (2.14.1)
|
17
|
+
rspec-core (~> 2.14.0)
|
18
|
+
rspec-expectations (~> 2.14.0)
|
19
|
+
rspec-mocks (~> 2.14.0)
|
20
|
+
rspec-core (2.14.5)
|
21
|
+
rspec-expectations (2.14.3)
|
24
22
|
diff-lcs (>= 1.1.3, < 2.0)
|
25
|
-
rspec-mocks (2.
|
23
|
+
rspec-mocks (2.14.3)
|
26
24
|
simplecov (0.7.1)
|
27
25
|
multi_json (~> 1.0)
|
28
26
|
simplecov-html (~> 0.7.1)
|
29
27
|
simplecov-html (0.7.1)
|
30
|
-
sinatra (1.4.
|
31
|
-
rack (~> 1.
|
28
|
+
sinatra (1.4.3)
|
29
|
+
rack (~> 1.4)
|
32
30
|
rack-protection (~> 1.4)
|
33
31
|
tilt (~> 1.3, >= 1.3.4)
|
34
|
-
tilt (1.
|
32
|
+
tilt (1.4.1)
|
35
33
|
|
36
34
|
PLATFORMS
|
37
35
|
ruby
|
38
36
|
|
39
37
|
DEPENDENCIES
|
40
|
-
rack-test
|
41
38
|
rake
|
42
|
-
rspec
|
39
|
+
rspec
|
43
40
|
simplecov
|
44
|
-
sinatra (~> 1.3)
|
45
41
|
sinatra-param!
|
data/README.md
CHANGED
@@ -1,16 +1,23 @@
|
|
1
1
|
# sinatra-param
|
2
2
|
_Parameter Contracts for Sinatra_
|
3
3
|
|
4
|
-
REST conventions
|
4
|
+
REST conventions take the guesswork out of designing and consuming web APIs. Simply `GET`, `POST`, `PATCH`, or `DELETE` resource endpoints, and you get what you'd expect.
|
5
5
|
|
6
|
-
|
6
|
+
However, when it comes to figuring out what parameters are expected... well, all bets are off.
|
7
|
+
|
8
|
+
This Sinatra extension takes a first step to solving this problem on the developer side
|
7
9
|
|
8
10
|
**`sinatra-param` allows you to declare, validate, and transform endpoint parameters as you would in frameworks like [ActiveModel](http://rubydoc.info/gems/activemodel/3.2.3/frames) or [DataMapper](http://datamapper.org/).**
|
9
11
|
|
12
|
+
> Use `sinatra-param` in combination with [`Rack::PostBodyContentTypeParser` and `Rack::NestedParams`](https://github.com/rack/rack-contrib) to automatically parameterize JSON `POST` bodies and nested parameters.
|
13
|
+
|
10
14
|
## Example
|
11
15
|
|
12
16
|
``` ruby
|
17
|
+
require 'sinatra/base'
|
13
18
|
require 'sinatra/param'
|
19
|
+
require 'json'
|
20
|
+
|
14
21
|
class App < Sinatra::Base
|
15
22
|
helpers Sinatra::Param
|
16
23
|
|
@@ -59,12 +66,6 @@ Passing a `default` option will provide a default value for a parameter if none
|
|
59
66
|
|
60
67
|
Use the `transform` option to take even more of the business logic of parameter I/O out of your code. Anything that responds to `to_proc` (including Procs and symbols) will do.
|
61
68
|
|
62
|
-
## Next Steps
|
63
|
-
|
64
|
-
- [Design by contract](http://en.wikipedia.org/wiki/Design_by_contract) like this is great for developers, and with a little meta-programming, it could probably be exposed to users as well. The self-documenting dream of [Hypermedia folks](http://twitter.com/#!/steveklabnik) could well be within reach.
|
65
|
-
|
66
|
-
- Support for Rails-style Arrays (`'key[]=value1&key[]=value2'`) and Hashes (`'key[a]=value1&key[b]=value2`). /via [@manton](https://twitter.com/#!/manton)
|
67
|
-
|
68
69
|
## Contact
|
69
70
|
|
70
71
|
Mattt Thompson
|
data/example/Gemfile
CHANGED
data/example/Gemfile.lock
CHANGED
@@ -1,24 +1,33 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/mattt/Code/Ruby/sinatra-param
|
3
|
+
specs:
|
4
|
+
sinatra-param (0.1.3)
|
5
|
+
sinatra (~> 1.3)
|
6
|
+
|
1
7
|
GEM
|
2
|
-
remote:
|
8
|
+
remote: https://rubygems.org/
|
3
9
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
rack (1.
|
7
|
-
rack-protection (1.
|
10
|
+
json (1.8.1)
|
11
|
+
kgio (2.8.1)
|
12
|
+
rack (1.5.2)
|
13
|
+
rack-protection (1.5.0)
|
14
|
+
rack
|
15
|
+
raindrops (0.12.0)
|
16
|
+
sinatra (1.4.3)
|
17
|
+
rack (~> 1.4)
|
18
|
+
rack-protection (~> 1.4)
|
19
|
+
tilt (~> 1.3, >= 1.3.4)
|
20
|
+
tilt (1.4.1)
|
21
|
+
unicorn (4.6.3)
|
22
|
+
kgio (~> 2.6)
|
8
23
|
rack
|
9
|
-
|
10
|
-
rack (~> 1.3, >= 1.3.6)
|
11
|
-
rack-protection (~> 1.2)
|
12
|
-
tilt (~> 1.3, >= 1.3.3)
|
13
|
-
thin (1.3.1)
|
14
|
-
daemons (>= 1.0.9)
|
15
|
-
eventmachine (>= 0.12.6)
|
16
|
-
rack (>= 1.0.0)
|
17
|
-
tilt (1.3.3)
|
24
|
+
raindrops (~> 0.7)
|
18
25
|
|
19
26
|
PLATFORMS
|
20
27
|
ruby
|
21
28
|
|
22
29
|
DEPENDENCIES
|
30
|
+
json
|
23
31
|
sinatra
|
24
|
-
|
32
|
+
sinatra-param!
|
33
|
+
unicorn
|
data/example/Procfile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
web: bundle exec
|
1
|
+
web: bundle exec unicorn -p $PORT
|
data/example/app.rb
CHANGED
data/example/config.ru
CHANGED
data/sinatra-param.gemspec
CHANGED
@@ -5,15 +5,17 @@ Gem::Specification.new do |s|
|
|
5
5
|
s.name = "sinatra-param"
|
6
6
|
s.authors = ["Mattt Thompson"]
|
7
7
|
s.email = "m@mattt.me"
|
8
|
-
s.homepage = "
|
8
|
+
s.homepage = "https://github.com/mattt/sinatra-param"
|
9
9
|
s.version = Sinatra::Param::VERSION
|
10
10
|
s.platform = Gem::Platform::RUBY
|
11
|
-
s.summary = "
|
12
|
-
s.description = "
|
11
|
+
s.summary = "Parameter Contracts for Sinatra"
|
12
|
+
s.description = "sinatra-param allows you to declare, validate, and transform endpoint parameters as you would in frameworks like ActiveModel or DataMapper."
|
13
13
|
|
14
14
|
s.add_dependency "sinatra", "~> 1.3"
|
15
15
|
|
16
|
-
s.add_development_dependency
|
16
|
+
s.add_development_dependency "rake"
|
17
|
+
s.add_development_dependency "rspec"
|
18
|
+
s.add_development_dependency "simplecov"
|
17
19
|
|
18
20
|
s.files = Dir["./**/*"].reject { |file| file =~ /\.\/(bin|log|pkg|script|spec|test|vendor)/ }
|
19
21
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/spec/dummy/app.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-param
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattt Thompson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -24,21 +24,50 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: simplecov
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
30
58
|
requirements:
|
31
|
-
- -
|
59
|
+
- - '>='
|
32
60
|
- !ruby/object:Gem::Version
|
33
61
|
version: '0'
|
34
62
|
type: :development
|
35
63
|
prerelease: false
|
36
64
|
version_requirements: !ruby/object:Gem::Requirement
|
37
65
|
requirements:
|
38
|
-
- -
|
66
|
+
- - '>='
|
39
67
|
- !ruby/object:Gem::Version
|
40
68
|
version: '0'
|
41
|
-
description:
|
69
|
+
description: sinatra-param allows you to declare, validate, and transform endpoint
|
70
|
+
parameters as you would in frameworks like ActiveModel or DataMapper.
|
42
71
|
email: m@mattt.me
|
43
72
|
executables: []
|
44
73
|
extensions: []
|
@@ -104,7 +133,7 @@ files:
|
|
104
133
|
- spec/parameter_type_coercion_spec.rb
|
105
134
|
- spec/parameter_validations_spec.rb
|
106
135
|
- spec/spec_helper.rb
|
107
|
-
homepage:
|
136
|
+
homepage: https://github.com/mattt/sinatra-param
|
108
137
|
licenses: []
|
109
138
|
metadata: {}
|
110
139
|
post_install_message:
|
@@ -113,12 +142,12 @@ require_paths:
|
|
113
142
|
- lib
|
114
143
|
required_ruby_version: !ruby/object:Gem::Requirement
|
115
144
|
requirements:
|
116
|
-
- -
|
145
|
+
- - '>='
|
117
146
|
- !ruby/object:Gem::Version
|
118
147
|
version: '0'
|
119
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
149
|
requirements:
|
121
|
-
- -
|
150
|
+
- - '>='
|
122
151
|
- !ruby/object:Gem::Version
|
123
152
|
version: '0'
|
124
153
|
requirements: []
|
@@ -126,7 +155,7 @@ rubyforge_project:
|
|
126
155
|
rubygems_version: 2.0.3
|
127
156
|
signing_key:
|
128
157
|
specification_version: 4
|
129
|
-
summary:
|
158
|
+
summary: Parameter Contracts for Sinatra
|
130
159
|
test_files:
|
131
160
|
- spec/dummy/app.rb
|
132
161
|
- spec/parameter_sets_spec.rb
|