stubify 0.1.0 → 0.1.1
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/LICENSE +22 -0
- data/README.md +71 -0
- data/lib/stubify.rb +23 -3
- data/lib/stubify/server.rb +2 -1
- data/lib/stubify/version.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cdf3c98837d99ac32a3638b51ada2857535b84a
|
4
|
+
data.tar.gz: b42efacd614f1adad54dfeecfbc93077509d9f8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e24d36514b3f6f23e2c054300ae8fadfa3575e16a59c841083bff1402b37419cc9177008c12b3641c6d330114dff32e444b0c081cc15edfe750b43a579f0c22c
|
7
|
+
data.tar.gz: ac125c537db1958ddcfcfa42b4980cb0bab4d4e40e82e77eb871be40dfb87621b6b1662e90ff13598b8bfb3ffee065ed9fca5acd489b59649eca0745f5817852
|
data/LICENSE
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
The MIT License (MIT)
|
3
|
+
|
4
|
+
Copyright (c) 2016 Carlos Vidal
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
# stubify
|
2
|
+
|
3
|
+
[](https://twitter.com/carlostify)
|
4
|
+
[](https://github.com/nakiostudio/xcov/blob/master/LICENSE)
|
5
|
+
[](http://rubygems.org/gems/stubify)
|
6
|
+
|
7
|
+
**stubify** allows you to stub real environments without really doing anything. It runs a [Sinatra](https://github.com/sinatra/sinatra)
|
8
|
+
application locally and, given a host, it forwards all the calls received caching the real responses, that way, next time the local
|
9
|
+
environment receives a request the cached response is returned.
|
10
|
+
|
11
|
+
## Example
|
12
|
+
|
13
|
+
By running the gem with the following command:
|
14
|
+
```bash
|
15
|
+
stubify server --host https://easy-peasy.io --directory fixtures
|
16
|
+
```
|
17
|
+
|
18
|
+
It will create a local environment with address `http://localhost:4567`. Every request received will be recreated against the host
|
19
|
+
provided, therefore a request to `http://localhost:4567/rest_api/user/32325` will return whatever `https://easy-peasy.io/rest_api/user/32325`
|
20
|
+
returns and, in addition, that response will be cached in the directory `fixtures`.
|
21
|
+
|
22
|
+
Next time a request to `http://localhost:4567/rest_api/user/32325` is made the cached payload will be returned.
|
23
|
+
|
24
|
+
## Features
|
25
|
+
|
26
|
+
* Accepts `GET`, `POST`, `PUT` and `DELETE` requests.
|
27
|
+
* HTTP headers, query parameters and request bodies are taken into account.
|
28
|
+
|
29
|
+
## Roadmap
|
30
|
+
|
31
|
+
This is a summary of the ideas which implementation is pending:
|
32
|
+
|
33
|
+
* Whitelisting of endpoints to avoid caching.
|
34
|
+
|
35
|
+
## Installation
|
36
|
+
|
37
|
+
```
|
38
|
+
sudo gem install stubify
|
39
|
+
```
|
40
|
+
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
```
|
44
|
+
stubify server --host https://real-host.com --directory path_to_cached_response
|
45
|
+
|
46
|
+
ACTIONS:
|
47
|
+
|
48
|
+
server [options]
|
49
|
+
|
50
|
+
OPTIONS:
|
51
|
+
|
52
|
+
--host STRING
|
53
|
+
Host the requests will be redirected to. i.e. https://easy-peasy.io
|
54
|
+
|
55
|
+
--directory DIR
|
56
|
+
Path where fixtures will be stored. i.e. fixtures/
|
57
|
+
|
58
|
+
--port STRING
|
59
|
+
Port the local environment will listen to. Default is 4567
|
60
|
+
|
61
|
+
--verbose
|
62
|
+
Increases the amount of information logged
|
63
|
+
```
|
64
|
+
|
65
|
+
## Contributors
|
66
|
+
|
67
|
+
[](https://github.com/nakiostudio)
|
68
|
+
|
69
|
+
## License
|
70
|
+
|
71
|
+
This project is licensed under the terms of the MIT license. See the LICENSE file.
|
data/lib/stubify.rb
CHANGED
@@ -12,14 +12,34 @@ module Stubify
|
|
12
12
|
program :name, 'stubify'
|
13
13
|
program :version, Stubify::VERSION
|
14
14
|
program :description, Stubify::DESCRIPTION
|
15
|
+
program :help, 'Author', 'Carlos Vidal <nakioparkour@gmail.com>'
|
15
16
|
|
16
17
|
command :server do |c|
|
17
|
-
c.syntax = 'server'
|
18
|
-
c.description = ''
|
19
|
-
c.option '--directory STRING', String, 'Path where fixtures will be stored. i.e. fixtures/'
|
18
|
+
c.syntax = 'server [options]'
|
19
|
+
c.description = 'Runs a local environment that will forward the requests received to the host provided. Responses will be cached'
|
20
20
|
c.option '--host STRING', String, 'Host the requests will be redirected to. i.e. https://easy-peasy.io'
|
21
|
+
c.option '--directory DIR', String, 'Path where fixtures will be stored. i.e. fixtures/'
|
22
|
+
c.option '--port STRING', String, 'Port the local environment will listen to. Default is 4567'
|
23
|
+
c.option '--verbose', 'Increases the amount of information logged'
|
21
24
|
c.action do |args, options|
|
25
|
+
# Ensure host is set
|
26
|
+
if options.host.nil?
|
27
|
+
raise 'Host must be provided. Run help command for more details'
|
28
|
+
end
|
29
|
+
|
30
|
+
# Default options
|
31
|
+
options.default \
|
32
|
+
port: '4567',
|
33
|
+
directory: 'fixtures',
|
34
|
+
verbose: false
|
35
|
+
|
36
|
+
# Set env variables
|
37
|
+
ENV['PORT'] = options.port
|
38
|
+
|
39
|
+
# Set options global attr
|
22
40
|
Stubify.options = options
|
41
|
+
|
42
|
+
# Launch Sinatra app
|
23
43
|
require 'stubify/server'
|
24
44
|
end
|
25
45
|
end
|
data/lib/stubify/server.rb
CHANGED
data/lib/stubify/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stubify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Vidal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -86,7 +86,7 @@ dependencies:
|
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
|
-
description:
|
89
|
+
description: Create stub environments the easy way
|
90
90
|
email:
|
91
91
|
- nakioparkour@gmail.com
|
92
92
|
executables:
|
@@ -124,5 +124,5 @@ rubyforge_project:
|
|
124
124
|
rubygems_version: 2.4.8
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
|
-
summary:
|
127
|
+
summary: Create stub environments the easy way
|
128
128
|
test_files: []
|