apiculture 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/apiculture.gemspec +3 -3
- data/lib/apiculture/sinatra_instance_methods.rb +3 -2
- data/lib/apiculture/version.rb +1 -1
- data/spec/apiculture_spec.rb +13 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aef2587d9cd055ecd731cc11364e2660dcf95e9c
|
4
|
+
data.tar.gz: 9b4820367da19028395a2d9928e1520808d10fad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb167f833039971ee16271a0c48d911fd11eeb3aeddfc130bdd31773b63f60e670d4901f0b21cd6ad4357bd499e78243a58c5c07532b4a36685e56e5c0156216
|
7
|
+
data.tar.gz: 49b05ae437ad28f58d132534b2b7b07c5b768e60cc60e53b9ab5fd85c4fabccf2f9bcc49c8cb5c7867daa2de1b940a7f21d00debccd3c19b315781966f792f76
|
data/apiculture.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: apiculture 0.0.
|
5
|
+
# stub: apiculture 0.0.15 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "apiculture"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.15"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Julik Tarkhanov", "WeTransfer"]
|
14
|
-
s.date = "2016-06-
|
14
|
+
s.date = "2016-06-06"
|
15
15
|
s.description = "A toolkit for building REST APIs on top of Sinatra"
|
16
16
|
s.email = "me@julik.nl"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -6,8 +6,9 @@ module Apiculture::SinatraInstanceMethods
|
|
6
6
|
|
7
7
|
# Convert the given structure to JSON, set the content-type and
|
8
8
|
# return the JSON string
|
9
|
-
def json_response(structure)
|
9
|
+
def json_response(structure, status: 200)
|
10
10
|
content_type :json
|
11
|
+
status status
|
11
12
|
JSON.pretty_generate(structure)
|
12
13
|
end
|
13
14
|
|
@@ -33,4 +34,4 @@ module Apiculture::SinatraInstanceMethods
|
|
33
34
|
|
34
35
|
json_response call_result
|
35
36
|
end
|
36
|
-
end
|
37
|
+
end
|
data/lib/apiculture/version.rb
CHANGED
data/spec/apiculture_spec.rb
CHANGED
@@ -314,7 +314,19 @@ describe "Apiculture" do
|
|
314
314
|
parsed_body = JSON.load(last_response.body)
|
315
315
|
expect(parsed_body['foo']).to eq('bar')
|
316
316
|
end
|
317
|
-
|
317
|
+
it 'adds support for json_response to set http status code', run: true do
|
318
|
+
@app_class = Class.new(Sinatra::Base) do
|
319
|
+
extend Apiculture
|
320
|
+
settings.show_exceptions = false
|
321
|
+
settings.raise_errors = true
|
322
|
+
api_method :post, '/some-json' do
|
323
|
+
json_response({foo: 'bar'}, status: 201)
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
post '/some-json'
|
328
|
+
expect(last_response.status).to eq(201)
|
329
|
+
end
|
318
330
|
it 'adds support for json_halt' do
|
319
331
|
@app_class = Class.new(Sinatra::Base) do
|
320
332
|
extend Apiculture
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apiculture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-06-
|
12
|
+
date: 2016-06-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|