http-mock-server 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06a392357e0c8018686eba0fc851bf1472a8b320
4
- data.tar.gz: 34e9170a145e5f9c4633c5d20533ee2ab8baeae9
3
+ metadata.gz: cb0f2449583ac229194f86d041ad5b2ac166b601
4
+ data.tar.gz: 4445f809a0e6c2781881fedc4f0dea39f4c856f8
5
5
  SHA512:
6
- metadata.gz: de5f55bd853117c05fd6a33dad38fc3b17f00580f5e3a67ebbc03c36f3268af2d14e2ae39a4a5a0aca395a466cd56581a9ea58df7b9ec87c738ed521a704ba00
7
- data.tar.gz: 79fe46b1195541f57d8a41beee647dcc38447030197d18ed67ce88afce15a0ebe4c2bad9ea5f869999903dc453077184f9a4f1cf0e0db74141e9c57169e0dbe8
6
+ metadata.gz: 2381f980f8415d24bdb265e2c9c6aa95a922e4e401c318290c7188dbb2d0fa03186da212d2102d5e03ecc51c102457f8ddfc875ea78622ffdd85b3957541273f
7
+ data.tar.gz: 103a9330960c8f675d994985221945ff4ca6054e740663ab33b895367bf0fd6a9005bd559179430e3d66a402f8fd443a532572cf7f52b1c0de861993e79028a9
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- http-mock-server (0.1.6)
4
+ http-mock-server (0.1.8)
5
5
  pry (~> 0.11)
6
6
  sinatra (~> 2.0)
7
7
 
data/README.md CHANGED
@@ -19,9 +19,12 @@ Only one option: the config yaml file to use
19
19
 
20
20
  Example: `http-mock-server conf.yml`
21
21
 
22
+ Config file can also be passed setting `ENV['MOCK_CONFIG']` environment variable.
23
+
22
24
  ## Config example
23
25
 
24
26
  ```yml
27
+ ---
25
28
  config:
26
29
  namespace: '/api/v1' # prepend to every route
27
30
  # no_cors: true # don't send CORS headers
@@ -41,12 +44,12 @@ routes:
41
44
  -
42
45
  get: '/posts/:id'
43
46
  body:
44
- content: A random number {rand} !
47
+ content: 'A random number #{rand} !'
45
48
  extra:
46
- today: Today is {DateTime.now}
47
- request: Post id {params[:id]} - request path {request.path}
49
+ today: 'Today is #{DateTime.now}'
50
+ request: 'Post id #{params[:id]} - request path #{request.path}'
48
51
  more:
49
- is_first: "conditional check {params[:id] == '1' ? 'first' : 'other'}"
52
+ is_first: "conditional check #{params[:id] == '1' ? 'first' : 'other'}"
50
53
  an_array:
51
54
  - me
52
55
  - myself
@@ -64,7 +67,7 @@ routes:
64
67
  -
65
68
  get: '/pry'
66
69
  body:
67
- message: '{binding.pry}'
70
+ message: '#{binding.pry}'
68
71
  -
69
72
  post: '/posts'
70
73
  status: 201
@@ -3,11 +3,16 @@ require 'pry'
3
3
  require 'sinatra/base'
4
4
  require 'yaml'
5
5
 
6
+ require_relative File.expand_path( '../version.rb', __FILE__ )
7
+
6
8
  $config_file = ENV['MOCK_CONFIG']
7
9
  if ARGV.length > 0
8
10
  case ARGV[0]
11
+ when '-v'
12
+ puts "http-mock-server v#{MOCK_SERVER_VERSION}"
13
+ exit 0
9
14
  when '-h'
10
- puts "#{$0} config.yml"
15
+ puts "http-mock-server v#{MOCK_SERVER_VERSION}\nSyntax: http-mock-server config.yml"
11
16
  exit 0
12
17
  else
13
18
  if File.exist?(ARGV[0])
@@ -107,8 +112,8 @@ class HttpMockServer < Sinatra::Base
107
112
  end
108
113
 
109
114
  def interpolate( input )
110
- vars = input.to_s.scan( /{(.*?)}/ ).flatten.map{|t| eval(t)}
111
- input.to_s.gsub( /{(.*?)}/, '%s' ) % vars
115
+ vars = input.to_s.scan( /\#{(.*?)}/ ).flatten.map{|t| eval(t)}
116
+ input.to_s.gsub( /\#{(.*?)}/, '%s' ) % vars
112
117
  end
113
118
 
114
119
  def reload_route( route_id )
@@ -0,0 +1 @@
1
+ MOCK_SERVER_VERSION = '0.1.8'
@@ -18,12 +18,12 @@ routes:
18
18
  -
19
19
  get: '/posts/:id'
20
20
  body:
21
- content: A random number {rand} !
21
+ content: 'A random number #{rand} !'
22
22
  extra:
23
- today: Today is {DateTime.now}
24
- request: Post id {params[:id]} - request path {request.path}
23
+ today: 'Today is #{DateTime.now}'
24
+ request: 'Post id #{params[:id]} - request path #{request.path}'
25
25
  more:
26
- is_first: "conditional check {params[:id] == '1' ? 'first' : 'other'}"
26
+ is_first: "conditional check #{params[:id] == '1' ? 'first' : 'other'}"
27
27
  an_array:
28
28
  - me
29
29
  - myself
@@ -41,7 +41,7 @@ routes:
41
41
  -
42
42
  get: '/pry'
43
43
  body:
44
- message: '{binding.pry}'
44
+ message: '#{binding.pry}'
45
45
  -
46
46
  post: '/posts'
47
47
  status: 201
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.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattia Roccoberton
@@ -79,6 +79,7 @@ files:
79
79
  - README.md
80
80
  - bin/http-mock-server
81
81
  - lib/http-mock-server.rb
82
+ - lib/version.rb
82
83
  - spec/responses_spec.rb
83
84
  - spec/spec_helper.rb
84
85
  - spec/test.yml