hobby-json 0.0.2 → 0.0.3

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: 52a1dc53955a48ad4dcbf1778b7c3893c4d9951f
4
- data.tar.gz: f9df643f17b3e43343152e8eed30d9d9a7668209
3
+ metadata.gz: 4b84e5a7d8db34627e1f5bec5d24c64627e102cb
4
+ data.tar.gz: df2792d1288bc19f6883fd7f15d7db0c6d628a16
5
5
  SHA512:
6
- metadata.gz: 6aa4fea91fb922ea872b3a33f2af55f69fd654bfbe4f3abe6e276416da9b56db7c488b9c30506f99f617cc21ff59ef4bdcc0cb6297f71fb7ad18cb0e7bae08ea
7
- data.tar.gz: feef520f01216f4e99366c9d473c51ae5f24b2b71b777ecc043a5aafcc37db7dbbb91179b3d8a94a2fe04f90102e6693208a56dd2427353b6e6851a4dfcc0318
6
+ metadata.gz: b7505c89b687929c3428a71234428cb100341482ceff937db8df559b1c8ae74e95a6258eceb1484f4a700423c11d1907e47f5259ea0f5477dc3fed437b4a829b
7
+ data.tar.gz: 853a766ea9250ae063acfb4434dd2865613cd415ea9ac2fb042fa7b8186efd048b92ba5f3832d4d82661b0fee8cdbc1ace4740ab403c067667136870a86546b5
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'hobby-devtools'
data/hobby-json.gemspec CHANGED
@@ -1,7 +1,9 @@
1
1
  Gem::Specification.new do |g|
2
2
  g.name = 'hobby-json'
3
3
  g.files = `git ls-files`.split($/)
4
- g.version = '0.0.2'
4
+ g.version = '0.0.3'
5
5
  g.summary = 'A way to work with JSON in Hobby without too much verbosity.'
6
6
  g.authors = ['Anatoly Chernow']
7
+
8
+ g.add_dependency 'rack'
7
9
  end
data/lib/hobby/json.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'json'
2
+ require 'rack'
2
3
 
3
4
  module Hobby
4
5
  module JSON
@@ -14,7 +15,11 @@ module Hobby
14
15
  end
15
16
 
16
17
  def json
17
- @json ||= ::JSON.parse request.body.read
18
+ @json ||= begin
19
+ ::JSON.parse request.body.read
20
+ rescue
21
+ response.status = 400
22
+ end
18
23
  end
19
24
  end
20
25
  end
data/spec/helper.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'hobby'
2
+ require 'hobby/json'
3
+ require 'hobby/devtools/rspec_helper'
@@ -0,0 +1,6 @@
1
+ - get:
2
+ path: /
3
+ body: not very json
4
+
5
+ response:
6
+ status: 400
@@ -0,0 +1,13 @@
1
+ - get:
2
+ path: /
3
+ body:
4
+ string: string
5
+ number: 42
6
+
7
+ response:
8
+ status: 200
9
+ body:
10
+ string: string
11
+ number: 42
12
+ headers.>:
13
+ Content-Type: application/json
data/spec/http_spec.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'helper'
2
+
3
+ Hobby::Devtools::RSpec.describe do
4
+ app do
5
+ Class.new do
6
+ include Hobby
7
+ include Hobby::JSON
8
+ get { json }
9
+ end.new
10
+ end
11
+ path 'spec/http/*.yml'
12
+ end
metadata CHANGED
@@ -1,23 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobby-json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoly Chernow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-13 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2016-12-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description:
14
28
  email:
15
29
  executables: []
16
30
  extensions: []
17
31
  extra_rdoc_files: []
18
32
  files:
33
+ - ".gitignore"
34
+ - Gemfile
19
35
  - hobby-json.gemspec
20
36
  - lib/hobby/json.rb
37
+ - spec/helper.rb
38
+ - spec/http/bad_request.yml
39
+ - spec/http/echo.yml
40
+ - spec/http_spec.rb
21
41
  homepage:
22
42
  licenses: []
23
43
  metadata: {}