fakeit 0.2.0 → 0.2.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/Gemfile.lock +1 -1
- data/docs/random.md +4 -4
- data/docs/static.md +7 -7
- data/lib/fakeit/openapi/example/integer_example.rb +7 -5
- data/lib/fakeit/openapi/example/number_example.rb +5 -4
- data/lib/fakeit/openapi/loader.rb +1 -1
- 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: 46f41bf28d7b4e0775fe84baa2d134947daa0e1ab114c4ad92bc95f63dc678be
|
4
|
+
data.tar.gz: ba497fcaf61e251e0316f7ac86223d84550f0c74d35db9319d3b152061de557b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7579ea64592fb2106a6a4af5d747f49be9eca739410a0decc0efb97fab22813a59cf416b57f13cfbc3ae0487449e7e1a5350533c98581baaa078d2266e80689
|
7
|
+
data.tar.gz: 42f1b09134e6f67cd933df04c00f9a154888830f500fd4d78a68bef780721d8f70f0409ee1a4d756640f5505783b2539d5856759f9096ff844fba5a023fdc843
|
data/Gemfile.lock
CHANGED
data/docs/random.md
CHANGED
@@ -21,11 +21,11 @@ The following Openapi properties are supported in random response generation
|
|
21
21
|
| |minLength|Default: `0`|
|
22
22
|
| |maxLength|Default: `minLength + 10`|
|
23
23
|
|integer|enum| |
|
24
|
-
| |minimum|Default:
|
25
|
-
| |maximum|Default: `2^
|
24
|
+
| |minimum|Default: `-2^31`|
|
25
|
+
| |maximum|Default: `2^31 - 1`|
|
26
26
|
| |exclusiveMinimum| |
|
27
27
|
| |exclusiveMaximum| |
|
28
28
|
| |multipleOf| |
|
29
|
-
|number|minimum|Default:
|
30
|
-
| |maximum|Default: `2^
|
29
|
+
|number|minimum|Default: `-2^31`|
|
30
|
+
| |maximum|Default: `2^31 - 1`|
|
31
31
|
| |multipleOf| |
|
data/docs/static.md
CHANGED
@@ -19,11 +19,11 @@ Static value generation rule
|
|
19
19
|
| |format=date-time|midnight today|
|
20
20
|
| |minLength|`1` repeats for (minLength + 10) times if no maxLength specified|
|
21
21
|
| |maxLength|`1` repeats for maxLength times|
|
22
|
-
|integer|N/A|`1`|
|
22
|
+
|integer|N/A|`2^31 - 1`|
|
23
23
|
| |enum|first item|
|
24
|
-
| |
|
25
|
-
| |
|
26
|
-
| |multipleOf|
|
27
|
-
|number|N/A
|
28
|
-
| |
|
29
|
-
| |multipleOf|
|
24
|
+
| |maximum|maximum|
|
25
|
+
| |exclusiveMaximum|maximum - 1|
|
26
|
+
| |multipleOf|maximum value meets multipleOf condition|
|
27
|
+
|number|N/A|`2^31 - 1`|
|
28
|
+
| |maximum|maximum rounded to 2 decimal places|
|
29
|
+
| |multipleOf|maximum value meets multipleOf condition|
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module Fakeit
|
2
2
|
module Openapi
|
3
3
|
module Example
|
4
|
-
BIG_INT = 2**32
|
5
|
-
|
6
4
|
def integer_example(example_options)
|
7
5
|
example_options[:static] ? static_integer_example : random_integer_example
|
8
6
|
end
|
@@ -13,7 +11,7 @@ module Fakeit
|
|
13
11
|
if enum
|
14
12
|
enum.to_a.first
|
15
13
|
else
|
16
|
-
|
14
|
+
int_rand_end * int_multiple
|
17
15
|
end
|
18
16
|
end
|
19
17
|
|
@@ -45,7 +43,7 @@ module Fakeit
|
|
45
43
|
if minimum
|
46
44
|
exclusiveMinimum ? minimum + 1 : minimum
|
47
45
|
else
|
48
|
-
1
|
46
|
+
-2**(int_bits - 1)
|
49
47
|
end
|
50
48
|
end
|
51
49
|
|
@@ -53,9 +51,13 @@ module Fakeit
|
|
53
51
|
if maximum
|
54
52
|
exclusiveMaximum ? maximum - 1 : maximum
|
55
53
|
else
|
56
|
-
|
54
|
+
2**(int_bits - 1) - 1
|
57
55
|
end
|
58
56
|
end
|
57
|
+
|
58
|
+
def int_bits
|
59
|
+
(format || 'int32')[/\d+/].to_i
|
60
|
+
end
|
59
61
|
end
|
60
62
|
end
|
61
63
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Fakeit
|
2
2
|
module Openapi
|
3
3
|
module Example
|
4
|
-
|
4
|
+
MIN_NUM = -2**31
|
5
|
+
MAX_NUM = 2**31 - 1
|
5
6
|
|
6
7
|
def number_example(example_options)
|
7
8
|
example_options[:static] ? static_number_example : random_number_example
|
@@ -10,7 +11,7 @@ module Fakeit
|
|
10
11
|
private
|
11
12
|
|
12
13
|
def static_number_example
|
13
|
-
(
|
14
|
+
(num_rand_end * num_multiple)
|
14
15
|
.then { |result| multipleOf ? result : result.round(2) }
|
15
16
|
end
|
16
17
|
|
@@ -32,11 +33,11 @@ module Fakeit
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def min_num
|
35
|
-
(minimum ||
|
36
|
+
(minimum || MIN_NUM).to_f.ceil(2)
|
36
37
|
end
|
37
38
|
|
38
39
|
def max_num
|
39
|
-
(maximum ||
|
40
|
+
(maximum || MAX_NUM).to_f.floor(2)
|
40
41
|
end
|
41
42
|
end
|
42
43
|
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.2.
|
4
|
+
version: 0.2.1
|
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-
|
11
|
+
date: 2019-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|