key-vortex 0.2.0 → 0.2.2

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: a34f3ac120e1d77828821334095974c96448d82df26ab5464370e46bc610adb2
4
- data.tar.gz: dd955d832e5a15a37362cd8fe536e0851377e7e2fd0812aebd47b64944fc8039
3
+ metadata.gz: 2fcc61bdf13488c6d20e7f6aa4e889852a37ef52b4ea341d8f4c62c40afe8426
4
+ data.tar.gz: e219c616d9a53e0874221e3ff748a2b4c608dd7c03c86fa765f3f13ffbfabc09
5
5
  SHA512:
6
- metadata.gz: e2ffcd6c05e930f8faba12aacf5ccfc2a004b5e27d8ec0785f0b9c939e61347bec7ff4e339fab98f31b948d966a4722bfd1831bbbc4da53a23d9c0a2ab115c31
7
- data.tar.gz: 3bc5641c8b9bc9c5e55dc5dbf299e968e9793a53aba261410885d4fda9689829aaa3c052169c7b79367d414a389fc5dd33a36a87e47545869ba3fa10d5023bd6
6
+ metadata.gz: df02551af7fd966c79f390ea2e15c5984540774eaf23c8770593ac3f750277eebec72975d10d6c8fa80216cd3096689caaf565308b3629d6eb1e7383ee0c6279
7
+ data.tar.gz: 294e8d44baddfb66d5c909754cf1f48aac50af12fedde35dc9d81e73e8ea68efb1a7a623283229eae745ff19cea284f19b5c08925147089b9b99ff87afe97235
data/.rubocop.yml CHANGED
@@ -20,3 +20,4 @@ Style/Documentation:
20
20
  Metrics/BlockLength:
21
21
  AllowedMethods:
22
22
  - describe
23
+ - context
data/Gemfile CHANGED
@@ -17,6 +17,6 @@ gem "guard-rspec"
17
17
  gem "guard-rubocop"
18
18
 
19
19
  gem "byebug"
20
- gem "stashify-contract"
20
+ gem "key_vortex-contract"
21
21
 
22
22
  gem "yard"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- key-vortex (0.2.0)
4
+ key-vortex (0.2.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -33,7 +33,11 @@ GEM
33
33
  guard (~> 2.0)
34
34
  rubocop (< 2.0)
35
35
  json (2.6.3)
36
+ key_vortex-contract (0.2.1.2)
37
+ rantly (~> 2.0.0)
38
+ rspec (~> 3.0)
36
39
  kwalify (0.7.2)
40
+ language_server-protocol (3.17.0.3)
37
41
  listen (3.8.0)
38
42
  rb-fsevent (~> 0.10, >= 0.10.3)
39
43
  rb-inotify (~> 0.9, >= 0.9.10)
@@ -43,12 +47,14 @@ GEM
43
47
  notiffany (0.1.3)
44
48
  nenv (~> 0.1)
45
49
  shellany (~> 0.0)
46
- parallel (1.22.1)
47
- parser (3.2.2.0)
50
+ parallel (1.23.0)
51
+ parser (3.2.2.3)
48
52
  ast (~> 2.4.1)
53
+ racc
49
54
  pry (0.14.2)
50
55
  coderay (~> 1.1)
51
56
  method_source (~> 1.0)
57
+ racc (1.7.1)
52
58
  rainbow (3.1.1)
53
59
  rake (13.0.6)
54
60
  rantly (2.0.0)
@@ -59,38 +65,36 @@ GEM
59
65
  kwalify (~> 0.7.0)
60
66
  parser (~> 3.2.0)
61
67
  rainbow (>= 2.0, < 4.0)
62
- regexp_parser (2.7.0)
68
+ regexp_parser (2.8.1)
63
69
  rexml (3.2.5)
64
70
  rspec (3.12.0)
65
71
  rspec-core (~> 3.12.0)
66
72
  rspec-expectations (~> 3.12.0)
67
73
  rspec-mocks (~> 3.12.0)
68
- rspec-core (3.12.1)
74
+ rspec-core (3.12.2)
69
75
  rspec-support (~> 3.12.0)
70
- rspec-expectations (3.12.2)
76
+ rspec-expectations (3.12.3)
71
77
  diff-lcs (>= 1.2.0, < 2.0)
72
78
  rspec-support (~> 3.12.0)
73
- rspec-mocks (3.12.5)
79
+ rspec-mocks (3.12.6)
74
80
  diff-lcs (>= 1.2.0, < 2.0)
75
81
  rspec-support (~> 3.12.0)
76
- rspec-support (3.12.0)
77
- rubocop (1.49.0)
82
+ rspec-support (3.12.1)
83
+ rubocop (1.54.1)
78
84
  json (~> 2.3)
85
+ language_server-protocol (>= 3.17.0)
79
86
  parallel (~> 1.10)
80
- parser (>= 3.2.0.0)
87
+ parser (>= 3.2.2.3)
81
88
  rainbow (>= 2.2.2, < 4.0)
82
89
  regexp_parser (>= 1.8, < 3.0)
83
90
  rexml (>= 3.2.5, < 4.0)
84
91
  rubocop-ast (>= 1.28.0, < 2.0)
85
92
  ruby-progressbar (~> 1.7)
86
93
  unicode-display_width (>= 2.4.0, < 3.0)
87
- rubocop-ast (1.28.0)
94
+ rubocop-ast (1.29.0)
88
95
  parser (>= 3.2.1.0)
89
96
  ruby-progressbar (1.13.0)
90
97
  shellany (0.0.1)
91
- stashify-contract (1.0.1)
92
- rantly (~> 2.0.0)
93
- rspec (~> 3.0)
94
98
  thor (1.2.2)
95
99
  unicode-display_width (2.4.2)
96
100
  yard (0.9.34)
@@ -105,11 +109,11 @@ DEPENDENCIES
105
109
  guard-rspec
106
110
  guard-rubocop
107
111
  key-vortex!
112
+ key_vortex-contract
108
113
  rake (~> 13.0)
109
114
  reek (~> 6.1.4)
110
115
  rspec (~> 3.0)
111
116
  rubocop (~> 1.21)
112
- stashify-contract
113
117
  yard
114
118
 
115
119
  BUNDLED WITH
@@ -25,5 +25,9 @@ class KeyVortex
25
25
  def accepts?(value)
26
26
  limitation.accepts?(value)
27
27
  end
28
+
29
+ def enable_json_additions
30
+ @limitation.enable_json_additions
31
+ end
28
32
  end
29
33
  end
@@ -27,9 +27,9 @@ class KeyVortex
27
27
  end
28
28
 
29
29
  def encompasses_constraint?(constraint)
30
- !applicable_constraints(constraint).select do |con|
30
+ applicable_constraints(constraint).any? do |con|
31
31
  con.within?(constraint)
32
- end.empty?
32
+ end
33
33
  end
34
34
 
35
35
  def within?(limitation)
@@ -39,9 +39,9 @@ class KeyVortex
39
39
  end
40
40
 
41
41
  def within_constraint?(constraint)
42
- !applicable_constraints(constraint).select do |con|
42
+ applicable_constraints(constraint).any? do |con|
43
43
  con.within?(constraint)
44
- end.empty?
44
+ end
45
45
  end
46
46
 
47
47
  def applicable_constraints(constraint)
@@ -54,6 +54,27 @@ class KeyVortex
54
54
  value.is_a?(type) && @constraints.all? { |constraint| constraint.accepts?(value) }
55
55
  end
56
56
 
57
+ JSON_ADDITIONS = {
58
+ BigDecimal: "json/add/bigdecimal",
59
+ Complex: "json/add/complex",
60
+ Date: "json/add/date",
61
+ DateTime: "json/add/date_time",
62
+ Exception: "json/add/exception",
63
+ OpenStruct: "json/add/ostruct",
64
+ Range: "json/add/range",
65
+ Rational: "json/add/rational",
66
+ Regexp: "json/add/regexp",
67
+ Set: "json/add/set",
68
+ Struct: "json/add/struct",
69
+ Symbol: "json/add/symbol",
70
+ Time: "json/add/time"
71
+ }.freeze
72
+
73
+ def enable_json_additions
74
+ path = JSON_ADDITIONS[@type.class.name]
75
+ require path if path
76
+ end
77
+
57
78
  def to_s
58
79
  "Limitation: #{@type}\n\t#{@constraints.join('\n\t')}"
59
80
  end
@@ -25,6 +25,7 @@ class KeyVortex
25
25
 
26
26
  def self.register_field(field)
27
27
  field_hash[field.name] = field
28
+ field.enable_json_additions
28
29
  define_getter(field)
29
30
  define_setter(field)
30
31
  end
@@ -51,11 +52,28 @@ class KeyVortex
51
52
  # Long enough to accomodate a GUID
52
53
  field :key, String, length: 36
53
54
 
55
+ attr_reader :values
56
+
54
57
  def initialize(values = {})
55
58
  @values = {}
56
59
  values.each do |name, value|
57
60
  send("#{name}=", value)
58
61
  end
59
62
  end
63
+
64
+ def ==(other)
65
+ self.class == other.class && values == other.values
66
+ end
67
+
68
+ def to_json(*args)
69
+ {
70
+ JSON.create_id => self.class.name,
71
+ "values" => @values
72
+ }.to_json(*args)
73
+ end
74
+
75
+ def self.json_create(object)
76
+ new(object["values"])
77
+ end
60
78
  end
61
79
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class KeyVortex
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: key-vortex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lambda Null
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-10 00:00:00.000000000 Z
11
+ date: 2023-07-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Defines abstractions that can be built on top of for key/value storage
14
14
  on different technologies (file, s3, sql, redis, etc.)