satz 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/.gems +2 -2
  3. data/lib/satz.rb +4 -8
  4. data/satz.gemspec +2 -2
  5. data/test/all.rb +19 -2
  6. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 527d7619ab15c936ca0bdf194f1a26c039df1308
4
- data.tar.gz: 052df45b1c3496cef2af07ef95e2a5a1f2d78b09
3
+ metadata.gz: 74a6c677b00a43f5684df2a33d2dd43d36fd9c18
4
+ data.tar.gz: 7c5f6e0889399f2df854c4eecd6fc6a12ff7bf5f
5
5
  SHA512:
6
- metadata.gz: 9c9bd5c8d92e1cc753943f2f7f564c64073dc72eff7e51360e84270169958ea3df45371b343da4267e8644fb5782674bf50d1a46d8c1e960276451654593669d
7
- data.tar.gz: 387a0f85f1130dcc26109061b407830d6315a796c8dfa6d01a9a705f91da42c5457ce552b38603f12133647a297f020c073237119c13b511fdb373df01b31c00
6
+ metadata.gz: cd6bbfb98fd009435b1d755bd7079245bfd2116da3416e2916827bd159b397ffaaab81a8da70e3706fe2c577befa95e8029e0eb346f800d47c53f5fadb8addd2
7
+ data.tar.gz: 81afd919658be0c406028f17fe81dcf2916bfb848fb804d59d59b8bc0148382be605af8531e1d41e4f23b6ae97a3d5508ce650d90b4701474e1ad25e20bf9fc1
data/.gems CHANGED
@@ -1,3 +1,3 @@
1
- syro -v 2.0.0
2
- rack-test -v 0.6.3
1
+ syro -v 3.0.0
3
2
  basica -v 1.0.0
3
+ rack-test -v 0.6.3
@@ -73,25 +73,21 @@ class Satz
73
73
  # res.status = 401
74
74
  # reply(error: "Unauthorized")
75
75
  # end
76
- #
76
+ #
77
77
  def auth
78
78
  basic_auth(env) { |user, pass| yield(user, pass) }
79
79
  end
80
80
 
81
- # Respond by default with JSON. The default charset
82
- # for "application/json" is UTF-8.
83
- def default_headers
84
- { "Content-Type" => "application/json" }
85
- end
86
-
87
81
  # Read JSON data from the POST request.
88
82
  def read
89
83
  Satz.serializer.load(req.body.read)
84
+ ensure
85
+ req.body.rewind
90
86
  end
91
87
 
92
88
  # Write JSON data to the response.
93
89
  def reply(data)
94
- res.write(Satz.serializer.dump(data))
90
+ res.json(Satz.serializer.dump(data))
95
91
  end
96
92
  end
97
93
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "satz"
3
- s.version = "0.0.4"
3
+ s.version = "0.1.0"
4
4
  s.summary = "Framework for JSON microservices"
5
5
  s.description = "Framework for JSON microservices"
6
6
  s.authors = ["Michel Martens"]
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
 
11
11
  s.files = `git ls-files`.split("\n")
12
12
 
13
- s.add_dependency "syro", "~> 2.0"
13
+ s.add_dependency "syro", "~> 3.0"
14
14
  s.add_dependency "basica", "~> 1.0"
15
15
  s.add_development_dependency "cutest"
16
16
  s.add_development_dependency "rack-test"
@@ -1,6 +1,6 @@
1
1
  A1 = Satz.define do
2
2
  get do
3
- reply(read)
3
+ reply("null")
4
4
  end
5
5
 
6
6
  post do
@@ -31,7 +31,7 @@ test "get" do |app|
31
31
  app.get("/")
32
32
 
33
33
  assert_equal 200, app.last_response.status
34
- assert_equal %Q(null), app.last_response.body
34
+ assert_equal %Q("null"), app.last_response.body
35
35
  end
36
36
 
37
37
  test "post" do |app|
@@ -84,3 +84,20 @@ test "get" do |app|
84
84
  assert_equal 200, app.last_response.status
85
85
  assert_equal %Q(olleh), app.last_response.body
86
86
  end
87
+
88
+ Stream = Satz.define do
89
+ post do
90
+ _ = read
91
+
92
+ res.write(req.body.read)
93
+ end
94
+ end
95
+
96
+ test "stream" do
97
+ json = JSON.generate(ok: true)
98
+
99
+ app = Driver.new(Stream)
100
+ app.post("/", json)
101
+
102
+ assert_equal json, app.last_response.body
103
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: satz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Martens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-22 00:00:00.000000000 Z
11
+ date: 2017-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: syro
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: basica
29
29
  requirement: !ruby/object:Gem::Requirement