geode 0.2.0 → 0.3.0
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/lib/geode/redis.rb +7 -3
- data/lib/geode/sequel.rb +9 -3
- data/lib/geode.rb +4 -4
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c1357dd8aadd830b705e45dcee476fdd473222574269373691ff6f91964da95
|
4
|
+
data.tar.gz: 1cc2d1a5129a238c25d89dc75a33c9edacdc79b45d9f7768ffc5912c4068e97d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 982b9ab60e0e287bdc79b431074ac3a65afffe306d49e79d99add358a3401babc36ba2a77dca01d92b0f46f1f72c2ce052d3eb52d4fec1a147c7ce70f966e4dc
|
7
|
+
data.tar.gz: 33237585799704b24e0634335d5a84a9cc75ec95340b7d24be6b1befe5a671f27884a82cbfb3099ed1a5a3d5218b3b3f127ae4aea52ec0127d0f8b9c1af7fa34
|
data/lib/geode/redis.rb
CHANGED
@@ -5,10 +5,14 @@ require_relative '../geode'
|
|
5
5
|
module Geode
|
6
6
|
# A store implemented using Redis.
|
7
7
|
class RedisStore < Store
|
8
|
-
|
8
|
+
# Connect to a store held in Redis.
|
9
|
+
# @param name [Symbol, String] The name of the store
|
10
|
+
# @param connection [Hash, String] Connection parameters passed to `Redis.new`.
|
11
|
+
# Defaults to empty hash
|
12
|
+
def initialize(name, connection = nil)
|
9
13
|
super
|
10
|
-
|
11
|
-
@redis = Redis.new
|
14
|
+
connection ||= {}
|
15
|
+
@redis = Redis.new(connection)
|
12
16
|
end
|
13
17
|
|
14
18
|
def open
|
data/lib/geode/sequel.rb
CHANGED
@@ -3,14 +3,20 @@ require 'sequel'
|
|
3
3
|
require_relative '../geode'
|
4
4
|
|
5
5
|
module Geode
|
6
|
-
#
|
6
|
+
# A store that uses a relational database supported by Sequel instead of Redis.
|
7
7
|
# This is mainly useful for Heroku, where persistent Postgres is free, but
|
8
8
|
# the same is not true of Redis.
|
9
|
-
# Unless you have a similarly good reason to use this class, use RedisStore instead.
|
9
|
+
# Unless you have a similarly good reason to use this class, use `RedisStore` instead.
|
10
10
|
class SequelStore < Store
|
11
|
-
|
11
|
+
# Connect to a store held in a relational database supported by Sequel.
|
12
|
+
# A table named `geode` will be created and used to store the data.
|
13
|
+
# @param name [Symbol, String] The name of the store
|
14
|
+
# @param connection [Hash, String] Connection parameters passed to `Sequel.connect`.
|
15
|
+
# Defaults to `{ adapter: 'postgres' }`
|
16
|
+
def initialize(name, connection = nil)
|
12
17
|
super
|
13
18
|
|
19
|
+
connection ||= { adapter: 'postgres' }
|
14
20
|
db = Sequel.connect(connection)
|
15
21
|
db.create_table? :geode do
|
16
22
|
primary_key :id
|
data/lib/geode.rb
CHANGED
@@ -3,15 +3,15 @@ module Geode
|
|
3
3
|
class Store
|
4
4
|
# Connect to a store.
|
5
5
|
# @param name [Symbol, String] The name of the store
|
6
|
-
# @param connection [Hash, String]
|
7
|
-
def initialize(name, connection)
|
6
|
+
# @param connection [Hash, String] Connection parameters passed to the DB client
|
7
|
+
def initialize(name, connection = nil)
|
8
8
|
@name = name.to_s
|
9
9
|
end
|
10
10
|
|
11
11
|
# "Open" the store for reading and/or writing.
|
12
|
-
# @yield a block
|
12
|
+
# @yield a block which receives `table` as its sole parameter
|
13
13
|
# @yieldparam table [Hash] The table belonging to `@name`
|
14
|
-
# @return [Object] The
|
14
|
+
# @return [Object] The return value of the block
|
15
15
|
def open
|
16
16
|
raise NotImplementedError
|
17
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- biqqles
|
@@ -53,8 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.0'
|
55
55
|
description:
|
56
|
-
email:
|
57
|
-
- biqqles@protonmail.com
|
56
|
+
email: biqqles@protonmail.com
|
58
57
|
executables: []
|
59
58
|
extensions: []
|
60
59
|
extra_rdoc_files: []
|
@@ -87,5 +86,5 @@ requirements: []
|
|
87
86
|
rubygems_version: 3.1.2
|
88
87
|
signing_key:
|
89
88
|
specification_version: 4
|
90
|
-
summary: Elegantly store Ruby objects in Redis or
|
89
|
+
summary: Elegantly store Ruby objects in Redis or Sequel
|
91
90
|
test_files: []
|