key-vortex 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.reek.yml +4 -0
- data/.rubocop.yml +5 -0
- data/Gemfile +11 -1
- data/Gemfile.lock +116 -0
- data/Guardfile +56 -0
- data/key-vortex.gemspec +3 -1
- data/lib/key_vortex/adapter/memory.rb +24 -0
- data/lib/key_vortex/record.rb +31 -0
- data/lib/key_vortex/version.rb +2 -2
- data/lib/key_vortex.rb +14 -2
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f16908e843138ceefe28247b31cc1fe6b0a6e4c704174f7af7f98bcf8ac433dd
|
4
|
+
data.tar.gz: 759988a8108b14ca1be504c1a6eeb102b1efc86b970b33c6078fa4290963b67b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 233359a3b6e85fe314abed09916491de40596ca47ac927dc18587970059c2470ef7071d6346baf67893e14416d041147130e62d2f4698011b81813b951225025
|
7
|
+
data.tar.gz: e4fc5a84f2726d24cbf2362890eb7dcfd2da5a67ad32e8982b73961f8acb0b34a94ff982a0075aa7a119008ead364bfa57608616729875801ac1efa0df44e332
|
data/.reek.yml
ADDED
data/.rubocop.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
AllCops:
|
2
2
|
TargetRubyVersion: 2.6
|
3
|
+
NewCops: enable
|
3
4
|
|
4
5
|
Style/StringLiterals:
|
5
6
|
Enabled: true
|
@@ -11,3 +12,7 @@ Style/StringLiteralsInInterpolation:
|
|
11
12
|
|
12
13
|
Layout/LineLength:
|
13
14
|
Max: 120
|
15
|
+
|
16
|
+
# TODO: Remove once design is set
|
17
|
+
Style/Documentation:
|
18
|
+
Enabled: false
|
data/Gemfile
CHANGED
@@ -7,6 +7,16 @@ gemspec
|
|
7
7
|
|
8
8
|
gem "rake", "~> 13.0"
|
9
9
|
|
10
|
+
gem "reek", "~> 6.1.4"
|
10
11
|
gem "rspec", "~> 3.0"
|
11
|
-
|
12
12
|
gem "rubocop", "~> 1.21"
|
13
|
+
|
14
|
+
gem "guard"
|
15
|
+
gem "guard-reek"
|
16
|
+
gem "guard-rspec"
|
17
|
+
gem "guard-rubocop"
|
18
|
+
|
19
|
+
gem "byebug"
|
20
|
+
gem "stashify-contract"
|
21
|
+
|
22
|
+
gem "yard"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
key-vortex (0.1.2)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
byebug (11.1.3)
|
11
|
+
coderay (1.1.3)
|
12
|
+
diff-lcs (1.5.0)
|
13
|
+
ffi (1.15.5)
|
14
|
+
formatador (1.1.0)
|
15
|
+
guard (2.18.0)
|
16
|
+
formatador (>= 0.2.4)
|
17
|
+
listen (>= 2.7, < 4.0)
|
18
|
+
lumberjack (>= 1.0.12, < 2.0)
|
19
|
+
nenv (~> 0.1)
|
20
|
+
notiffany (~> 0.0)
|
21
|
+
pry (>= 0.13.0)
|
22
|
+
shellany (~> 0.0)
|
23
|
+
thor (>= 0.18.1)
|
24
|
+
guard-compat (1.2.1)
|
25
|
+
guard-reek (1.2.0)
|
26
|
+
guard-compat (~> 1.1)
|
27
|
+
reek
|
28
|
+
guard-rspec (4.7.3)
|
29
|
+
guard (~> 2.1)
|
30
|
+
guard-compat (~> 1.1)
|
31
|
+
rspec (>= 2.99.0, < 4.0)
|
32
|
+
guard-rubocop (1.5.0)
|
33
|
+
guard (~> 2.0)
|
34
|
+
rubocop (< 2.0)
|
35
|
+
json (2.6.3)
|
36
|
+
kwalify (0.7.2)
|
37
|
+
listen (3.8.0)
|
38
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
39
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
40
|
+
lumberjack (1.2.8)
|
41
|
+
method_source (1.0.0)
|
42
|
+
nenv (0.3.0)
|
43
|
+
notiffany (0.1.3)
|
44
|
+
nenv (~> 0.1)
|
45
|
+
shellany (~> 0.0)
|
46
|
+
parallel (1.22.1)
|
47
|
+
parser (3.2.2.0)
|
48
|
+
ast (~> 2.4.1)
|
49
|
+
pry (0.14.2)
|
50
|
+
coderay (~> 1.1)
|
51
|
+
method_source (~> 1.0)
|
52
|
+
rainbow (3.1.1)
|
53
|
+
rake (13.0.6)
|
54
|
+
rantly (2.0.0)
|
55
|
+
rb-fsevent (0.11.2)
|
56
|
+
rb-inotify (0.10.1)
|
57
|
+
ffi (~> 1.0)
|
58
|
+
reek (6.1.4)
|
59
|
+
kwalify (~> 0.7.0)
|
60
|
+
parser (~> 3.2.0)
|
61
|
+
rainbow (>= 2.0, < 4.0)
|
62
|
+
regexp_parser (2.7.0)
|
63
|
+
rexml (3.2.5)
|
64
|
+
rspec (3.12.0)
|
65
|
+
rspec-core (~> 3.12.0)
|
66
|
+
rspec-expectations (~> 3.12.0)
|
67
|
+
rspec-mocks (~> 3.12.0)
|
68
|
+
rspec-core (3.12.1)
|
69
|
+
rspec-support (~> 3.12.0)
|
70
|
+
rspec-expectations (3.12.2)
|
71
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
72
|
+
rspec-support (~> 3.12.0)
|
73
|
+
rspec-mocks (3.12.5)
|
74
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
75
|
+
rspec-support (~> 3.12.0)
|
76
|
+
rspec-support (3.12.0)
|
77
|
+
rubocop (1.49.0)
|
78
|
+
json (~> 2.3)
|
79
|
+
parallel (~> 1.10)
|
80
|
+
parser (>= 3.2.0.0)
|
81
|
+
rainbow (>= 2.2.2, < 4.0)
|
82
|
+
regexp_parser (>= 1.8, < 3.0)
|
83
|
+
rexml (>= 3.2.5, < 4.0)
|
84
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
85
|
+
ruby-progressbar (~> 1.7)
|
86
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
87
|
+
rubocop-ast (1.28.0)
|
88
|
+
parser (>= 3.2.1.0)
|
89
|
+
ruby-progressbar (1.13.0)
|
90
|
+
shellany (0.0.1)
|
91
|
+
stashify-contract (1.0.1)
|
92
|
+
rantly (~> 2.0.0)
|
93
|
+
rspec (~> 3.0)
|
94
|
+
thor (1.2.2)
|
95
|
+
unicode-display_width (2.4.2)
|
96
|
+
yard (0.9.34)
|
97
|
+
|
98
|
+
PLATFORMS
|
99
|
+
x86_64-linux
|
100
|
+
|
101
|
+
DEPENDENCIES
|
102
|
+
byebug
|
103
|
+
guard
|
104
|
+
guard-reek
|
105
|
+
guard-rspec
|
106
|
+
guard-rubocop
|
107
|
+
key-vortex!
|
108
|
+
rake (~> 13.0)
|
109
|
+
reek (~> 6.1.4)
|
110
|
+
rspec (~> 3.0)
|
111
|
+
rubocop (~> 1.21)
|
112
|
+
stashify-contract
|
113
|
+
yard
|
114
|
+
|
115
|
+
BUNDLED WITH
|
116
|
+
2.2.33
|
data/Guardfile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# A sample Guardfile
|
4
|
+
# More info at https://github.com/guard/guard#readme
|
5
|
+
|
6
|
+
## Uncomment and set this to only include directories you want to watch
|
7
|
+
# directories %w(app lib config test spec features) \
|
8
|
+
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
9
|
+
|
10
|
+
## Note: if you are using the `directories` clause above and you are not
|
11
|
+
## watching the project directory ('.'), then you will want to move
|
12
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
13
|
+
#
|
14
|
+
# $ mkdir config
|
15
|
+
# $ mv Guardfile config/
|
16
|
+
# $ ln -s config/Guardfile .
|
17
|
+
#
|
18
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
19
|
+
|
20
|
+
# NOTE: The cmd option is now required due to the increasing number of ways
|
21
|
+
# rspec may be run, below are examples of the most common uses.
|
22
|
+
# * bundler: 'bundle exec rspec'
|
23
|
+
# * bundler binstubs: 'bin/rspec'
|
24
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
25
|
+
# installed the spring binstubs per the docs)
|
26
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
27
|
+
# * 'just' rspec: 'rspec'
|
28
|
+
|
29
|
+
group :red_green_refactor, halt_on_fail: true do
|
30
|
+
guard :rspec, cmd: "bundle exec rspec", all_on_pass: true do
|
31
|
+
require "guard/rspec/dsl"
|
32
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
33
|
+
|
34
|
+
# Feel free to open issues for suggestions and improvements
|
35
|
+
|
36
|
+
# RSpec files
|
37
|
+
rspec = dsl.rspec
|
38
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
39
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
40
|
+
watch(rspec.spec_files)
|
41
|
+
|
42
|
+
# Ruby files
|
43
|
+
ruby = dsl.ruby
|
44
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
45
|
+
end
|
46
|
+
|
47
|
+
guard :rubocop, cli: "--autocorrect-all --display-cop-names" do
|
48
|
+
watch(/.+\.rb$/)
|
49
|
+
watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
|
50
|
+
end
|
51
|
+
|
52
|
+
guard "reek" do
|
53
|
+
watch(/.+\.rb$/)
|
54
|
+
watch(".reek.yml")
|
55
|
+
end
|
56
|
+
end
|
data/key-vortex.gemspec
CHANGED
@@ -9,7 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ["lambda.null.42@gmail.com"]
|
10
10
|
|
11
11
|
spec.summary = "Abstraction for interacting with various record stores"
|
12
|
-
spec.description = "Defines abstractions that can be built on top of for key/value
|
12
|
+
spec.description = "Defines abstractions that can be built on top of for key/value " \
|
13
|
+
"storage on different technologies (file, s3, sql, redis, etc.)"
|
13
14
|
spec.homepage = "https://github.com/Lambda-Null/key-vortex"
|
14
15
|
spec.license = "MIT"
|
15
16
|
spec.required_ruby_version = ">= 2.6.0"
|
@@ -33,4 +34,5 @@ Gem::Specification.new do |spec|
|
|
33
34
|
|
34
35
|
# For more information and examples about making a new gem, checkout our
|
35
36
|
# guide at: https://bundler.io/guides/creating_gem.html
|
37
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
36
38
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class KeyVortex
|
4
|
+
class Adapter
|
5
|
+
class Memory < KeyVortex::Adapter
|
6
|
+
def initialize(items)
|
7
|
+
super()
|
8
|
+
@items = items
|
9
|
+
end
|
10
|
+
|
11
|
+
def save(record)
|
12
|
+
@items[record.id] = record
|
13
|
+
end
|
14
|
+
|
15
|
+
def find(id)
|
16
|
+
@items[id]
|
17
|
+
end
|
18
|
+
|
19
|
+
def remove(key)
|
20
|
+
@items.delete(key)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class KeyVortex
|
4
|
+
class Record
|
5
|
+
def self.constraints
|
6
|
+
@constraints ||= {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.field(type, **constraints)
|
10
|
+
self.constraints[type] = constraints
|
11
|
+
end
|
12
|
+
|
13
|
+
field :id
|
14
|
+
|
15
|
+
def initialize(fields)
|
16
|
+
@fields = fields
|
17
|
+
end
|
18
|
+
|
19
|
+
def respond_to_missing?(method, *args)
|
20
|
+
args.empty? && self.class.field_constraints(method)
|
21
|
+
end
|
22
|
+
|
23
|
+
def method_missing(method, *_args)
|
24
|
+
@fields[method]
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.field_constraints(field)
|
28
|
+
@fields[field]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/key_vortex/version.rb
CHANGED
data/lib/key_vortex.rb
CHANGED
@@ -2,7 +2,19 @@
|
|
2
2
|
|
3
3
|
require_relative "key_vortex/version"
|
4
4
|
|
5
|
-
|
5
|
+
class KeyVortex
|
6
6
|
class Error < StandardError; end
|
7
|
-
|
7
|
+
|
8
|
+
def initialize(adapter, record_class)
|
9
|
+
@adapter = adapter
|
10
|
+
@record_class = record_class
|
11
|
+
end
|
12
|
+
|
13
|
+
def save(record)
|
14
|
+
@adapter.save(record)
|
15
|
+
end
|
16
|
+
|
17
|
+
def find(id)
|
18
|
+
@adapter.find(id)
|
19
|
+
end
|
8
20
|
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.1.
|
4
|
+
version: 0.1.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-
|
11
|
+
date: 2023-07-08 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.)
|
@@ -18,10 +18,13 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
+
- ".reek.yml"
|
21
22
|
- ".rspec"
|
22
23
|
- ".rubocop.yml"
|
23
24
|
- CODE_OF_CONDUCT.md
|
24
25
|
- Gemfile
|
26
|
+
- Gemfile.lock
|
27
|
+
- Guardfile
|
25
28
|
- LICENSE.txt
|
26
29
|
- README.md
|
27
30
|
- Rakefile
|
@@ -29,6 +32,8 @@ files:
|
|
29
32
|
- bin/setup
|
30
33
|
- key-vortex.gemspec
|
31
34
|
- lib/key_vortex.rb
|
35
|
+
- lib/key_vortex/adapter/memory.rb
|
36
|
+
- lib/key_vortex/record.rb
|
32
37
|
- lib/key_vortex/version.rb
|
33
38
|
- sig/record/store.rbs
|
34
39
|
homepage: https://github.com/Lambda-Null/key-vortex
|
@@ -37,6 +42,7 @@ licenses:
|
|
37
42
|
metadata:
|
38
43
|
homepage_uri: https://github.com/Lambda-Null/key-vortex
|
39
44
|
source_code_uri: https://github.com/Lambda-Null/key-vortex
|
45
|
+
rubygems_mfa_required: 'true'
|
40
46
|
post_install_message:
|
41
47
|
rdoc_options: []
|
42
48
|
require_paths:
|