basket 0.0.2 → 0.0.3

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: '092352c400ad4483af38e9afe1060a39c6162c7318e4c69fb1ecd7649af56344'
4
+ data.tar.gz: 9a6cb3e5937d7367b6e83bae58e796c71c7a2a7b77cec5bbbbd5178bf4e0107b
5
5
  SHA512:
6
- metadata.gz: f015621c801d42ef33fc3090d244b8a53f8a8830d7230ce73177287ba9b7ab3a7fe41129a6427c66a1119e17e0fb75e1be82bfbca0424026bdbefb0d33e94a79
7
- data.tar.gz: 4ae3e63475e3fb68e2177356d44f5a92b332b31efe43081c76f3df5824751f4ed3d203b39f3d01e227edea063466220e9ec4bd63a6cb272f8f560fbb70c31ce9
6
+ metadata.gz: a0f510f3e3f9c7b7accff0b76580d426e939d82212d6a4d83979f3043e4d679c8fafe994e58f788cf920110f3094e45cac1e290b50c802a22a5937358cdabd86
7
+ data.tar.gz: 33798eb722f92da71a396bac9529676f34cde316cdf3824fe5c42e66cfca26444caedb615fdcbad4ff67374a0a60dd646daf93eb349e0ee4d880f22b2186b2be
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
@@ -2,13 +2,17 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  basket (0.0.2)
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.
@@ -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,24 @@ 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.config 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
+
83
105
  ## Development
84
106
 
85
107
  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.
@@ -90,7 +112,7 @@ This project uses Guard to facilitate local development. You can run it with `b
90
112
 
91
113
  ## Contributing
92
114
 
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).
115
+ 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
116
 
95
117
  ## License
96
118
 
@@ -98,7 +120,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
98
120
 
99
121
  ## Code of Conduct
100
122
 
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).
123
+ 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
124
 
103
125
 
104
126
 
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 = ">= 2.6.0"
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,56 @@
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 = Redis.new(
10
+ host: Basket.config.redis_host,
11
+ port: Basket.config.redis_port,
12
+ db: Basket.config.redis_db
13
+ )
14
+
15
+ @client = Redis::Namespace.new(
16
+ Basket.config.namespace,
17
+ redis: redis_connection
18
+ )
19
+ end
20
+
21
+ def data
22
+ response = {}
23
+
24
+ @client.scan_each do |queue|
25
+ response[queue] = deserialized_queue_data(queue)
26
+ end
27
+
28
+ response
29
+ end
30
+
31
+ def push(queue, data)
32
+ # TODO: should we use JSON vs Marshal?
33
+ marshalled_data = Marshal.dump(data)
34
+ @client.lpush(queue, marshalled_data)
35
+ end
36
+
37
+ def length(queue)
38
+ @client.llen(queue)
39
+ end
40
+
41
+ def clear(queue)
42
+ @client.del(queue)
43
+ end
44
+
45
+ def read(queue)
46
+ deserialized_queue_data(queue)
47
+ end
48
+
49
+ private
50
+
51
+ def deserialized_queue_data(queue)
52
+ @client.lrange(queue, 0, -1).reverse.map { |marshalled_data| Marshal.load(marshalled_data) }
53
+ end
54
+ end
55
+ end
56
+ 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,25 @@
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
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
+ end
13
+
14
+ def backend=(backend)
15
+ case backend
16
+ when :hash
17
+ @backend = BackendAdapter::HashBackend
18
+ when :redis
19
+ @backend = BackendAdapter::RedisBackend
20
+ else
21
+ raise Basket::Error, "Unknown Backend"
22
+ end
5
23
  end
6
24
  end
7
25
  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,49 @@
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
+ @queue_collection = Basket.queue_collection
11
+ end
12
+
13
+ def call(data = @data)
14
+ queue_length = @queue_collection.push(@queue, data)
15
+ queue_class = class_for_queue
16
+ queue_instance = queue_class.new
17
+
18
+ queue_instance.define_singleton_method(:element) { data }
19
+ queue_instance.on_add
20
+
21
+ return unless basket_full?(queue_length, queue_class)
22
+
23
+ queue_instance.perform
24
+ queue_instance.on_success
25
+ @queue_collection.clear(@queue)
26
+ rescue => e
27
+ raise e if basket_error?(e)
28
+
29
+ queue_instance.define_singleton_method(:error) { e }
30
+ queue_instance.on_failure
31
+ end
32
+
33
+ private
34
+
35
+ def class_for_queue
36
+ Object.const_get(@queue)
37
+ rescue NameError => e
38
+ raise Basket::BasketNotFoundError, "We couldn't find that basket anywhere, please make sure it is defined. | #{e.message}"
39
+ end
40
+
41
+ def basket_full?(queue_length, queue_class)
42
+ queue_length == queue_class.basket_options_hash[:size]
43
+ end
44
+
45
+ def basket_error?(e)
46
+ e.instance_of?(Basket::Error) || e.instance_of?(Basket::BasketNotFoundError)
47
+ end
48
+ end
49
+ 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.3"
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.3
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-03-26 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
@@ -57,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
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