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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f19c0713bc918d394d2bb1c56251b09cf6dae231a0252c5bbb32c3b99fd284d
4
- data.tar.gz: abcb565c1179594b5ea2b5c2f707c4c3597fbb74e2833edeb5335661866723a0
3
+ metadata.gz: 35c58ad2d52ce6f2ba2375738faaed686b7945ce0d3e438d0d5e3e78f7d32d71
4
+ data.tar.gz: 4c9a1566b7256b2b5b8fb7772daf1329810644b646f2ac0c939d5a3fd824a8db
5
5
  SHA512:
6
- metadata.gz: 962926947343492b3b37a5e1739d8919cc76ffac8491e033e183f72a8ac2346eb62147aed3e870da9dfc8988422c9f0869255d7957253bb56fc0f35772e8065a
7
- data.tar.gz: d471fae5943b4932e07413ee8f67ba484f188efddb0a5d4bf8198f0d791eea07e9744514e7b6ef0890be5dd4932a088bd4f9cc60111f9c72adfadfd96af5fb44
6
+ metadata.gz: 0c3b0375ac956484083b108bb3284ccd33adda44e002b310b7e44fdb2ce151f1b62729a095f9caa02d2953d7dd809e4144fa33612756aa3189cee358e279ae18
7
+ data.tar.gz: 71e3391f4570e12b3c940476e0657e700088ef72f122ccf6e354e71e43ed47ef3d082e7d7f972fc5b35c3fb111aba38110b00d36725eaaafbaeb18750d6ebc96
@@ -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
@@ -1,12 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fakeit (0.6.2)
4
+ fakeit (0.6.3)
5
5
  faker (= 2.13.0)
6
- openapi_parser (= 0.11.2)
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.6)
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.3)
23
+ i18n (1.8.5)
23
24
  concurrent-ruby (~> 1.0)
24
- openapi_parser (0.11.2)
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.87.1)
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.1.0, < 1.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.1.0)
60
- parser (>= 2.7.0.1)
61
+ rubocop-ast (0.3.0)
62
+ parser (>= 2.7.1.4)
61
63
  ruby-progressbar (1.10.1)
62
- simplecov (0.18.5)
64
+ simplecov (0.19.0)
63
65
  docile (~> 1.1)
64
66
  simplecov-html (~> 0.11)
65
67
  simplecov-html (0.12.2)
@@ -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| |
@@ -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.11.2'
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
@@ -4,6 +4,7 @@ require 'open-uri'
4
4
  require 'base64'
5
5
  require 'openapi_parser'
6
6
  require 'faker'
7
+ require 'regexp-examples'
7
8
  require 'rack'
8
9
  require 'logger'
9
10
  require 'rainbow'
@@ -1,4 +1,4 @@
1
1
  module Fakeit
2
- STDOUT.sync = true
3
- Logger = ::Logger.new(STDOUT)
2
+ $stdout.sync = true
3
+ Logger = ::Logger.new($stdout)
4
4
  end
@@ -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 Faker::Base.regexify(pattern)
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 Faker::Base.regexify(pattern)
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'
@@ -1,3 +1,3 @@
1
1
  module Fakeit
2
- VERSION = '0.6.2'.freeze
2
+ VERSION = '0.6.3'.freeze
3
3
  end
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.2
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-07-12 00:00:00.000000000 Z
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.11.2
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.11.2
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