basket 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/lib/basket/backend_adapter/{hash_backend.rb → memory_backend.rb} +1 -1
- data/lib/basket/backend_adapter/redis_backend.rb +7 -4
- data/lib/basket/configuration.rb +3 -3
- data/lib/basket/version.rb +1 -1
- data/lib/basket.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a3e9da361b2587c986144240ada1490a812ae9a9d0f6f639c0e38c167874ac8
|
4
|
+
data.tar.gz: 936a8d8b31d126cd35913cc1c087ecffbca722a2d5cc06747b23f26ba90d9055
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 551534c644dbb4a269f2de9de81ae43aef66f7e41dedef2e27845d4edcd17584d74067339110611628052282f5601ca9d5c39dd7962a4a71103110b9d1b37b1a
|
7
|
+
data.tar.gz: 96af7b3698edec4b70b3fa13acbb007ee17a03750c2df6583ed42df0e144bc32da8074378425ac24a655e6630070d2bcadd5b9870f2e4523804003fcdbd72fb6
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.1.0
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -32,7 +32,7 @@ while chicken.laying? do
|
|
32
32
|
end
|
33
33
|
```
|
34
34
|
|
35
|
-
The item added to the basket can be any data you want! If you are using the in memory Queue, it is fine to store Ruby objects, but if you have a different backend,
|
35
|
+
The item added to the basket can be any data you want! If you are using the in memory Queue, it is fine to store Ruby objects, but if you have a different backend, must be JSON serializable via `to_json`.
|
36
36
|
|
37
37
|
```ruby
|
38
38
|
class QuicheBasket
|
@@ -100,7 +100,7 @@ end
|
|
100
100
|
|
101
101
|
The defaults for a redis backend are the standard `"127.0.0.1"`, `6379`, `15` with a namespace of `:basket`.
|
102
102
|
|
103
|
-
The default for the backend is the
|
103
|
+
The default for the backend is the MemoryBackend, which can be set by passing `:memory` to `config.backend`, but you don't have to do that. Because it's the default!
|
104
104
|
|
105
105
|
For the redis configuration, you can alternatively pass a url, thusly:
|
106
106
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "redis-namespace"
|
2
|
+
require "json"
|
2
3
|
|
3
4
|
module Basket
|
4
5
|
class BackendAdapter
|
@@ -25,9 +26,7 @@ module Basket
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def push(queue, data)
|
28
|
-
|
29
|
-
marshalled_data = Marshal.dump(data)
|
30
|
-
@client.lpush(queue, marshalled_data)
|
29
|
+
@client.lpush(queue, serialize_data(data))
|
31
30
|
end
|
32
31
|
|
33
32
|
def length(queue)
|
@@ -44,8 +43,12 @@ module Basket
|
|
44
43
|
|
45
44
|
private
|
46
45
|
|
46
|
+
def serialize_data(data)
|
47
|
+
JSON.generate(data)
|
48
|
+
end
|
49
|
+
|
47
50
|
def deserialized_queue_data(queue)
|
48
|
-
@client.lrange(queue, 0, -1).reverse.map { |
|
51
|
+
@client.lrange(queue, 0, -1).reverse.map { |serialized_data| JSON.parse(serialized_data) }
|
49
52
|
end
|
50
53
|
|
51
54
|
def select_redis_connection
|
data/lib/basket/configuration.rb
CHANGED
@@ -7,15 +7,15 @@ module Basket
|
|
7
7
|
@redis_host = "127.0.0.1"
|
8
8
|
@redis_port = 6379
|
9
9
|
@redis_db = 15
|
10
|
-
@backend = BackendAdapter::
|
10
|
+
@backend = BackendAdapter::MemoryBackend
|
11
11
|
@namespace = :basket
|
12
12
|
@redis_url = nil
|
13
13
|
end
|
14
14
|
|
15
15
|
def backend=(backend)
|
16
16
|
case backend
|
17
|
-
when :
|
18
|
-
@backend = BackendAdapter::
|
17
|
+
when :memory
|
18
|
+
@backend = BackendAdapter::MemoryBackend
|
19
19
|
when :redis
|
20
20
|
@backend = BackendAdapter::RedisBackend
|
21
21
|
else
|
data/lib/basket/version.rb
CHANGED
data/lib/basket.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "basket/backend_adapter"
|
4
|
-
require_relative "basket/backend_adapter/
|
4
|
+
require_relative "basket/backend_adapter/memory_backend"
|
5
5
|
require_relative "basket/backend_adapter/redis_backend"
|
6
6
|
require_relative "basket/batcher"
|
7
7
|
require_relative "basket/configuration"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: basket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nichol alexander
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-04-
|
12
|
+
date: 2023-04-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
@@ -62,6 +62,7 @@ extensions: []
|
|
62
62
|
extra_rdoc_files: []
|
63
63
|
files:
|
64
64
|
- ".rspec"
|
65
|
+
- ".ruby-version"
|
65
66
|
- ".standard.yml"
|
66
67
|
- CHANGELOG.md
|
67
68
|
- CODE_OF_CONDUCT.md
|
@@ -74,7 +75,7 @@ files:
|
|
74
75
|
- basket.gemspec
|
75
76
|
- lib/basket.rb
|
76
77
|
- lib/basket/backend_adapter.rb
|
77
|
-
- lib/basket/backend_adapter/
|
78
|
+
- lib/basket/backend_adapter/memory_backend.rb
|
78
79
|
- lib/basket/backend_adapter/redis_backend.rb
|
79
80
|
- lib/basket/batcher.rb
|
80
81
|
- lib/basket/configuration.rb
|
@@ -105,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
106
|
- !ruby/object:Gem::Version
|
106
107
|
version: '0'
|
107
108
|
requirements: []
|
108
|
-
rubygems_version: 3.
|
109
|
+
rubygems_version: 3.3.3
|
109
110
|
signing_key:
|
110
111
|
specification_version: 4
|
111
112
|
summary: Wait until you have a bunch of things, then do something.
|