apiculture 0.0.14 → 0.0.15

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: 52cb357c6a73e99a64db5e12a108b7a73cd5afd8
4
- data.tar.gz: 7c03623922d85c6947ca1ca4026d3b29e584fe4f
3
+ metadata.gz: aef2587d9cd055ecd731cc11364e2660dcf95e9c
4
+ data.tar.gz: 9b4820367da19028395a2d9928e1520808d10fad
5
5
  SHA512:
6
- metadata.gz: 9c97d38dab84b5c6d4cda3d2fb04c30f1c4c3ea8f7ff6cdd6432f5656ddc6523a7a95aaa4919324f28839669e8aa3c7bea0e65c0c73ab274573625805c1bd3e5
7
- data.tar.gz: 8d289be328fbc019a55dab97317c219d0ddb48e181078bc446d5da4d13b8b6de2accf688d03a6965bd8733928efb71f633916ad60a4f6d9900f38c375e0ed26d
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.14 ruby lib
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.14"
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-01"
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
@@ -1,3 +1,3 @@
1
1
  module Apiculture
2
- VERSION = '0.0.14'
2
+ VERSION = '0.0.15'
3
3
  end
@@ -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.14
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-01 00:00:00.000000000 Z
12
+ date: 2016-06-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra