totoro 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 054f471cccf811b3c8541b3e0b12ef9939171747d50057012b883ccb5e8cd660
4
- data.tar.gz: 17454620d69e705661b1827485826be4d764c4bdee92a5cb841cf61ebc20591c
3
+ metadata.gz: 3b1f49dd68bdc18d9fa1d15f53d3b2e1948305f1d7e371b11d4ff73bd1222124
4
+ data.tar.gz: a463608787db8e13d02ec08d015e3cba657bc12e74eae7beb2fd293d6b56c40b
5
5
  SHA512:
6
- metadata.gz: 7879ada1b51de17ff076392033b14fbe3ddfa0932f9bed680e5fcf64d02c0267745e93f29ad06faf8e929e0770a67b6f275568aad5bb83f09e9cbb2dcab6aec4
7
- data.tar.gz: 382b7d954a98576b4efdc1f1ba0b4e56dcb24c2bed80cf580924e0494305f493d6896f183dd174251eeacd48da69a12ad27f80b250ac61f4066e0881e103da01
6
+ metadata.gz: f501160e0fbc222a82195dabcea85f44c97d2ea82acc4a24bbe3bdae73d97e562982d1c4da938a43dd9b0a28ded4d690958b571d88cbad507f70d7458d60cdea
7
+ data.tar.gz: 5b7107a0aca94d895e21af9d0c627c0c9210ac127c0c1dbf78991b586635c58cc7ec98100a10770b501e1ed319731b98e1e2ff291554251b70b9384a591da0a2
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Totoro
4
4
  class ConfigGenerator < Rails::Generators::Base
5
- source_root File.expand_path('../templates', __FILE__)
5
+ source_root File.expand_path('templates', __dir__)
6
6
  desc 'Generate totoro config file'
7
7
 
8
8
  def copy_config_file
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Totoro
4
4
  class InitGenerator < Rails::Generators::Base
5
- source_root File.expand_path('../templates', __FILE__)
5
+ source_root File.expand_path('templates', __dir__)
6
6
  desc 'Generate totoro config file'
7
7
 
8
8
  def copy_config_file
@@ -2,15 +2,9 @@
2
2
 
3
3
  module Worker
4
4
  class <%= name.camelcase %> < Totoro::BaseWorker
5
+ setup queue_name: '<%= queue || name.underscore %>'<% if prefix.present? %> ,prefix: :<%= prefix %><% end %>
5
6
  def process(payload, metadata, delivery_info)
6
7
  # worker process
7
8
  end
8
-
9
- private
10
-
11
- def setup<% if prefix.present? %>
12
- @prefix = :<%= prefix %><% end %>
13
- @queue_name = '<%= queue || name.underscore %>'
14
- end
15
9
  end
16
10
  end
@@ -4,7 +4,7 @@ module Totoro
4
4
  class WorkerGenerator < Rails::Generators::Base
5
5
  desc 'Generate totoro worker file'
6
6
 
7
- source_root File.expand_path('../templates', __FILE__)
7
+ source_root File.expand_path('templates', __dir__)
8
8
  argument :name, type: :string
9
9
  argument :queue, type: :string, required: false
10
10
  argument :prefix, type: :string, required: false
@@ -18,7 +18,7 @@ module Totoro
18
18
  end
19
19
 
20
20
  def exchange
21
- @exchanges ||= channel.default_exchange
21
+ @exchange ||= channel.default_exchange
22
22
  end
23
23
 
24
24
  # enqueue = publish to direct exchange
@@ -2,8 +2,17 @@
2
2
 
3
3
  module Totoro
4
4
  class BaseWorker
5
+ def self.setup(attrs)
6
+ prefix = attrs[:prefix].present? ? attrs[:prefix] : :default
7
+ queue_name = attrs[:queue_name]
8
+ define_method('setup') do
9
+ raise(Totoro::NeedQueueNameError) if queue_name.nil?
10
+ @prefix = prefix
11
+ @queue_name = queue_name
12
+ end
13
+ end
14
+
5
15
  def initialize
6
- @prefix = :default
7
16
  Rails.logger = @logger = Logger.new STDOUT
8
17
  @logger.level = Logger.const_get(
9
18
  Rails.configuration.log_level.to_s.upcase
@@ -26,10 +35,6 @@ module Totoro
26
35
 
27
36
  private
28
37
 
29
- def setup
30
- raise(Totoro::NeedQueueNameError, 'Need setup @queue_name')
31
- end
32
-
33
38
  def queue_class
34
39
  if @prefix == :default
35
40
  Totoro::Queue
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Totoro
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
Binary file
data/totoro.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  # frozen_string_literal: true
3
3
 
4
- lib = File.expand_path('../lib', __FILE__)
4
+ lib = File.expand_path('lib', __dir__)
5
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
6
  require 'totoro/version'
7
7
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: totoro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ShuHui18
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-16 00:00:00.000000000 Z
11
+ date: 2018-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
@@ -103,6 +103,7 @@ files:
103
103
  - pkg/totoro-0.1.4.gem
104
104
  - pkg/totoro-0.1.5.gem
105
105
  - pkg/totoro-0.1.6.gem
106
+ - pkg/totoro-0.2.0.gem
106
107
  - spec/spec_helper.rb
107
108
  - spec/totoro_spec.rb
108
109
  - test/totoro_test/Gemfile