http-mock-server 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -4
  3. data/lib/http-mock-server.rb +5 -5
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c36ea5e76a2d6f1a0e2eda34bcdd6ed1a847e1b
4
- data.tar.gz: 2c354c438261a68565ad3b997d35263c99f0109d
3
+ metadata.gz: 110e2a7871cb0e74b6f8fec9fb8e485624eb2352
4
+ data.tar.gz: 135d9cb6d537ef0e24b48ad7a3340ea653563925
5
5
  SHA512:
6
- metadata.gz: d886dc16e73b76e475dac39c063b6c87e57fa39c5dabd6b90796f90874d56d88c70ef418a2733e575134907deabd4028ff6981c7cc269fd6f61ed8c48e1857e0
7
- data.tar.gz: 71f12f8c388c7740e91a46516dae6ab8e4ad7a37187e1351ba9ca51cf3affce4b984aa6713d3a735d959a564c2f14f165094202495d3d1568724cfd7338c7cec
6
+ metadata.gz: e5ca95bb3fadc757e69c814e1be01d5d01fcc543d84073bd7f01cc64446c45b43ced75e32742ea2c7b86b7e5532604694c7d30bd575e5bb1c6a17cccb726ac5e
7
+ data.tar.gz: c9adf8da5670b10d9de7dee73f7559590f917bd76b0aeb9094a6ca1360a312a73045b0caa7b7c6d0bad98cd723327c2a644a0dffaa1c32681410f5a7176462da
data/README.md CHANGED
@@ -20,10 +20,11 @@ Features:
20
20
 
21
21
  ```yml
22
22
  config:
23
- # no_cors: true # don't send CORS headers
24
- port: 8080 # server port
25
- # timeout: 10 # response timeout
26
- verbose: true # shows request params
23
+ namespace: '/api/v1' # prepend to every route
24
+ # no_cors: true # don't send CORS headers
25
+ port: 8080 # server port
26
+ # timeout: 10 # response timeout
27
+ verbose: true # shows request params
27
28
  not_found:
28
29
  body:
29
30
  message: This is not the path you are looking for...
@@ -10,6 +10,7 @@ $config = YAML.load File.read(CONFIG_FILE) rescue begin
10
10
  exit 1
11
11
  end
12
12
  $config['config'] ||= {}
13
+ $config['config']['namespace'] ||= ''
13
14
  $config['routes'] ||= []
14
15
 
15
16
  class HttpMockServer < Sinatra::Base
@@ -40,7 +41,7 @@ class HttpMockServer < Sinatra::Base
40
41
  break if method
41
42
  end
42
43
  if method
43
- send method, rt[method] do
44
+ send method, $config['config']['namespace'] + rt[method] do
44
45
  route = reload_route i
45
46
  code = route['status'] || 200
46
47
  log code, method.upcase, request.path
@@ -90,10 +91,9 @@ class HttpMockServer < Sinatra::Base
90
91
  end
91
92
  end
92
93
 
93
- def interpolate( string )
94
- return '' unless string
95
- vars = string.scan( /{(.*?)}/ ).flatten.map{|t| eval(t)}
96
- string.gsub( /{(.*?)}/, '%s' ) % vars
94
+ def interpolate( input )
95
+ vars = input.to_s.scan( /{(.*?)}/ ).flatten.map{|t| eval(t)}
96
+ input.to_s.gsub( /{(.*?)}/, '%s' ) % vars
97
97
  end
98
98
 
99
99
  def reload_route( route_id )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-mock-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattia Roccoberton