fakeit 0.3.1 → 0.4.0
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.lock +18 -18
- data/README.md +1 -0
- data/lib/fakeit/app/app.rb +1 -1
- data/lib/fakeit/openapi/loader.rb +0 -1
- data/lib/fakeit/openapi/specification.rb +19 -2
- data/lib/fakeit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85a4951080b18afc8b31d90df48908395db45187040d55234f2e8d012d7e604b
|
4
|
+
data.tar.gz: '038962f3d25cf199b87c45f3e2556fea349ae30939da4a8ea5a67a6fc32c7c47'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 803b450a3aaff3aae4a2a93e99e205076476585ba344febf551a6fadb743f6d44e3c9955179e296530fd0fb37ead6b3f60ebefb825cd5dd0771cb2811e067a68
|
7
|
+
data.tar.gz: efc7ba4148e2f557e882c449266f8559eb2208fcd0801157aea4130ec95b42378826d6b932742a1879d1f666be0613e1a699e423e425a4a3afe7cbc5477c2a01
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fakeit (0.
|
4
|
+
fakeit (0.4.0)
|
5
5
|
faker (~> 2.2)
|
6
6
|
openapi_parser (= 0.3.1)
|
7
7
|
rack (~> 2.0)
|
@@ -17,15 +17,15 @@ GEM
|
|
17
17
|
concurrent-ruby (1.1.5)
|
18
18
|
diff-lcs (1.3)
|
19
19
|
docile (1.3.2)
|
20
|
-
faker (2.
|
21
|
-
i18n (
|
20
|
+
faker (2.5.0)
|
21
|
+
i18n (~> 1.6.0)
|
22
22
|
i18n (1.6.0)
|
23
23
|
concurrent-ruby (~> 1.0)
|
24
24
|
jaro_winkler (1.5.3)
|
25
25
|
json (2.2.0)
|
26
26
|
openapi_parser (0.3.1)
|
27
|
-
parallel (1.
|
28
|
-
parser (2.6.
|
27
|
+
parallel (1.18.0)
|
28
|
+
parser (2.6.5.0)
|
29
29
|
ast (~> 2.4.0)
|
30
30
|
rack (2.0.7)
|
31
31
|
rack-cors (1.0.3)
|
@@ -33,20 +33,20 @@ GEM
|
|
33
33
|
rack (>= 1.0, < 3)
|
34
34
|
rainbow (3.0.0)
|
35
35
|
rake (12.3.3)
|
36
|
-
rspec (3.
|
37
|
-
rspec-core (~> 3.
|
38
|
-
rspec-expectations (~> 3.
|
39
|
-
rspec-mocks (~> 3.
|
40
|
-
rspec-core (3.
|
41
|
-
rspec-support (~> 3.
|
42
|
-
rspec-expectations (3.
|
36
|
+
rspec (3.9.0)
|
37
|
+
rspec-core (~> 3.9.0)
|
38
|
+
rspec-expectations (~> 3.9.0)
|
39
|
+
rspec-mocks (~> 3.9.0)
|
40
|
+
rspec-core (3.9.0)
|
41
|
+
rspec-support (~> 3.9.0)
|
42
|
+
rspec-expectations (3.9.0)
|
43
43
|
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
-
rspec-support (~> 3.
|
45
|
-
rspec-mocks (3.
|
44
|
+
rspec-support (~> 3.9.0)
|
45
|
+
rspec-mocks (3.9.0)
|
46
46
|
diff-lcs (>= 1.2.0, < 2.0)
|
47
|
-
rspec-support (~> 3.
|
48
|
-
rspec-support (3.
|
49
|
-
rubocop (0.
|
47
|
+
rspec-support (~> 3.9.0)
|
48
|
+
rspec-support (3.9.0)
|
49
|
+
rubocop (0.75.0)
|
50
50
|
jaro_winkler (~> 1.5.1)
|
51
51
|
parallel (~> 1.10)
|
52
52
|
parser (>= 2.6)
|
@@ -54,7 +54,7 @@ GEM
|
|
54
54
|
ruby-progressbar (~> 1.7)
|
55
55
|
unicode-display_width (>= 1.4.0, < 1.7)
|
56
56
|
ruby-progressbar (1.10.1)
|
57
|
-
simplecov (0.17.
|
57
|
+
simplecov (0.17.1)
|
58
58
|
docile (~> 1.1)
|
59
59
|
json (>= 1.8, < 3)
|
60
60
|
simplecov-html (~> 0.10.0)
|
data/README.md
CHANGED
@@ -33,6 +33,7 @@ After tried several existing options, we cannot find a best solution to meet all
|
|
33
33
|
* Randomly or statically generated response
|
34
34
|
* Request validation
|
35
35
|
* Load specification from local or remote
|
36
|
+
* Support hot reload local specification
|
36
37
|
* Support specification in yaml or json format
|
37
38
|
|
38
39
|
**Note:** Only support json content type as of now
|
data/lib/fakeit/app/app.rb
CHANGED
@@ -1,15 +1,32 @@
|
|
1
1
|
module Fakeit
|
2
2
|
module Openapi
|
3
3
|
class Specification
|
4
|
-
def initialize(
|
5
|
-
@
|
4
|
+
def initialize(spec_file)
|
5
|
+
@spec_file = spec_file
|
6
|
+
@mtime = File.mtime(spec_file) if File.exist?(spec_file)
|
7
|
+
@doc = Fakeit::Openapi.load(spec_file)
|
6
8
|
end
|
7
9
|
|
8
10
|
def operation(method, path, options)
|
11
|
+
reload_spec if @mtime
|
12
|
+
|
9
13
|
@doc
|
10
14
|
.request_operation(method, path)
|
11
15
|
&.then { |operation| Operation.new(operation, options) }
|
12
16
|
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def reload_spec
|
21
|
+
new_mtime = File.mtime(@spec_file)
|
22
|
+
|
23
|
+
return if @mtime == new_mtime
|
24
|
+
|
25
|
+
@mtime = new_mtime
|
26
|
+
@doc = Fakeit::Openapi.load(@spec_file)
|
27
|
+
rescue StandardError => _e
|
28
|
+
Fakeit::Logger.warn(Rainbow('Invalid spec file, use previous snapshot instead').red)
|
29
|
+
end
|
13
30
|
end
|
14
31
|
end
|
15
32
|
end
|
data/lib/fakeit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fakeit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Feng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09
|
11
|
+
date: 2019-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|