dry-elastic_model 0.1.4 → 0.2.0

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: 22daff8f3ddd6c86ca64c773a341229917bc9930bd0897c3090fe8bc51dbd3c6
4
- data.tar.gz: f6abb2425966e98eb112ada1da931831a21da6e4641de261431d8c01b1326148
3
+ metadata.gz: 8730a0d70a0298649084d06ce66c94013da17d86feaf2983aa7ba16658617a3c
4
+ data.tar.gz: ea585bf95b6e9469cd02a83d67ffcb79c605442cca13c7de53208f39d77343da
5
5
  SHA512:
6
- metadata.gz: 943f4654fc39e200de139ed30e9afa48262b1795ef845699b18764b1c60e011d536b5c873d1202d5388d3e6b0fa036977977e0abf47a92d263639c97422579b8
7
- data.tar.gz: 2d9e317a152a567a1ea583922b3e01b607b24d2b5192bf834b439613b771cb8cde90cc5bad70d73e4baab9db22c6a462271e6c5479a42e4b06b78017445cd1b6
6
+ metadata.gz: 2ab98478042ae1f7148357cf89db527fcde378a0050d1dcf230781d52ee2d63372f28c1ec0af4d8ca4d6f36a0eaa4306a7502a4946aee3b23eeb84245f3d2224
7
+ data.tar.gz: 3abd42cfbcf4553b697e50ad7f472c248e64f7578aede523a7d256bf96bddeefecc19073dbb3b2035dd4dd4ef03a5b49ae5d1846000dde24c6db6945a0255689
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.2.0
@@ -10,21 +10,35 @@ module Dry
10
10
 
11
11
  # rubocop:disable Metrics/LineLength
12
12
  # String datatypes
13
- Text = Types::Strict::String.meta(es_name: "text",
13
+ Text = (Types::Strict::String | Types::Strict::Nil).optional.meta(es_name: "text",
14
14
  type_options: TypeOptions::Text,
15
15
  opts: { index: "not_analyzed" })
16
- Keyword = (Types::Strict::String | Types::Strict::Symbol).
16
+ Keyword = (Types::Strict::String | Types::Strict::Symbol).optional.
17
17
  meta(type_options: TypeOptions::Keyword, es_name: "keyword")
18
18
 
19
19
  # Binary datatype
20
20
  # TODO: Verify if correct Base64
21
- Binary = Types::Strict::String.meta(es_name: "binary",
22
- type_options: TypeOptions::Binary)
21
+ Binary = Types::Strict::String.optional.
22
+ meta(
23
+ es_name: "binary",
24
+ type_options: TypeOptions::Binary
25
+ )
23
26
 
24
27
  # Date datatype
25
- # TODO: Test strings
26
- Date = (Types::Strict::Date | Types::Strict::Time | Types.Value("now")).
27
- meta(es_name: "date", type_options: TypeOptions::Date)
28
+ Date = (
29
+ Types::Strict::Date |
30
+ Types::JSON::Date |
31
+ Types.Value("now")
32
+ ).optional.meta(es_name: "date", type_options: TypeOptions::Date)
33
+
34
+ MAX_UNIX_TIME = 2147468400000 # 2038-01-19
35
+ DateTime = (
36
+ Types::Strict::Time |
37
+ Types::Strict::DateTime |
38
+ Types::JSON::DateTime |
39
+ Types::Integer.constrained(gteq: 0, lteq: MAX_UNIX_TIME) |
40
+ Types.Value("now")
41
+ ).optional.meta(es_name: "date", type_options: TypeOptions::Date)
28
42
 
29
43
  # Numeric datatypes
30
44
  LONG_LIMIT = 2**63
@@ -32,43 +46,43 @@ module Dry
32
46
  SHORT_LIMIT = 2**15
33
47
  BYTE_LIMIT = 2**8
34
48
 
35
- Long = Types::Strict::Integer.
49
+ Long = Types::Strict::Integer.optional.
36
50
  constrained(gteq: -LONG_LIMIT, lteq: LONG_LIMIT - 1).
37
51
  meta(type_options: TypeOptions::Numeric, es_name: "long")
38
52
 
39
- Integer = Types::Strict::Integer.
53
+ Integer = Types::Strict::Integer.optional.
40
54
  constrained(gteq: -INTEGER_LIMIT, lteq: INTEGER_LIMIT - 1).
41
55
  meta(type_options: TypeOptions::Numeric, es_name: "integer")
42
56
 
43
- Short = Types::Strict::Integer.
57
+ Short = Types::Strict::Integer.optional.
44
58
  constrained(gteq: -SHORT_LIMIT, lteq: SHORT_LIMIT - 1).
45
59
  meta(type_options: TypeOptions::Numeric, es_name: "short")
46
60
 
47
- Byte = Types::Strict::Integer.
61
+ Byte = Types::Strict::Integer.optional.
48
62
  constrained(gteq: -BYTE_LIMIT, lteq: BYTE_LIMIT - 1).
49
63
  meta(type_options: TypeOptions::Numeric, es_name: "byte")
50
64
 
51
- Double = (Types::Strict::Integer | Types::Strict::Float).
65
+ Double = (Types::Strict::Integer | Types::Strict::Float).optional.
52
66
  meta(es_name: "double")
53
- Float = (Types::Strict::Integer | Types::Strict::Float).
67
+ Float = (Types::Strict::Integer | Types::Strict::Float).optional.
54
68
  meta(type_options: TypeOptions::Numeric, es_name: "float")
55
69
 
56
- HalfFloat = (Types::Strict::Integer | Types::Strict::Float).
70
+ HalfFloat = (Types::Strict::Integer | Types::Strict::Float).optional.
57
71
  meta(type_options: TypeOptions::Numeric, es_name: "half_float")
58
72
 
59
- ScaledFloat = (Types::Strict::Integer | Types::Strict::Float).
73
+ ScaledFloat = (Types::Strict::Integer | Types::Strict::Float).optional.
60
74
  meta(type_options: TypeOptions::ScaledFloat,
61
75
  es_name: "scaled_float")
62
76
 
63
77
  # Boolean datatype
64
- Boolean = (Types::Strict::Bool | Types.Value("true") | Types.Value("false")).
78
+ Boolean = (Types::Strict::Bool | Types.Value("true") | Types.Value("false")).optional.
65
79
  meta(es_name: "boolean", type_options: TypeOptions::Boolean)
66
80
 
67
81
  # IP datatype
68
82
  IP = (
69
83
  Types::Strict::String.constrained(format: Resolv::IPv4::Regex) |
70
84
  Types::Strict::String.constrained(format: Resolv::IPv6::Regex)
71
- ).meta(es_name: "ip", type_options: TypeOptions::IP)
85
+ ).optional.meta(es_name: "ip", type_options: TypeOptions::IP)
72
86
 
73
87
  Array = lambda do |type|
74
88
  Types::Strict::Array.of(type).meta(es_name: type.meta[:es_name])
@@ -92,6 +106,7 @@ module Dry
92
106
  binary: Binary,
93
107
  keyword: Keyword,
94
108
  date: Date,
109
+ datetime: DateTime,
95
110
  long: Long,
96
111
  integer: Integer,
97
112
  short: Short,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-elastic_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konrad Oleksiuk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-25 00:00:00.000000000 Z
11
+ date: 2019-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct