barrister-sinatra 0.0.1 → 0.0.2

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: c0e9be0213a1fe2ca5c861dc18dffc576d53c6f0
4
- data.tar.gz: 12f5652e22767823f487d91bcb76cca00a564055
3
+ metadata.gz: 533384ba51e4ec858ef745450dddced1672c6eb9
4
+ data.tar.gz: 3f45d6c74203dad7d99e28de55f1dbc843f3f336
5
5
  SHA512:
6
- metadata.gz: 86499472c9dac6fbf92b34a4d8d44294fb9ee9e10dad575dd3aef74248d6b7abb540703f54122deaab9e2a41ee4dffe910265e55b4b06a84875c234c203474bb
7
- data.tar.gz: b14b7c42bfe7e96457dab5419aae6dab73b6163aacc7d41344e3b38a0f423aa3170062eb81bf6986275816cf4307923b11a01994c8c929723d6cb373bd33b5eb
6
+ metadata.gz: 49ff9a3b2ce66adf4ba6718021644e2d753b11666bc44bf0a9474823bd8818b39b0bca702c268fb1cb883d750c8cbb07235cec5095572add9357bddd44a21af9
7
+ data.tar.gz: 58e1bcdae9eeeb446e55723301d83a5766240cad7c1d467bc00371b6d647c7bd1e0798f9004de6cec86030d251817da924c9dc669e8a156ff76a74299d0560aa
@@ -1,5 +1,5 @@
1
1
  module Barrister
2
2
  module Sinatra
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -4,38 +4,34 @@ require 'sinatra/base'
4
4
 
5
5
  module Barrister
6
6
 
7
- module Sinatra
7
+ class SinatraContainer
8
8
 
9
- class Container
9
+ def initialize(json_path, mount_path, handlers, port=4567, host='localhost')
10
+ @my_app = ::Sinatra.new do
11
+ set :bind, host
12
+ set :port, port
10
13
 
11
- def initialize(json_path, mount_path, handlers, port=4567, host='localhost')
12
- @my_app = ::Sinatra.new do
13
- set :bind, host
14
- set :port, port
14
+ contract = Barrister::contract_from_file json_path
15
+ server = Barrister::Server.new(contract)
15
16
 
16
- contract = Barrister::contract_from_file json_path
17
- server = Barrister::Server.new(contract)
18
-
19
- # register each provided handler
20
- handlers.each do |handler_klass|
21
- server.add_handler handler_klass.to_s, handler_klass.new
22
- end
17
+ # register each provided handler
18
+ handlers.each do |handler_klass|
19
+ server.add_handler handler_klass.to_s, handler_klass.new
20
+ end
23
21
 
24
- post mount_path do
25
- request.body.rewind
26
- resp = server.handle_json(request.body.read)
22
+ post mount_path do
23
+ request.body.rewind
24
+ resp = server.handle_json(request.body.read)
27
25
 
28
- status 200
29
- headers 'Content-Type' => 'application/json'
30
- resp
31
- end
26
+ status 200
27
+ headers 'Content-Type' => 'application/json'
28
+ resp
32
29
  end
33
30
  end
31
+ end
34
32
 
35
- def start
36
- @my_app.run!
37
- end
38
-
33
+ def start
34
+ @my_app.run!
39
35
  end
40
36
 
41
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barrister-sinatra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erin Swenson-Healey