basket 0.0.2 → 0.0.4

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: d11f37f0087fb606bf92362eb1c913e9f089b262d130a13edfb22d639055c374
4
- data.tar.gz: b66835a0ad01af6b29b528a2e7bd481331e64b0b437586a42a504ecc27d3c1b7
3
+ metadata.gz: fe1bb079417239ff859572188cdc08c280e471752d2e5bca308e26b57d375640
4
+ data.tar.gz: f8f4cb0b630b7f07b492a4281e04302322c4661266f0da966e4b5b4dc5f1b37c
5
5
  SHA512:
6
- metadata.gz: f015621c801d42ef33fc3090d244b8a53f8a8830d7230ce73177287ba9b7ab3a7fe41129a6427c66a1119e17e0fb75e1be82bfbca0424026bdbefb0d33e94a79
7
- data.tar.gz: 4ae3e63475e3fb68e2177356d44f5a92b332b31efe43081c76f3df5824751f4ed3d203b39f3d01e227edea063466220e9ec4bd63a6cb272f8f560fbb70c31ce9
6
+ metadata.gz: 5cfa5e413c339a9f354457c7f2cf2a05edb21fecabaa63da9a6d8e51987d1e4ddef90b01235835ff330357834881836aa48dcf52edb8cc43e7d466e5f5528a6c
7
+ data.tar.gz: d880195c4f2d3ef24ed92e3ac288de53cfaca6990b1e8a8c596b0ad5fef126907b62336478edbf38c317c9f6a721bbcc5578c2a84af26047031acc25b0e5a11e
data/Gemfile CHANGED
@@ -5,13 +5,12 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in basket.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
9
-
10
- gem "rspec", "~> 3.0"
11
- gem "mocktail"
12
-
13
- gem "standard", "~> 1.3"
14
-
15
8
  gem "guard"
16
9
  gem "guard-rspec", require: false
17
10
  gem "guard-standardrb", require: false
11
+ gem "mocktail"
12
+ gem "rake", "~> 13.0"
13
+ gem "rspec", "~> 3.0"
14
+ gem "simplecov", require: false, group: :test
15
+ gem "simplecov-json", require: false, group: :test
16
+ gem "standard", "~> 1.3"
data/Gemfile.lock CHANGED
@@ -1,14 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- basket (0.0.2)
4
+ basket (0.0.3)
5
+ redis
6
+ redis-namespace
5
7
 
6
8
  GEM
7
9
  remote: https://rubygems.org/
8
10
  specs:
9
11
  ast (2.4.2)
10
12
  coderay (1.1.3)
13
+ connection_pool (2.3.0)
11
14
  diff-lcs (1.5.0)
15
+ docile (1.4.0)
12
16
  ffi (1.15.5)
13
17
  formatador (1.1.0)
14
18
  guard (2.18.0)
@@ -36,6 +40,8 @@ GEM
36
40
  rb-inotify (~> 0.9, >= 0.9.10)
37
41
  lumberjack (1.2.8)
38
42
  method_source (1.0.0)
43
+ mock_redis (0.36.0)
44
+ ruby2_keywords
39
45
  mocktail (1.2.2)
40
46
  nenv (0.3.0)
41
47
  notiffany (0.1.3)
@@ -52,6 +58,12 @@ GEM
52
58
  rb-fsevent (0.11.2)
53
59
  rb-inotify (0.10.1)
54
60
  ffi (~> 1.0)
61
+ redis (5.0.6)
62
+ redis-client (>= 0.9.0)
63
+ redis-client (0.14.0)
64
+ connection_pool
65
+ redis-namespace (1.10.0)
66
+ redis (>= 4)
55
67
  regexp_parser (2.7.0)
56
68
  rexml (3.2.5)
57
69
  rspec (3.12.0)
@@ -83,7 +95,17 @@ GEM
83
95
  rubocop (>= 1.7.0, < 2.0)
84
96
  rubocop-ast (>= 0.4.0)
85
97
  ruby-progressbar (1.11.0)
98
+ ruby2_keywords (0.0.5)
86
99
  shellany (0.0.1)
100
+ simplecov (0.22.0)
101
+ docile (~> 1.1)
102
+ simplecov-html (~> 0.11)
103
+ simplecov_json_formatter (~> 0.1)
104
+ simplecov-html (0.12.3)
105
+ simplecov-json (0.2.3)
106
+ json
107
+ simplecov
108
+ simplecov_json_formatter (0.1.4)
87
109
  standard (1.24.3)
88
110
  language_server-protocol (~> 3.17.0.2)
89
111
  rubocop (= 1.44.1)
@@ -104,9 +126,12 @@ DEPENDENCIES
104
126
  guard
105
127
  guard-rspec
106
128
  guard-standardrb
129
+ mock_redis
107
130
  mocktail
108
131
  rake (~> 13.0)
109
132
  rspec (~> 3.0)
133
+ simplecov
134
+ simplecov-json
110
135
  standard (~> 1.3)
111
136
 
112
137
  BUNDLED WITH
data/Guardfile CHANGED
@@ -15,7 +15,7 @@
15
15
  #
16
16
  # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
17
 
18
- # Note: The cmd option is now required due to the increasing number of ways
18
+ # NOTE: The cmd option is now required due to the increasing number of ways
19
19
  # rspec may be run, below are examples of the most common uses.
20
20
  # * bundler: 'bundle exec rspec'
21
21
  # * bundler binstubs: 'bin/rspec'
@@ -25,10 +25,10 @@
25
25
  # * 'just' rspec: 'rspec'
26
26
 
27
27
  group "specs", halt_on_fail: true do
28
- guard :rspec, all_on_start: false, cmd: "rspec" do
28
+ guard :rspec, all_on_start: true, all_after_pass: true, cmd: "rspec" do
29
29
  watch(%r{^spec/.+_spec\.rb$})
30
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
31
- watch("spec/spec_helper.rb") { "spec/lib" }
30
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
31
+ watch("spec/spec_helper.rb") { "spec/" }
32
32
  end
33
33
 
34
34
  guard :standardrb, fix: true, all_on_start: true, progress: true do
data/README.md CHANGED
@@ -1,4 +1,8 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/basket.svg)](https://badge.fury.io/rb/basket)
2
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
3
+ [![Tests](https://github.com/nicholalexander/basket/actions/workflows/main.yml/badge.svg)](https://github.com/nicholalexander/basket/actions/workflows/main.yml)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/dab6a6e193cbd9df2b3e/maintainability)](https://codeclimate.com/github/nicholalexander/basket/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/dab6a6e193cbd9df2b3e/test_coverage)](https://codeclimate.com/github/nicholalexander/basket/test_coverage)
2
6
  # Basket
3
7
 
4
8
  A farmer doesn't walk down to the chicken coop, grab an egg, go back to the kitchen, go back to the coop, go back to the kitchen ad infinitum. They take a basket with them, and as the chickens lay their eggs, they fill up the basket and when the basket is full they go make something with them! I would make a quiche, but that's besides the case.
@@ -22,7 +26,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
22
26
  Add items to your basket as they come along. They might come along quickly, or there might be a delay between them. Regardless, you want to collect items into your basket before going and doing something with them.
23
27
 
24
28
  ```ruby
25
- while chicken.laying do
29
+ while chicken.laying? do
26
30
  egg = { egg: {color: brown, size: medium}}
27
31
  Basket.add('QuicheBasket', egg)
28
32
  end
@@ -51,7 +55,7 @@ class QuicheBasket
51
55
  BrunchInviteJob.perform_async
52
56
  end
53
57
 
54
- # There are four callbacks to the lifecycle of a basket.
58
+ # There are three callbacks to the lifecycle of a basket.
55
59
  # :on_add, :on_success, and :on_failure.
56
60
  # They can be used like this:
57
61
  def on_success
@@ -80,6 +84,32 @@ The `on_failure` use of `batch` of course may not have a full batch as the error
80
84
 
81
85
  Defining `on_add`, `on_failure`, and `on_success` is optional.
82
86
 
87
+ ## Configuration
88
+
89
+ In an initializer, or somewhere equally appropriate, you might put something like this:
90
+
91
+ ```ruby
92
+ Basket.configure do |config|
93
+ config.redis_host = "127.0.0.2"
94
+ config.redis_port = 6390
95
+ config.redis_db = 10
96
+ config.backend = :redis
97
+ config.namespace = :basket
98
+ end
99
+ ```
100
+
101
+ The defaults for a redis backend are the standard `"127.0.0.1"`, `6379`, `15` with a namespace of `:basket`.
102
+
103
+ The default for the backend is the HashBackend, which can be set by passing `:hash` to `config.backend`, but you don't have to do that. Because it's the default!
104
+
105
+ For the redis configuration, you can alternatively pass a url, thusly:
106
+
107
+ ```ruby
108
+ Basket.configure do |config|
109
+ config.backend = :redis
110
+ config.redis_url = "redis://:p4ssw0rd@10.0.1.1:6380/15"
111
+ end
112
+ ```
83
113
  ## Development
84
114
 
85
115
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -88,9 +118,11 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
88
118
 
89
119
  This project uses Guard to facilitate local development. You can run it with `bundle exec guard`. It will run specs on change to files and will run `standard --fix` after passing tests.
90
120
 
121
+ Looking through the code base, the majority of the work happens in [lib/basket/handle_add.rb](https://github.com/nicholalexander/basket/blob/main/lib/basket/handle_add.rb). Alternatively, you might be interested in the [backend adapters](https://github.com/nicholalexander/basket/tree/main/lib/basket/backend_adapter) for how the gem works with in memory hashes and/or a redis backend.
122
+
91
123
  ## Contributing
92
124
 
93
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/basket. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/basket/blob/main/CODE_OF_CONDUCT.md).
125
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nicholalexander/basket. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/nicholalexander/basket/blob/main/CODE_OF_CONDUCT.md).
94
126
 
95
127
  ## License
96
128
 
@@ -98,7 +130,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
98
130
 
99
131
  ## Code of Conduct
100
132
 
101
- Everyone interacting in the Basket project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/basket/blob/main/CODE_OF_CONDUCT.md).
133
+ Everyone interacting in the Basket project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/nicholalexander/basket/blob/main/CODE_OF_CONDUCT.md).
102
134
 
103
135
 
104
136
 
data/basket.gemspec ADDED
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/basket/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "basket"
7
+ spec.version = Basket::VERSION
8
+ spec.authors = ["nichol alexander", "alec clarke"]
9
+ spec.email = ["nichol.alexander@gmail.com", "alec.clarke.dev@gmail.com"]
10
+
11
+ spec.summary = "Wait until you have a bunch of things, then do something."
12
+ spec.description = "A simple way of accumulating things and then acting on them."
13
+ spec.homepage = "https://github.com/nicholalexander/basket"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.0.6"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/nicholalexander/basket"
19
+ spec.metadata["changelog_uri"] = "https://github.com/nicholalexander/basket/blob/main/CHANGELOG.md"
20
+
21
+ spec.files = Dir.chdir(__dir__) do
22
+ `git ls-files -z`.split("\x0").reject do |f|
23
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
24
+ end
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "redis"
31
+ spec.add_dependency "redis-namespace"
32
+
33
+ spec.add_development_dependency "mock_redis"
34
+ end
@@ -0,0 +1,30 @@
1
+ module Basket
2
+ class BackendAdapter
3
+ class HashBackend < Basket::BackendAdapter
4
+ def initialize
5
+ @data = {}
6
+ end
7
+
8
+ attr_reader :data
9
+
10
+ def push(queue, data)
11
+ @data[queue] = [] if @data[queue].nil?
12
+ @data[queue] <<= data
13
+ end
14
+
15
+ def length(queue)
16
+ return 0 if @data[queue].nil?
17
+
18
+ @data[queue].length
19
+ end
20
+
21
+ def read(queue)
22
+ @data[queue]
23
+ end
24
+
25
+ def clear(queue)
26
+ @data[queue] = []
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,74 @@
1
+ require "redis-namespace"
2
+
3
+ module Basket
4
+ class BackendAdapter
5
+ class RedisBackend < Basket::BackendAdapter
6
+ attr_reader :client
7
+
8
+ def initialize
9
+ redis_connection = select_redis_connection
10
+
11
+ @client = Redis::Namespace.new(
12
+ Basket.config.namespace,
13
+ redis: redis_connection
14
+ )
15
+ end
16
+
17
+ def data
18
+ response = {}
19
+
20
+ @client.scan_each do |queue|
21
+ response[queue] = deserialized_queue_data(queue)
22
+ end
23
+
24
+ response
25
+ end
26
+
27
+ def push(queue, data)
28
+ # TODO: should we use JSON vs Marshal?
29
+ marshalled_data = Marshal.dump(data)
30
+ @client.lpush(queue, marshalled_data)
31
+ end
32
+
33
+ def length(queue)
34
+ @client.llen(queue)
35
+ end
36
+
37
+ def clear(queue)
38
+ @client.del(queue)
39
+ end
40
+
41
+ def read(queue)
42
+ deserialized_queue_data(queue)
43
+ end
44
+
45
+ private
46
+
47
+ def deserialized_queue_data(queue)
48
+ @client.lrange(queue, 0, -1).reverse.map { |marshalled_data| Marshal.load(marshalled_data) }
49
+ end
50
+
51
+ def select_redis_connection
52
+ if Basket.config.redis_url
53
+ redis_connection_from_url
54
+ else
55
+ redis_connection_from_host
56
+ end
57
+ end
58
+
59
+ def redis_connection_from_host
60
+ Redis.new(
61
+ host: Basket.config.redis_host,
62
+ port: Basket.config.redis_port,
63
+ db: Basket.config.redis_db
64
+ )
65
+ end
66
+
67
+ def redis_connection_from_url
68
+ Redis.new(
69
+ url: Basket.config.redis_url
70
+ )
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,23 @@
1
+ module Basket
2
+ class BackendAdapter
3
+ def data
4
+ raise "must implement data"
5
+ end
6
+
7
+ def push(queue, data)
8
+ raise "must implement push with queue and data params"
9
+ end
10
+
11
+ def length(queue)
12
+ raise "must implement length with queue param"
13
+ end
14
+
15
+ def read(queue)
16
+ raise "must implement read with queue param"
17
+ end
18
+
19
+ def clear(queue)
20
+ raise "must implement clear with queue param"
21
+ end
22
+ end
23
+ end
@@ -1,4 +1,3 @@
1
- require_relative "./error"
2
1
  module Basket
3
2
  module Batcher
4
3
  def self.included(base)
@@ -13,12 +12,13 @@ module Basket
13
12
  def basket_options_hash
14
13
  raise Basket::Error, "You must specify the size of your basket!" if @basket_options.nil?
15
14
  raise Basket::Error, "You must specify a size greater than 0" if @basket_options[:size] <= 0
15
+
16
16
  @basket_options
17
17
  end
18
18
  end
19
19
 
20
20
  def batch
21
- @batch ||= Basket.config.queue_collection.pop_all(self.class.name)
21
+ @batch ||= Basket.queue_collection.read(self.class.name)
22
22
  end
23
23
 
24
24
  def perform
@@ -1,7 +1,26 @@
1
1
  module Basket
2
2
  class Configuration
3
- def queue_collection
4
- @queue_collection ||= Basket::QueueCollection.new
3
+ attr_accessor :redis_host, :redis_port, :redis_db, :namespace, :redis_url
4
+ attr_reader :backend
5
+
6
+ def initialize
7
+ @redis_host = "127.0.0.1"
8
+ @redis_port = 6379
9
+ @redis_db = 15
10
+ @backend = BackendAdapter::HashBackend
11
+ @namespace = :basket
12
+ @redis_url = nil
13
+ end
14
+
15
+ def backend=(backend)
16
+ case backend
17
+ when :hash
18
+ @backend = BackendAdapter::HashBackend
19
+ when :redis
20
+ @backend = BackendAdapter::RedisBackend
21
+ else
22
+ raise Basket::Error, "Unknown Backend"
23
+ end
5
24
  end
6
25
  end
7
26
  end
data/lib/basket/error.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Basket
2
- class Error < StandardError
3
- end
2
+ class Error < StandardError; end
3
+
4
+ class BasketNotFoundError < Error; end
4
5
  end
@@ -0,0 +1,64 @@
1
+ module Basket
2
+ class HandleAdd
3
+ def self.call(queue, data)
4
+ new(queue, data).call
5
+ end
6
+
7
+ def initialize(queue, data)
8
+ @queue = queue
9
+ @data = data
10
+ end
11
+
12
+ def call
13
+ setup_batchers
14
+ add_to_basket
15
+ perform if basket_full?(@queue_length, @queue_class)
16
+ rescue => error
17
+ maybe_raise_basket_error(error)
18
+ failure(error)
19
+ end
20
+
21
+ private
22
+
23
+ def setup_batchers
24
+ @queue_collection = Basket.queue_collection
25
+ @queue_class = class_for_queue
26
+ @queue_instance = @queue_class.new
27
+ end
28
+
29
+ def add_to_basket(data = @data)
30
+ @queue_length = @queue_collection.push(@queue, data)
31
+ @queue_instance.define_singleton_method(:element) { data }
32
+ @queue_instance.on_add
33
+ end
34
+
35
+ def perform
36
+ @queue_instance.perform
37
+ @queue_instance.on_success
38
+ @queue_collection.clear(@queue)
39
+ end
40
+
41
+ def failure(error)
42
+ @queue_instance.define_singleton_method(:error) { error }
43
+ @queue_instance.on_failure
44
+ end
45
+
46
+ def class_for_queue
47
+ raise_basket_not_found unless Object.const_defined?(@queue)
48
+ Object.const_get(@queue)
49
+ end
50
+
51
+ def raise_basket_not_found
52
+ raise Basket::BasketNotFoundError, "We couldn't find that basket anywhere, please make sure it is defined."
53
+ end
54
+
55
+ def basket_full?(queue_length, queue_class)
56
+ queue_length == queue_class.basket_options_hash[:size]
57
+ end
58
+
59
+ def maybe_raise_basket_error(e)
60
+ raise e if e.instance_of?(Basket::Error)
61
+ raise e if e.instance_of?(Basket::BasketNotFoundError)
62
+ end
63
+ end
64
+ end
@@ -1,7 +1,7 @@
1
1
  module Basket
2
2
  class QueueCollection
3
- def initialize(backend = HashBackend.new)
4
- @backend = backend
3
+ def initialize(backend = Basket.config.backend)
4
+ @backend = backend.new
5
5
  end
6
6
 
7
7
  def push(queue, data)
@@ -13,8 +13,12 @@ module Basket
13
13
  @backend.length(queue)
14
14
  end
15
15
 
16
- def pop_all(queue)
17
- @backend.pop_all(queue)
16
+ def read(queue)
17
+ @backend.read(queue)
18
+ end
19
+
20
+ def clear(queue)
21
+ @backend.clear(queue)
18
22
  end
19
23
 
20
24
  def data
@@ -22,7 +26,7 @@ module Basket
22
26
  end
23
27
 
24
28
  def reset_backend
25
- @backend = HashBackend.new
29
+ @backend = Basket.config.backend.new
26
30
  end
27
31
  end
28
32
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Basket
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.4"
5
5
  end
data/lib/basket.rb CHANGED
@@ -1,9 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "basket/backend_adapter"
4
+ require_relative "basket/backend_adapter/hash_backend"
5
+ require_relative "basket/backend_adapter/redis_backend"
3
6
  require_relative "basket/batcher"
4
7
  require_relative "basket/configuration"
5
8
  require_relative "basket/error"
6
- require_relative "basket/hash_backend"
9
+ require_relative "basket/handle_add"
7
10
  require_relative "basket/queue_collection"
8
11
  require_relative "basket/version"
9
12
 
@@ -14,30 +17,23 @@ module Basket
14
17
  @config ||= Configuration.new
15
18
  end
16
19
 
20
+ def self.configure
21
+ yield(config)
22
+ end
23
+
17
24
  def self.contents
18
25
  @queue_collection.data
19
26
  end
20
27
 
28
+ def self.queue_collection
29
+ @queue_collection ||= Basket::QueueCollection.new
30
+ end
31
+
21
32
  def self.add(queue, data)
22
- @queue_collection = config.queue_collection
23
- queue_length = @queue_collection.push(queue, data)
24
- queue_class = Object.const_get(queue)
25
- queue_instance = queue_class.new
26
-
27
- queue_instance.define_singleton_method(:element) { data }
28
- queue_instance.on_add
29
-
30
- return unless queue_length == queue_class.basket_options_hash[:size]
31
-
32
- queue_instance.perform
33
- queue_instance.on_success
34
- rescue => e
35
- raise e if e.instance_of?(Basket::Error)
36
- queue_instance.define_singleton_method(:error) { e }
37
- queue_instance.on_failure
33
+ HandleAdd.call(queue, data)
38
34
  end
39
35
 
40
36
  def self.clear_all
41
- config.queue_collection.reset_backend
37
+ queue_collection.reset_backend
42
38
  end
43
39
  end
metadata CHANGED
@@ -1,18 +1,62 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: basket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - nichol alexander
8
+ - alec clarke
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2023-03-05 00:00:00.000000000 Z
12
- dependencies: []
13
- description: This is a longer description.
12
+ date: 2023-04-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: redis
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: redis-namespace
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: mock_redis
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ description: A simple way of accumulating things and then acting on them.
14
57
  email:
15
- - 'nichol.alexander@gmail.com '
58
+ - nichol.alexander@gmail.com
59
+ - alec.clarke.dev@gmail.com
16
60
  executables: []
17
61
  extensions: []
18
62
  extra_rdoc_files: []
@@ -27,11 +71,15 @@ files:
27
71
  - LICENSE.txt
28
72
  - README.md
29
73
  - Rakefile
74
+ - basket.gemspec
30
75
  - lib/basket.rb
76
+ - lib/basket/backend_adapter.rb
77
+ - lib/basket/backend_adapter/hash_backend.rb
78
+ - lib/basket/backend_adapter/redis_backend.rb
31
79
  - lib/basket/batcher.rb
32
80
  - lib/basket/configuration.rb
33
81
  - lib/basket/error.rb
34
- - lib/basket/hash_backend.rb
82
+ - lib/basket/handle_add.rb
35
83
  - lib/basket/queue_collection.rb
36
84
  - lib/basket/version.rb
37
85
  - sig/basket.rbs
@@ -50,14 +98,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
50
98
  requirements:
51
99
  - - ">="
52
100
  - !ruby/object:Gem::Version
53
- version: 2.6.0
101
+ version: 3.0.6
54
102
  required_rubygems_version: !ruby/object:Gem::Requirement
55
103
  requirements:
56
104
  - - ">="
57
105
  - !ruby/object:Gem::Version
58
106
  version: '0'
59
107
  requirements: []
60
- rubygems_version: 3.3.24
108
+ rubygems_version: 3.4.7
61
109
  signing_key:
62
110
  specification_version: 4
63
111
  summary: Wait until you have a bunch of things, then do something.
@@ -1,24 +0,0 @@
1
- module Basket
2
- class HashBackend
3
- attr_reader :data
4
-
5
- def initialize
6
- @data = {}
7
- end
8
-
9
- def push(queue, data)
10
- @data[queue] = [] if @data[queue].nil?
11
- @data[queue] <<= data
12
- end
13
-
14
- def length(queue)
15
- return 0 if @data[queue].nil?
16
-
17
- @data[queue].length
18
- end
19
-
20
- def pop_all(queue)
21
- @data.delete(queue)
22
- end
23
- end
24
- end