nedforce-sidekiq-client-cli 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 05b2941f18d0359bcbda214f2bd1e7c5152fa533
4
+ data.tar.gz: 5595d93847442894a017ab1cae5eb10401553dbb
5
+ SHA512:
6
+ metadata.gz: 7cf76b561f45ed144178a40a8f6cfe9dc8d148e6e9b06669844ea65f2e3d8156c91e041ad2be019a969403348e05de629a087cfef4d1a6b22b8262f98ad9a7fd
7
+ data.tar.gz: 57c31b446e2de804c7f43ac96b76936a23b56b5d1b9f270be6fe0b2ee35c4eac47f33b33df5aca7552de588a8a3dbc590e8e2d327bfdfdf895315f706fc56997
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.0.0"
4
+ - "2.2.2"
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sidekiq-client-cli.gemspec
4
+ gemspec
5
+
6
+ gem 'coveralls', require: false
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 didil
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,67 @@
1
+ # sidekiq-client-cli
2
+
3
+ [![Build Status](https://secure.travis-ci.org/didil/sidekiq-client-cli.png)](http://travis-ci.org/didil/sidekiq-client-cli) [![Code Climate](https://codeclimate.com/github/didil/sidekiq-client-cli.png)](https://codeclimate.com/github/didil/sidekiq-client-cli) [![Coverage Status](https://coveralls.io/repos/didil/sidekiq-client-cli/badge.png)](https://coveralls.io/r/didil/sidekiq-client-cli)
4
+
5
+ A command line client for Sidekiq
6
+ You can use this when you need to interact with Sidekiq via the command line, for example in cron jobs.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'sidekiq-client-cli'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install sidekiq-client-cli
21
+
22
+ ## Dependencies
23
+
24
+ Requires sidekiq >= 2.15.0
25
+
26
+ ## Usage
27
+
28
+ Push worker classes to Sidekiq :
29
+
30
+ $ sidekiq-client push MyWorker OtherWorker
31
+
32
+ You can specify a sidekiq config file via the -c option (if not specified the usual rails path config/initializers/sidekiq.rb is used) :
33
+
34
+ $ sidekiq-client -c mysidekiq.conf push MyWorker OtherWorker
35
+
36
+ You can also specify a specific queue to push the jobs to :
37
+
38
+ $ sidekiq-client -q my_queue push MyWorker OtherWorker
39
+
40
+ You can specify that the job should not be retried, if it fails :
41
+
42
+ $ sidekiq-client -r false push MyWorker OtherWorker
43
+
44
+ You can also specify the number of times a job should be retried, if it fails :
45
+
46
+ $ sidekiq-client -r 5 push MyWorker OtherWorker
47
+ If your job requires arguments, you can specify them a la Rake (it uses Rake's task parser):
48
+
49
+ $ sidekiq-client push MyWorker[my-arg,my-other-arg]
50
+
51
+ For help :
52
+
53
+ $ sidekiq-client --help
54
+
55
+ ## Contributing to sidekiq-client-cli
56
+
57
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
58
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
59
+ * Fork the project.
60
+ * Start a feature/bugfix branch.
61
+ * Commit and push until you are happy with your contribution.
62
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
63
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
64
+
65
+ ## Copyright
66
+
67
+ Copyright (c) 2013 Adil Haritah. See LICENSE.txt for further details.
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rubygems'
3
+
4
+ require 'rspec/core'
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = FileList['spec/**/*_spec.rb']
8
+ end
9
+
10
+
11
+ task :default => :spec
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/sidekiq_client_cli'
4
+
5
+ begin
6
+ client = SidekiqClientCLI.new
7
+ client.parse
8
+ client.run or exit 1
9
+ rescue => e
10
+ STDERR.puts e.message
11
+ STDERR.puts e.backtrace.join("\n")
12
+ exit 1
13
+ end
@@ -0,0 +1,77 @@
1
+ require 'sidekiq'
2
+ require_relative 'sidekiq_client_cli/version'
3
+ require_relative 'sidekiq_client_cli/parser'
4
+
5
+ class SidekiqClientCLI
6
+ COMMANDS = %w{push}
7
+ DEFAULT_CONFIG_PATH = "config/initializers/sidekiq.rb"
8
+
9
+ attr_accessor :settings
10
+
11
+ def parse
12
+ @settings = Parser.new.parse
13
+ end
14
+
15
+ def self.cast_retry_option(retry_option)
16
+ return true if !!retry_option.match(/^(true|t|yes|y)$/i)
17
+ return false if !!retry_option.match(/^(false|f|no|n|0)$/i)
18
+ return retry_option.to_i if !!retry_option.match(/^\d+$/)
19
+ end
20
+
21
+ def run
22
+ # load the config file
23
+ load settings.config_path if File.exists?(settings.config_path)
24
+
25
+ # set queue or retry if they are not given
26
+ settings.queue ||= Sidekiq.default_worker_options['queue']
27
+ settings.retry = Sidekiq.default_worker_options['retry'] if settings.retry.nil?
28
+
29
+ self.send settings.command.to_sym
30
+ end
31
+
32
+ # Returns true if all args can be pushed successfully.
33
+ # Returns false if at least one exception occured.
34
+ def push
35
+ settings.command_args.inject(true) do |success, arg|
36
+ push_argument arg
37
+ end
38
+ end
39
+
40
+ private
41
+
42
+ def push_argument(arg)
43
+ klass, klass_args = parse_task_string(arg)
44
+ jid = Sidekiq::Client.push({ 'class' => klass,
45
+ 'queue' => settings.queue,
46
+ 'args' => klass_args,
47
+ 'retry' => settings.retry })
48
+ p "Posted #{klass} to queue '#{settings.queue}', Job ID : #{jid}, Retry : #{settings.retry}, Args : #{klass_args}"
49
+ true
50
+ rescue StandardError => ex
51
+ p "Failed to push to queue : #{ex.message}"
52
+ false
53
+ end
54
+
55
+ # pilfered from rake
56
+ # commas within args are not supported
57
+ def parse_task_string(string)
58
+ /^([^\[]+)(?:\[(.*)\])$/ =~ string.to_s
59
+
60
+ name = $1
61
+ remaining_args = $2
62
+
63
+ return string, [] unless name
64
+ return name, [] if remaining_args.empty?
65
+
66
+ args = []
67
+
68
+ begin
69
+ /((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args
70
+
71
+ remaining_args = $2
72
+ args << $1.gsub(/\\(.)/, '\1')
73
+ end while remaining_args
74
+
75
+ return name, args
76
+ end
77
+ end
@@ -0,0 +1,21 @@
1
+ require 'cli'
2
+
3
+ class SidekiqClientCLI
4
+ class Parser
5
+ def parse
6
+ CLI.new do
7
+ option :config_path, :short => :c, :default => DEFAULT_CONFIG_PATH, :description => "Sidekiq client config file path"
8
+ option :queue, :short => :q, :description => "Queue to place job on"
9
+ option :retry, :short => :r, :cast => lambda { |r| SidekiqClientCLI.cast_retry_option(r) }, :description => "Retry option for job"
10
+ argument :command, :description => "'push' to push a job to the queue"
11
+ arguments :command_args, :required => false, :description => "command arguments"
12
+ end.parse! do |settings|
13
+ fail "Invalid command '#{settings.command}'. Available commands: #{COMMANDS.join(',').chomp(',')}" unless COMMANDS.include? settings.command
14
+
15
+ if settings.command == "push" && settings.command_args.empty?
16
+ fail "No Worker Classes to push"
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ class SidekiqClientCLI
2
+ VERSION = "0.1.7"
3
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sidekiq_client_cli/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nedforce-sidekiq-client-cli"
8
+ spec.version = SidekiqClientCLI::VERSION
9
+ spec.authors = ["Adil Haritah"]
10
+ spec.email = ["haritahadil@gmail.com"]
11
+ spec.description = %q{Command line client for Sidekiq. Push worker classes to queue from the cli ...}
12
+ spec.summary = %q{Command line client for Sidekiq}
13
+ spec.homepage = "https://github.com/didil/sidekiq-client-cli"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "simplecov"
25
+
26
+ spec.add_dependency "sidekiq", ">= 2.15"
27
+ spec.add_dependency "cli"
28
+
29
+ end
@@ -0,0 +1,318 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe SidekiqClientCLI do
4
+ let(:default_queue) { Sidekiq.default_worker_options['queue'] }
5
+ let(:default_retry_option) { Sidekiq.default_worker_options['retry'] }
6
+
7
+ before(:each) { @client = SidekiqClientCLI.new }
8
+
9
+ describe "ARGV parsing" do
10
+ it "fails if no command" do
11
+ out = IOHelper.stderr_read do
12
+ ARGV = []
13
+ expect {
14
+ @client.parse
15
+ }.to (raise_error(SystemExit))
16
+ end
17
+
18
+ out.should include("'command' not given")
19
+ end
20
+
21
+ it "fails if wrong command" do
22
+ out = IOHelper.stderr_read do
23
+ ARGV = %w(dosomething)
24
+ expect {
25
+ @client.parse
26
+ }.to (raise_error(SystemExit))
27
+ end
28
+
29
+ out.should include("Invalid command")
30
+ end
31
+
32
+ it "fails if push without classes" do
33
+ out = IOHelper.stderr_read do
34
+ ARGV = %w(push)
35
+ expect {
36
+ @client.parse
37
+ }.to (raise_error(SystemExit))
38
+ end
39
+
40
+ out.should include("No Worker Classes")
41
+ end
42
+
43
+ it "parses push with classes" do
44
+ worker_klasses = %w{FirstWorker SecondWorker}
45
+ ARGV = %w{ push }.concat(worker_klasses)
46
+ @client.parse
47
+ @client.settings.command.should eq "push"
48
+ @client.settings.command_args.should eq worker_klasses
49
+ @client.settings.config_path.should eq SidekiqClientCLI::DEFAULT_CONFIG_PATH
50
+ @client.settings.queue.should eq nil
51
+ @client.settings.retry.should eq nil
52
+ end
53
+
54
+ it "parses push with a configuration file" do
55
+ worker_klasses = %w{FirstWorker SecondWorker}
56
+ ARGV = %w{ -c mysidekiq.conf push }.concat(worker_klasses)
57
+ @client.parse
58
+ @client.settings.command.should eq "push"
59
+ @client.settings.command_args.should eq worker_klasses
60
+ @client.settings.config_path.should eq "mysidekiq.conf"
61
+ @client.settings.queue.should eq nil
62
+ end
63
+
64
+ it "parses push with a queue" do
65
+ worker_klasses = %w{FirstWorker SecondWorker}
66
+ ARGV = %w{ -q my_queue push }.concat(worker_klasses)
67
+ @client.parse
68
+ @client.settings.command.should eq "push"
69
+ @client.settings.command_args.should eq worker_klasses
70
+ @client.settings.config_path.should eq SidekiqClientCLI::DEFAULT_CONFIG_PATH
71
+ @client.settings.queue.should eq "my_queue"
72
+ end
73
+
74
+ it 'parses push with a boolean retry' do
75
+ worker_klasses = %w{FirstWorker SecondWorker}
76
+ ARGV = %w{ -r false push }.concat(worker_klasses)
77
+ @client.parse
78
+ @client.settings.command.should eq "push"
79
+ @client.settings.command_args.should eq worker_klasses
80
+ @client.settings.config_path.should eq SidekiqClientCLI::DEFAULT_CONFIG_PATH
81
+ @client.settings.retry.should eq false
82
+ end
83
+
84
+ it 'parses push with an integer retry' do
85
+ worker_klasses = %w{FirstWorker SecondWorker}
86
+ ARGV = %w{ -r 42 push }.concat(worker_klasses)
87
+ @client.parse
88
+ @client.settings.command.should eq "push"
89
+ @client.settings.command_args.should eq worker_klasses
90
+ @client.settings.config_path.should eq SidekiqClientCLI::DEFAULT_CONFIG_PATH
91
+ @client.settings.retry.should eq 42
92
+ end
93
+
94
+ end
95
+
96
+ describe "run" do
97
+
98
+ it "loads the config file if existing and runs the command" do
99
+ config_path = "sidekiq.conf"
100
+ @client.settings.stub(:config_path).and_return(config_path)
101
+ @client.settings.stub(:command).and_return("mycommand")
102
+ @client.settings.stub(:queue).and_return(default_queue)
103
+ @client.settings.stub(:retry).and_return(default_retry_option)
104
+ @client.should_receive(:mycommand)
105
+
106
+ File.should_receive(:exists?).with(config_path).and_return true
107
+ @client.should_receive(:load).with(config_path)
108
+
109
+ @client.run
110
+ end
111
+
112
+ it "won't load a non-existant config file and the command is run" do
113
+ config_path = "sidekiq.conf"
114
+ settings = double("settings")
115
+ settings.stub(:config_path).and_return(config_path)
116
+ settings.stub(:command).and_return("mycommand")
117
+ settings.stub(:queue).and_return(default_queue)
118
+ settings.stub(:retry).and_return(default_retry_option)
119
+
120
+ @client.settings = settings
121
+ @client.should_receive(:mycommand)
122
+
123
+ File.should_receive(:exists?).with(config_path).and_return false
124
+ @client.should_not_receive(:load)
125
+
126
+ @client.run
127
+ end
128
+
129
+ it "doesnt try to change the retry value if it has been set to false" do
130
+ config_path = "sidekiq.conf"
131
+ @client.settings.stub(:config_path).and_return(config_path)
132
+ @client.settings.stub(:command).and_return("mycommand")
133
+ @client.settings.stub(:queue).and_return(default_queue)
134
+ @client.settings.stub(:retry).and_return(false)
135
+
136
+ @client.should_receive(:mycommand)
137
+ @client.should_not_receive(:retry=)
138
+
139
+ @client.run
140
+ end
141
+
142
+ it "doesnt try to change the retry value if it has been set to true" do
143
+ config_path = "sidekiq.conf"
144
+ @client.settings.stub(:config_path).and_return(config_path)
145
+ @client.settings.stub(:command).and_return("mycommand")
146
+ @client.settings.stub(:queue).and_return(default_queue)
147
+ @client.settings.stub(:retry).and_return(true)
148
+
149
+ @client.should_receive(:mycommand)
150
+ @client.should_not_receive(:retry=)
151
+
152
+ @client.run
153
+ end
154
+ end
155
+
156
+ describe 'push' do
157
+ let(:settings) { double("settings") }
158
+ let(:klass1) { "FirstWorker" }
159
+ let(:klass2) { "SecondWorker" }
160
+ let(:client) { SidekiqClientCLI.new }
161
+
162
+ before(:each) do
163
+ settings.stub(:command_args).and_return [klass1, klass2]
164
+ client.settings = settings
165
+ end
166
+
167
+ it 'returns true if all #push_argument calls return true' do
168
+ client.stub(:push_argument).and_return(true)
169
+ client.push.should eq true
170
+ end
171
+
172
+ it 'returns false if at least one #push_argument call fails' do
173
+ client.should_receive(:push_argument).with('FirstWorker').and_return(true)
174
+ client.should_receive(:push_argument).with('SecondWorker').and_return(false)
175
+ client.push.should eq false
176
+ end
177
+ end
178
+
179
+ describe '#push_argument' do
180
+ let(:settings) { double("settings", :queue => default_queue, :retry => default_retry_option) }
181
+ let(:klass1) { "FirstWorker" }
182
+ let(:klass1_arg1) { "2015-01-01" }
183
+ let(:klass1_arg2) { "some string variable" }
184
+ let(:client) { SidekiqClientCLI.new }
185
+
186
+ before(:each) do
187
+ client.settings = settings
188
+ end
189
+
190
+ it "pushes the worker classes" do
191
+ Sidekiq::Client.should_receive(:push).with('class' => klass1,
192
+ 'args' => [],
193
+ 'queue' => default_queue,
194
+ 'retry' => default_retry_option)
195
+
196
+ client.__send__(:push_argument, klass1).should eq true
197
+ end
198
+
199
+ it "pushes the worker classes to the correct queue" do
200
+ queue = "Queue"
201
+ settings.stub(:queue).and_return queue
202
+
203
+ Sidekiq::Client.should_receive(:push).with('class' => klass1,
204
+ 'args' => [],
205
+ 'queue' => queue,
206
+ 'retry' => default_retry_option)
207
+
208
+ client.__send__(:push_argument, klass1).should eq true
209
+ end
210
+
211
+ it 'pushes the worker classes with retry disabled' do
212
+ retry_option = false
213
+ settings.stub(:retry).and_return retry_option
214
+
215
+ Sidekiq::Client.should_receive(:push).with('class' => klass1,
216
+ 'args' => [],
217
+ 'queue' => default_queue,
218
+ 'retry' => retry_option)
219
+
220
+ client.__send__(:push_argument, klass1).should eq true
221
+ end
222
+
223
+ it 'pushes the worker classes with a set retry number' do
224
+ retry_attempts = 5
225
+ settings.stub(:retry).and_return retry_attempts
226
+
227
+ Sidekiq::Client.should_receive(:push).with('class' => klass1,
228
+ 'args' => [],
229
+ 'queue' => default_queue,
230
+ 'retry' => retry_attempts)
231
+
232
+ client.__send__(:push_argument, klass1).should eq true
233
+ end
234
+
235
+ it "prints and continues if an exception is raised" do
236
+ Sidekiq::Client.should_receive(:push).with('class' => klass1,
237
+ 'args' => [],
238
+ 'queue' => default_queue,
239
+ 'retry' => default_retry_option).and_raise
240
+
241
+ out = IOHelper.stdout_read do
242
+ client.__send__(:push_argument, klass1).should eq false
243
+ end
244
+ out.should include("Failed to push")
245
+ end
246
+
247
+ it "pushes a worker with one arg" do
248
+ Sidekiq::Client.should_receive(:push).with('class' => klass1,
249
+ 'args' => [klass1_arg1],
250
+ 'queue' => default_queue,
251
+ 'retry' => default_retry_option)
252
+ client.__send__(:push_argument, "#{klass1}[#{klass1_arg1}]").should eq true
253
+ end
254
+
255
+ it "pushes a worker with two args" do
256
+ Sidekiq::Client.should_receive(:push).with('class' => klass1,
257
+ 'args' => [klass1_arg1,klass1_arg2],
258
+ 'queue' => default_queue,
259
+ 'retry' => default_retry_option)
260
+ client.__send__(:push_argument, "#{klass1}[#{klass1_arg1},#{klass1_arg2}]").should eq true
261
+ end
262
+ end
263
+
264
+ describe 'cast_retry_option' do
265
+ subject { SidekiqClientCLI }
266
+
267
+ it 'returns false if the string matches false|f|no|n|0' do
268
+ subject.cast_retry_option('false').should == false
269
+ subject.cast_retry_option('f').should == false
270
+ subject.cast_retry_option('no').should == false
271
+ subject.cast_retry_option('n').should == false
272
+ subject.cast_retry_option('0').should == false
273
+ end
274
+
275
+ it 'returns true if the string matches true|t|yes|y' do
276
+ subject.cast_retry_option('true').should == true
277
+ subject.cast_retry_option('t').should == true
278
+ subject.cast_retry_option('yes').should == true
279
+ subject.cast_retry_option('y').should == true
280
+ end
281
+
282
+ it 'returns an integer if the passed string is an integer' do
283
+ subject.cast_retry_option('1').should == 1
284
+ subject.cast_retry_option('42').should == 42
285
+ end
286
+
287
+ end
288
+
289
+ describe 'parse_task_string' do
290
+ let(:client) { SidekiqClientCLI.new }
291
+ it 'parses a task without args' do
292
+ expected = "SomeTaskName"
293
+ name, args = client.send(:parse_task_string, expected)
294
+ name.should eq expected
295
+ args.should eq []
296
+ end
297
+
298
+ it 'parses a task with one arg' do
299
+ expected = "SomeTaskName"
300
+ expected_arg = "arg1"
301
+ name, args = client.send(:parse_task_string, "#{expected}[#{expected_arg}]")
302
+
303
+ name.should eq expected
304
+ args.should eq [expected_arg]
305
+ end
306
+
307
+ it 'parses a task with two args' do
308
+ expected = "SomeTaskName"
309
+ expected_args = ["arg1", "arg2"]
310
+ name, args = client.send(:parse_task_string,
311
+ "#{expected}[#{expected_args[0]},#{expected_args[1]}]")
312
+
313
+ name.should eq expected
314
+ args.should eq expected_args
315
+ end
316
+ end
317
+
318
+ end
@@ -0,0 +1,24 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
5
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
+ SimpleCov::Formatter::HTMLFormatter,
7
+ Coveralls::SimpleCov::Formatter
8
+ ]
9
+ SimpleCov.start do
10
+ add_filter "/spec/support/"
11
+ end
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'rspec'
16
+ require 'sidekiq_client_cli'
17
+
18
+ # Requires supporting files with custom matchers and macros, etc,
19
+ # in ./support/ and its subdirectories.
20
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
21
+
22
+ RSpec.configure do |config|
23
+
24
+ end
@@ -0,0 +1,53 @@
1
+ module IOHelper
2
+
3
+ def self.stdin_write(data)
4
+ r, w = IO.pipe
5
+ old_stdin = STDIN.clone
6
+ STDIN.reopen r
7
+ Thread.new do
8
+ w.write data
9
+ w.close
10
+ end
11
+ begin
12
+ yield
13
+ ensure
14
+ STDIN.reopen old_stdin
15
+ end
16
+ end
17
+
18
+ def self.stdout_read
19
+ r, w = IO.pipe
20
+ old_stdout = STDOUT.clone
21
+ STDOUT.reopen(w)
22
+ data = ''
23
+ t = Thread.new do
24
+ data << r.read
25
+ end
26
+ begin
27
+ yield
28
+ ensure
29
+ w.close
30
+ STDOUT.reopen(old_stdout)
31
+ end
32
+ t.join
33
+ data
34
+ end
35
+
36
+ def self.stderr_read
37
+ r, w = IO.pipe
38
+ old_stdout = STDERR.clone
39
+ STDERR.reopen(w)
40
+ data = ''
41
+ t = Thread.new do
42
+ data << r.read
43
+ end
44
+ begin
45
+ yield
46
+ ensure
47
+ w.close
48
+ STDERR.reopen(old_stdout)
49
+ end
50
+ t.join
51
+ data
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nedforce-sidekiq-client-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.7
5
+ platform: ruby
6
+ authors:
7
+ - Adil Haritah
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sidekiq
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '2.15'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '2.15'
83
+ - !ruby/object:Gem::Dependency
84
+ name: cli
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Command line client for Sidekiq. Push worker classes to queue from the
98
+ cli ...
99
+ email:
100
+ - haritahadil@gmail.com
101
+ executables:
102
+ - sidekiq-client
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".coveralls.yml"
107
+ - ".gitignore"
108
+ - ".rspec"
109
+ - ".travis.yml"
110
+ - Gemfile
111
+ - LICENSE.txt
112
+ - README.md
113
+ - Rakefile
114
+ - bin/sidekiq-client
115
+ - lib/sidekiq_client_cli.rb
116
+ - lib/sidekiq_client_cli/parser.rb
117
+ - lib/sidekiq_client_cli/version.rb
118
+ - sidekiq-client-cli.gemspec
119
+ - spec/sidekiq_client_cli_spec.rb
120
+ - spec/spec_helper.rb
121
+ - spec/support/io.rb
122
+ homepage: https://github.com/didil/sidekiq-client-cli
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.4.8
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Command line client for Sidekiq
146
+ test_files:
147
+ - spec/sidekiq_client_cli_spec.rb
148
+ - spec/spec_helper.rb
149
+ - spec/support/io.rb