fakeit 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -48
- data/Gemfile.lock +12 -10
- data/docs/random.md +1 -1
- data/fakeit.gemspec +2 -1
- data/lib/fakeit.rb +1 -0
- data/lib/fakeit/logger.rb +2 -2
- data/lib/fakeit/openapi/example/string_example.rb +14 -2
- data/lib/fakeit/version.rb +1 -1
- metadata +18 -5
- data/lib/fakeit/core_extensions/path_item_finder.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35c58ad2d52ce6f2ba2375738faaed686b7945ce0d3e438d0d5e3e78f7d32d71
|
4
|
+
data.tar.gz: 4c9a1566b7256b2b5b8fb7772daf1329810644b646f2ac0c939d5a3fd824a8db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c3b0375ac956484083b108bb3284ccd33adda44e002b310b7e44fdb2ce151f1b62729a095f9caa02d2953d7dd809e4144fa33612756aa3189cee358e279ae18
|
7
|
+
data.tar.gz: 71e3391f4570e12b3c940476e0657e700088ef72f122ccf6e354e71e43ed47ef3d082e7d7f972fc5b35c3fb111aba38110b00d36725eaaafbaeb18750d6ebc96
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
AllCops:
|
2
2
|
TargetRubyVersion: 2.7
|
3
|
+
NewCops: enable
|
3
4
|
|
4
5
|
Style/Documentation:
|
5
6
|
Enabled: false
|
@@ -18,53 +19,5 @@ Metrics/BlockLength:
|
|
18
19
|
Security/Open:
|
19
20
|
Enabled: false
|
20
21
|
|
21
|
-
Style/HashEachMethods:
|
22
|
-
Enabled: true
|
23
|
-
|
24
22
|
Style/HashTransformKeys:
|
25
23
|
Enabled: false
|
26
|
-
|
27
|
-
Style/HashTransformValues:
|
28
|
-
Enabled: true
|
29
|
-
|
30
|
-
Lint/RaiseException:
|
31
|
-
Enabled: true
|
32
|
-
|
33
|
-
Lint/StructNewOverride:
|
34
|
-
Enabled: true
|
35
|
-
|
36
|
-
Layout/EmptyLinesAroundAttributeAccessor:
|
37
|
-
Enabled: true
|
38
|
-
|
39
|
-
Layout/SpaceAroundMethodCallOperator:
|
40
|
-
Enabled: true
|
41
|
-
|
42
|
-
Lint/DeprecatedOpenSSLConstant:
|
43
|
-
Enabled: true
|
44
|
-
|
45
|
-
Lint/MixedRegexpCaptureTypes:
|
46
|
-
Enabled: true
|
47
|
-
|
48
|
-
Style/AccessorGrouping:
|
49
|
-
Enabled: true
|
50
|
-
|
51
|
-
Style/BisectedAttrAccessor:
|
52
|
-
Enabled: true
|
53
|
-
|
54
|
-
Style/ExponentialNotation:
|
55
|
-
Enabled: true
|
56
|
-
|
57
|
-
Style/RedundantAssignment:
|
58
|
-
Enabled: true
|
59
|
-
|
60
|
-
Style/RedundantFetchBlock:
|
61
|
-
Enabled: true
|
62
|
-
|
63
|
-
Style/RedundantRegexpCharacterClass:
|
64
|
-
Enabled: true
|
65
|
-
|
66
|
-
Style/RedundantRegexpEscape:
|
67
|
-
Enabled: true
|
68
|
-
|
69
|
-
Style/SlicingWithRange:
|
70
|
-
Enabled: true
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fakeit (0.6.
|
4
|
+
fakeit (0.6.3)
|
5
5
|
faker (= 2.13.0)
|
6
|
-
openapi_parser (= 0.
|
6
|
+
openapi_parser (= 0.12.1)
|
7
7
|
rack (~> 2.0)
|
8
8
|
rack-cors (~> 1.0)
|
9
9
|
rainbow (~> 3.0)
|
10
|
+
regexp-examples (= 1.5.1)
|
10
11
|
slop (~> 4.8)
|
11
12
|
|
12
13
|
GEM
|
@@ -14,14 +15,14 @@ GEM
|
|
14
15
|
specs:
|
15
16
|
ast (2.4.1)
|
16
17
|
byebug (11.1.3)
|
17
|
-
concurrent-ruby (1.1.
|
18
|
+
concurrent-ruby (1.1.7)
|
18
19
|
diff-lcs (1.4.4)
|
19
20
|
docile (1.3.2)
|
20
21
|
faker (2.13.0)
|
21
22
|
i18n (>= 1.6, < 2)
|
22
|
-
i18n (1.8.
|
23
|
+
i18n (1.8.5)
|
23
24
|
concurrent-ruby (~> 1.0)
|
24
|
-
openapi_parser (0.
|
25
|
+
openapi_parser (0.12.1)
|
25
26
|
parallel (1.19.2)
|
26
27
|
parser (2.7.1.4)
|
27
28
|
ast (~> 2.4.1)
|
@@ -32,6 +33,7 @@ GEM
|
|
32
33
|
rack (>= 1.0, < 3)
|
33
34
|
rainbow (3.0.0)
|
34
35
|
rake (12.3.3)
|
36
|
+
regexp-examples (1.5.1)
|
35
37
|
regexp_parser (1.7.1)
|
36
38
|
rexml (3.2.4)
|
37
39
|
rspec (3.9.0)
|
@@ -47,19 +49,19 @@ GEM
|
|
47
49
|
diff-lcs (>= 1.2.0, < 2.0)
|
48
50
|
rspec-support (~> 3.9.0)
|
49
51
|
rspec-support (3.9.3)
|
50
|
-
rubocop (0.
|
52
|
+
rubocop (0.90.0)
|
51
53
|
parallel (~> 1.10)
|
52
54
|
parser (>= 2.7.1.1)
|
53
55
|
rainbow (>= 2.2.2, < 4.0)
|
54
56
|
regexp_parser (>= 1.7)
|
55
57
|
rexml
|
56
|
-
rubocop-ast (>= 0.
|
58
|
+
rubocop-ast (>= 0.3.0, < 1.0)
|
57
59
|
ruby-progressbar (~> 1.7)
|
58
60
|
unicode-display_width (>= 1.4.0, < 2.0)
|
59
|
-
rubocop-ast (0.
|
60
|
-
parser (>= 2.7.
|
61
|
+
rubocop-ast (0.3.0)
|
62
|
+
parser (>= 2.7.1.4)
|
61
63
|
ruby-progressbar (1.10.1)
|
62
|
-
simplecov (0.
|
64
|
+
simplecov (0.19.0)
|
63
65
|
docile (~> 1.1)
|
64
66
|
simplecov-html (~> 0.11)
|
65
67
|
simplecov-html (0.12.2)
|
data/docs/random.md
CHANGED
@@ -11,7 +11,7 @@ The following Openapi properties are supported in random response generation
|
|
11
11
|
| |minItems|Default: `1`|
|
12
12
|
| |maxItems|Default: `minItems + 2`|
|
13
13
|
|string|enum| |
|
14
|
-
| |pattern| |
|
14
|
+
| |pattern|Random generated once and cached for performance concern|
|
15
15
|
| |format=uri| |
|
16
16
|
| |format=uuid| |
|
17
17
|
| |format=guid| |
|
data/fakeit.gemspec
CHANGED
@@ -33,9 +33,10 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency 'simplecov', '~> 0.18'
|
34
34
|
|
35
35
|
spec.add_dependency 'faker', '2.13.0'
|
36
|
-
spec.add_dependency 'openapi_parser', '0.
|
36
|
+
spec.add_dependency 'openapi_parser', '0.12.1'
|
37
37
|
spec.add_dependency 'rack', '~> 2.0'
|
38
38
|
spec.add_dependency 'rack-cors', '~> 1.0'
|
39
39
|
spec.add_dependency 'rainbow', '~> 3.0'
|
40
|
+
spec.add_dependency 'regexp-examples', '1.5.1'
|
40
41
|
spec.add_dependency 'slop', '~> 4.8'
|
41
42
|
end
|
data/lib/fakeit.rb
CHANGED
data/lib/fakeit/logger.rb
CHANGED
@@ -27,6 +27,8 @@ module Fakeit
|
|
27
27
|
}.freeze
|
28
28
|
|
29
29
|
def string_example(example_options)
|
30
|
+
@string_pattern ||= Regexp.new(pattern) if pattern
|
31
|
+
|
30
32
|
if example_options[:use_static][type: 'string', property: example_options[:property]]
|
31
33
|
static_string_example
|
32
34
|
else
|
@@ -39,7 +41,7 @@ module Fakeit
|
|
39
41
|
def static_string_example
|
40
42
|
fixed_faker do
|
41
43
|
if enum then enum.to_a.first
|
42
|
-
elsif pattern then
|
44
|
+
elsif pattern then static_string_pattern
|
43
45
|
elsif format then static_string_format
|
44
46
|
elsif length_constraint then static_string_with_length
|
45
47
|
else 'string'
|
@@ -56,7 +58,7 @@ module Fakeit
|
|
56
58
|
|
57
59
|
def random_string_example
|
58
60
|
if enum then enum.to_a.sample
|
59
|
-
elsif pattern then
|
61
|
+
elsif pattern then random_string_pattern
|
60
62
|
elsif format then random_string_format
|
61
63
|
elsif length_constraint then string_with_length
|
62
64
|
else Faker::Book.title
|
@@ -71,6 +73,12 @@ module Fakeit
|
|
71
73
|
(STATIC_FORMAT_HANDLERS[format] || method(:unknown_format))[]
|
72
74
|
end
|
73
75
|
|
76
|
+
def static_string_pattern
|
77
|
+
@static_string_pattern ||= @string_pattern.examples(
|
78
|
+
max_repeater_variance: 1, max_group_results: 1, max_results_limit: 1
|
79
|
+
).first
|
80
|
+
end
|
81
|
+
|
74
82
|
def length_constraint
|
75
83
|
minLength || maxLength
|
76
84
|
end
|
@@ -91,6 +99,10 @@ module Fakeit
|
|
91
99
|
(RANDOM_FORMAT_HANDLERS[format] || method(:unknown_format))[]
|
92
100
|
end
|
93
101
|
|
102
|
+
def random_string_pattern
|
103
|
+
@random_string_pattern ||= @string_pattern.random_example(max_repeater_variance: 1)
|
104
|
+
end
|
105
|
+
|
94
106
|
def unknown_format
|
95
107
|
Fakeit::Logger.info("Unknown string format: #{format}")
|
96
108
|
'Unknown string format'
|
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.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Feng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - '='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 0.
|
131
|
+
version: 0.12.1
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - '='
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.
|
138
|
+
version: 0.12.1
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rack
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +178,20 @@ dependencies:
|
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '3.0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: regexp-examples
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - '='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 1.5.1
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - '='
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 1.5.1
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: slop
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,7 +231,6 @@ files:
|
|
217
231
|
- lib/fakeit/app/app.rb
|
218
232
|
- lib/fakeit/app/body_parser.rb
|
219
233
|
- lib/fakeit/app/options.rb
|
220
|
-
- lib/fakeit/core_extensions/path_item_finder.rb
|
221
234
|
- lib/fakeit/core_extensions/schema.rb
|
222
235
|
- lib/fakeit/logger.rb
|
223
236
|
- lib/fakeit/middleware/recorder.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# https://github.com/ota42y/openapi_parser/issues/75
|
2
|
-
module OpenAPIParser
|
3
|
-
class PathItemFinder
|
4
|
-
private
|
5
|
-
|
6
|
-
def find_path_and_params(http_method, request_path)
|
7
|
-
return [request_path, {}] if matches_directly?(request_path, http_method)
|
8
|
-
|
9
|
-
matching = matching_paths_with_params(request_path, http_method)
|
10
|
-
|
11
|
-
matching.min_by { |match| match[1].size }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|