http-mock-server 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -3
  3. data/README.md +7 -4
  4. data/lib/http-mock-server.rb +18 -4
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dae1ac5e29006cabd735aefbbaf243d6b20c84e3
4
- data.tar.gz: e0ca780edfcdf556f3515670127c631273584af2
3
+ metadata.gz: 17db1ff5d868cd52e59df9e7b32bb861171614c5
4
+ data.tar.gz: 2cb416c7a474f43e2c9d9a01f31df3f48566110e
5
5
  SHA512:
6
- metadata.gz: e8b8a5b7582a1adb5852200e42f14bff54405e440e5bf4f3406725032c3e6c2b94882e4f0523bdfe5ac30225c78aad3bbaa311649292aa40c4825bff3bba7620
7
- data.tar.gz: 04dfc86943b1e959a4bdc9ae34b71169af423335f50f3eb75419280f516599dc1f875966235327900014ae1286b7591bb1579c2585d74957d3f093d866968cb9
6
+ metadata.gz: f223245541da21866f55eb5b581145a921530675a20a9dac18436cfd051ee147b3ca8fdbbb044e6422d0098f990e6639e7888993404453268eefa64eca6e79d3
7
+ data.tar.gz: 8a85c2d9da4867108c82cebf074fd40767f50ca8d502992943175834563dae66afbd15706ca2a808ec227134e9107eabc22f6b93c44a12bdcfa82446a258436c
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'sinatra'
4
-
5
- gem 'pry'
3
+ gemspec
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
@@ -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
- $config = YAML.load File.read(CONFIG_FILE) rescue begin
9
- puts "Config file not found: #{CONFIG_FILE}"
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(CONFIG_FILE) || {}
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
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-01 00:00:00.000000000 Z
11
+ date: 2018-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry