http-mock-server 0.1.4 → 0.1.5
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 +4 -4
- data/Gemfile +1 -3
- data/README.md +7 -4
- data/lib/http-mock-server.rb +18 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17db1ff5d868cd52e59df9e7b32bb861171614c5
|
4
|
+
data.tar.gz: 2cb416c7a474f43e2c9d9a01f31df3f48566110e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f223245541da21866f55eb5b581145a921530675a20a9dac18436cfd051ee147b3ca8fdbbb044e6422d0098f990e6639e7888993404453268eefa64eca6e79d3
|
7
|
+
data.tar.gz: 8a85c2d9da4867108c82cebf074fd40767f50ca8d502992943175834563dae66afbd15706ca2a808ec227134e9107eabc22f6b93c44a12bdcfa82446a258436c
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -7,15 +7,18 @@ Features:
|
|
7
7
|
- routes reloaded every time (but only the updated ones)
|
8
8
|
- string interpolations on response body (even *binding.pry* to inspect a request)
|
9
9
|
|
10
|
-
## Install
|
11
|
-
|
12
|
-
`gem install http-mock-server`
|
13
|
-
|
14
10
|
## Usage
|
15
11
|
|
12
|
+
- Install the gem: `gem install http-mock-server`
|
16
13
|
- Create a *mock.yml* config file in the current directory (see the [example](mock.yml))
|
17
14
|
- Execute: `http-mock-server`
|
18
15
|
|
16
|
+
## Options
|
17
|
+
|
18
|
+
Only one option: the config yaml file to use
|
19
|
+
|
20
|
+
Example: `http-mock-server conf.yml`
|
21
|
+
|
19
22
|
## Config example
|
20
23
|
|
21
24
|
```yml
|
data/lib/http-mock-server.rb
CHANGED
@@ -1,12 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
require 'pry'
|
2
3
|
require 'sinatra/base'
|
3
4
|
require 'yaml'
|
4
5
|
|
5
|
-
CONFIG_FILE = 'mock.yml'
|
6
6
|
MIME_JSON = ['application/json']
|
7
7
|
|
8
|
-
$
|
9
|
-
|
8
|
+
$config_file = 'mock.yml'
|
9
|
+
if ARGV.length > 0
|
10
|
+
case ARGV[0]
|
11
|
+
when '-h'
|
12
|
+
puts "#{$0} config.yml"
|
13
|
+
exit 0
|
14
|
+
else
|
15
|
+
if File.exist?(ARGV[0])
|
16
|
+
$config_file = ARGV[0]
|
17
|
+
puts "> Using config file: #{$config_file}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
$config = YAML.load File.read($config_file) rescue begin
|
23
|
+
puts "Config file not found: #{$config_file}"
|
10
24
|
exit 1
|
11
25
|
end
|
12
26
|
$config['config'] ||= {}
|
@@ -97,7 +111,7 @@ class HttpMockServer < Sinatra::Base
|
|
97
111
|
end
|
98
112
|
|
99
113
|
def reload_route( route_id )
|
100
|
-
config = YAML.load File.read(
|
114
|
+
config = YAML.load File.read($config_file) || {}
|
101
115
|
return config['not_found'] || {} if route_id < 0
|
102
116
|
return {} if !config['routes'] || !config['routes'][route_id]
|
103
117
|
config['routes'][route_id]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http-mock-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattia Roccoberton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|