sidekiq-client-cli 0.1.2 → 0.1.3
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 +8 -8
- data/README.md +4 -0
- data/lib/sidekiq_client_cli.rb +6 -8
- data/lib/sidekiq_client_cli/version.rb +1 -1
- data/sidekiq-client-cli.gemspec +1 -1
- data/spec/sidekiq_client_cli_spec.rb +15 -13
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTgyYzgzOGEyYzEwMGJhM2FiNGNjZDE0NDFmN2U4ZjQ2YTIzMGUxYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTdiZDI4YTNkYTZlM2Y4ZWJjOTM1MzU4ZDg1MWQyMzNmNTQyODQ5NA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWVkODk5YzcwMDE2Y2Y0NTY4NmY4Mjc3NmRmMDBmNDk5ZDBhYTBmNjVlMDZh
|
10
|
+
MGUzNGRlOGU1YTIyYzdhYmM2YzhkYzExNWE0ZGE2ZGMyZGI5ZTJkYWYxMWY0
|
11
|
+
MWMwZDJkMmMyZDEyYzRiN2U5MWIwOWJjMzNjYWE0NDhkNjFiMGU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzdmMDU3Y2YyMTE0N2U0NTZmMTVkMGM2Y2MzYjAwYjY2MmNkYjVhY2QzOTM4
|
14
|
+
NTAzNmQ0ZWE0NWQxMzI3N2NiMTRkNzZmYTE4ZjZiM2I3Y2I5OTk5NjEwMTQ2
|
15
|
+
NDk2NzFjOWY3MzE1MGMxNzM2ZGU1ZWIzZjQ1ZmMxZjM5ZmUzODk=
|
data/README.md
CHANGED
data/lib/sidekiq_client_cli.rb
CHANGED
@@ -5,18 +5,13 @@ require_relative 'sidekiq_client_cli/version'
|
|
5
5
|
class SidekiqClientCLI
|
6
6
|
COMMANDS = %w{push}
|
7
7
|
DEFAULT_CONFIG_PATH = "config/initializers/sidekiq.rb"
|
8
|
-
DEFAULT_QUEUE = Sidekiq::Worker::ClassMethods::DEFAULT_OPTIONS['queue']
|
9
8
|
|
10
9
|
attr_accessor :settings
|
11
10
|
|
12
|
-
def initialize
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
11
|
def parse
|
17
12
|
@settings = CLI.new do
|
18
13
|
option :config_path, :short => :c, :default => DEFAULT_CONFIG_PATH, :description => "Sidekiq client config file path"
|
19
|
-
|
14
|
+
option :queue, :short => :q, :description => "Queue to place job on"
|
20
15
|
argument :command, :description => "'push' to push a job to the queue"
|
21
16
|
arguments :command_args, :required => false, :description => "command arguments"
|
22
17
|
end.parse! do |settings|
|
@@ -30,7 +25,10 @@ class SidekiqClientCLI
|
|
30
25
|
|
31
26
|
def run
|
32
27
|
# load the config file
|
33
|
-
load settings.config_path if File.exists?
|
28
|
+
load settings.config_path if File.exists?(settings.config_path)
|
29
|
+
|
30
|
+
# set queue if not given
|
31
|
+
settings.queue ||= Sidekiq.default_worker_options['queue']
|
34
32
|
|
35
33
|
self.send settings.command.to_sym
|
36
34
|
end
|
@@ -45,5 +43,5 @@ class SidekiqClientCLI
|
|
45
43
|
end
|
46
44
|
end
|
47
45
|
end
|
48
|
-
end
|
49
46
|
|
47
|
+
end
|
data/sidekiq-client-cli.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe SidekiqClientCLI do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
let(:default_queue) { Sidekiq.default_worker_options['queue'] }
|
5
|
+
|
6
|
+
before(:each) { @client = SidekiqClientCLI.new }
|
7
7
|
|
8
8
|
describe "ARGV parsing" do
|
9
9
|
it "fails if no command" do
|
@@ -46,7 +46,7 @@ describe SidekiqClientCLI do
|
|
46
46
|
@client.settings.command.should eq "push"
|
47
47
|
@client.settings.command_args.should eq worker_klasses
|
48
48
|
@client.settings.config_path.should eq SidekiqClientCLI::DEFAULT_CONFIG_PATH
|
49
|
-
|
49
|
+
@client.settings.queue.should eq nil
|
50
50
|
end
|
51
51
|
|
52
52
|
it "parses push with a configuration file" do
|
@@ -56,7 +56,7 @@ describe SidekiqClientCLI do
|
|
56
56
|
@client.settings.command.should eq "push"
|
57
57
|
@client.settings.command_args.should eq worker_klasses
|
58
58
|
@client.settings.config_path.should eq "mysidekiq.conf"
|
59
|
-
|
59
|
+
@client.settings.queue.should eq nil
|
60
60
|
end
|
61
61
|
|
62
62
|
it "parses push with a queue" do
|
@@ -66,7 +66,7 @@ describe SidekiqClientCLI do
|
|
66
66
|
@client.settings.command.should eq "push"
|
67
67
|
@client.settings.command_args.should eq worker_klasses
|
68
68
|
@client.settings.config_path.should eq SidekiqClientCLI::DEFAULT_CONFIG_PATH
|
69
|
-
|
69
|
+
@client.settings.queue.should eq "my_queue"
|
70
70
|
end
|
71
71
|
|
72
72
|
end
|
@@ -77,6 +77,7 @@ describe SidekiqClientCLI do
|
|
77
77
|
config_path = "sidekiq.conf"
|
78
78
|
@client.settings.stub(:config_path).and_return(config_path)
|
79
79
|
@client.settings.stub(:command).and_return("mycommand")
|
80
|
+
@client.settings.stub(:queue).and_return(default_queue)
|
80
81
|
@client.should_receive(:mycommand)
|
81
82
|
|
82
83
|
File.should_receive(:exists?).with(config_path).and_return true
|
@@ -90,6 +91,7 @@ describe SidekiqClientCLI do
|
|
90
91
|
settings = double("settings")
|
91
92
|
settings.stub(:config_path).and_return(config_path)
|
92
93
|
settings.stub(:command).and_return("mycommand")
|
94
|
+
settings.stub(:queue).and_return(default_queue)
|
93
95
|
|
94
96
|
@client.settings = settings
|
95
97
|
@client.should_receive(:mycommand)
|
@@ -108,17 +110,17 @@ describe SidekiqClientCLI do
|
|
108
110
|
klass2 = "SecondWorker"
|
109
111
|
settings = double("settings")
|
110
112
|
settings.stub(:command_args).and_return [klass1, klass2]
|
111
|
-
settings.stub(:queue).and_return
|
113
|
+
settings.stub(:queue).and_return default_queue
|
112
114
|
@client.settings = settings
|
113
115
|
|
114
|
-
Sidekiq::Client.should_receive(:push).with('class' => klass1, 'args' => [], 'queue' =>
|
115
|
-
Sidekiq::Client.should_receive(:push).with('class' => klass2, 'args' => [], 'queue' =>
|
116
|
+
Sidekiq::Client.should_receive(:push).with('class' => klass1, 'args' => [], 'queue' => default_queue)
|
117
|
+
Sidekiq::Client.should_receive(:push).with('class' => klass2, 'args' => [], 'queue' => default_queue)
|
116
118
|
|
117
119
|
@client.push
|
118
120
|
end
|
119
121
|
|
120
122
|
it "pushes the worker classes to the correct queue" do
|
121
|
-
|
123
|
+
queue = "Queue"
|
122
124
|
klass1 = "FirstWorker"
|
123
125
|
klass2 = "SecondWorker"
|
124
126
|
settings = double("settings")
|
@@ -137,11 +139,11 @@ describe SidekiqClientCLI do
|
|
137
139
|
klass2 = "SecondWorker"
|
138
140
|
settings = double("settings")
|
139
141
|
settings.stub(:command_args).and_return [klass1, klass2]
|
140
|
-
settings.stub(:queue).and_return
|
142
|
+
settings.stub(:queue).and_return default_queue
|
141
143
|
@client.settings = settings
|
142
144
|
|
143
|
-
Sidekiq::Client.should_receive(:push).with('class' => klass1, 'args' => [], 'queue' =>
|
144
|
-
Sidekiq::Client.should_receive(:push).with('class' => klass2, 'args' => [], 'queue' =>
|
145
|
+
Sidekiq::Client.should_receive(:push).with('class' => klass1, 'args' => [], 'queue' => default_queue).and_raise
|
146
|
+
Sidekiq::Client.should_receive(:push).with('class' => klass2, 'args' => [], 'queue' => default_queue)
|
145
147
|
|
146
148
|
out = IOHelper.stdout_read do
|
147
149
|
@client.push
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-client-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adil Haritah
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: sidekiq
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 2.15.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 2.15.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: cli
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|