jsonatra 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/jsonatra.gemspec +1 -1
- data/lib/jsonatra/break_rest.rb +18 -0
- data/lib/jsonatra/helpers/params.rb +1 -0
- data/lib/jsonatra/version.rb +1 -1
- data/lib/jsonatra.rb +0 -13
- data/test/jsonatra_spec.rb +1 -0
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0d8d44af79ab5cf6dee75d62af27c876641e24f
|
4
|
+
data.tar.gz: 0968b006ea9a44217ed38cff192626f862c73999
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 055915bb1afe2f636053cb156a6dea217ed6271e8400c3c7394b15c9fd47b72e76fad56eb10bcae9c86f60fbd9e177e6f9cd4213bdf10690e4d892c18806e35e
|
7
|
+
data.tar.gz: 290faa9e84a16a0356bc6e00bc966ae02ed922607c8d20309c61a5bb7bdef0421f4a3c8b700d078b12e777fa6b5658da8d632769d306d5b11a48f436039eb753
|
data/README.md
CHANGED
@@ -7,14 +7,13 @@ This is a very opinionated gem. Some of its strongly held views:
|
|
7
7
|
|
8
8
|
* [Sinatra](http://sinatrarb.com) is the BEST.
|
9
9
|
* JSON is awesome!
|
10
|
-
* REST is fo' suckas.
|
11
10
|
* HTTP status codes are for **transport**!
|
12
11
|
|
13
12
|
To that end, this gem subclasses `Sinatra::Base` and `Sinatra::Response` adding
|
14
13
|
some helpful defaults to achieve the following goals:
|
15
14
|
|
16
15
|
* always respond with JSON, route blocks' return hashes are automatically converted
|
17
|
-
* all GET routes also respond to POST for large query values
|
16
|
+
* all GET routes also respond to POST for large query values (`require 'jsonatra/break_rest'`)
|
18
17
|
* accept form encoded **OR** JSON POST body parameters
|
19
18
|
* always supply CORS headers
|
20
19
|
* short-circuit OPTIONS requests
|
data/jsonatra.gemspec
CHANGED
@@ -4,7 +4,7 @@ require File.expand_path('../lib/jsonatra/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Kenichi Nakamura"]
|
6
6
|
gem.email = ["kenichi.nakamura@gmail.com"]
|
7
|
-
gem.description = gem.summary = "
|
7
|
+
gem.description = gem.summary = "JSON API extension for Sinatra"
|
8
8
|
gem.homepage = "https://github.com/esripdx/jsonatra"
|
9
9
|
gem.files = `git ls-files | grep -Ev '^(myapp|examples)'`.split("\n")
|
10
10
|
gem.test_files = `git ls-files -- test/*`.split("\n")
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Jsonatra
|
2
|
+
class Base < Sinatra::Base
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
# because some parameters can be too large for normal GET query strings,
|
7
|
+
# all GET routes also accept a POST with body data, with the same parameter
|
8
|
+
# names and behavior
|
9
|
+
#
|
10
|
+
alias_method :sinatra_get, :get
|
11
|
+
def get(*args, &block)
|
12
|
+
sinatra_get *args, &block
|
13
|
+
post *args, &block
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/jsonatra/version.rb
CHANGED
data/lib/jsonatra.rb
CHANGED
@@ -108,19 +108,6 @@ module Jsonatra
|
|
108
108
|
}
|
109
109
|
end
|
110
110
|
|
111
|
-
class << self
|
112
|
-
|
113
|
-
# because some parameters can be too large for normal GET query strings,
|
114
|
-
# all GET routes also accept a POST with body data, with the same parameter
|
115
|
-
# names and behavior
|
116
|
-
#
|
117
|
-
alias_method :sinatra_get, :get
|
118
|
-
def get(*args, &block)
|
119
|
-
sinatra_get *args, &block
|
120
|
-
post *args, &block
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
111
|
end
|
125
112
|
|
126
113
|
end
|
data/test/jsonatra_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenichi Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description:
|
27
|
+
description: JSON API extension for Sinatra
|
28
28
|
email:
|
29
29
|
- kenichi.nakamura@gmail.com
|
30
30
|
executables: []
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- Rakefile
|
40
40
|
- jsonatra.gemspec
|
41
41
|
- lib/jsonatra.rb
|
42
|
+
- lib/jsonatra/break_rest.rb
|
42
43
|
- lib/jsonatra/helpers/error.rb
|
43
44
|
- lib/jsonatra/helpers/params.rb
|
44
45
|
- lib/jsonatra/response.rb
|
@@ -67,12 +68,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
68
|
version: '0'
|
68
69
|
requirements: []
|
69
70
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.0.
|
71
|
+
rubygems_version: 2.0.14
|
71
72
|
signing_key:
|
72
73
|
specification_version: 4
|
73
|
-
summary:
|
74
|
+
summary: JSON API extension for Sinatra
|
74
75
|
test_files:
|
75
76
|
- test/helper.rb
|
76
77
|
- test/helpers/error_spec.rb
|
77
78
|
- test/helpers/params_spec.rb
|
78
79
|
- test/jsonatra_spec.rb
|
80
|
+
has_rdoc:
|