Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
348 additions
and
341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require 'rails/generators/named_base' | ||
|
||
module Sidekiq | ||
module Generators # :nodoc: | ||
class JobGenerator < ::Rails::Generators::NamedBase # :nodoc: | ||
desc 'This generator creates a Sidekiq Job in app/jobs and a corresponding test' | ||
|
||
check_class_collision suffix: 'Job' | ||
|
||
def self.default_generator_root | ||
File.dirname(__FILE__) | ||
end | ||
|
||
def create_job_file | ||
template 'job.rb.erb', File.join('app/jobs', class_path, "#{file_name}_job.rb") | ||
end | ||
|
||
def create_test_file | ||
if defined?(RSpec) | ||
create_job_spec | ||
else | ||
create_job_test | ||
end | ||
end | ||
|
||
private | ||
|
||
def create_job_spec | ||
template_file = File.join( | ||
'spec/jobs', | ||
class_path, | ||
"#{file_name}_job_spec.rb" | ||
) | ||
template 'job_spec.rb.erb', template_file | ||
end | ||
|
||
def create_job_test | ||
template_file = File.join( | ||
'test/jobs', | ||
class_path, | ||
"#{file_name}_job_test.rb" | ||
) | ||
template 'job_test.rb.erb', template_file | ||
end | ||
|
||
|
||
end | ||
end | ||
end |
6 changes: 3 additions & 3 deletions
6
...enerators/sidekiq/templates/worker.rb.erb → lib/generators/sidekiq/templates/job.rb.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<% module_namespacing do -%> | ||
class <%= class_name %>Worker | ||
include Sidekiq::Worker | ||
class <%= class_name %>Job | ||
include Sidekiq::Job | ||
|
||
def perform(*args) | ||
# Do something | ||
end | ||
end | ||
<% end -%> | ||
<% end -%> |
4 changes: 2 additions & 2 deletions
4
...tors/sidekiq/templates/worker_spec.rb.erb → ...erators/sidekiq/templates/job_spec.rb.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
require 'rails_helper' | ||
<% module_namespacing do -%> | ||
RSpec.describe <%= class_name %>Worker, :type => :worker do | ||
RSpec.describe <%= class_name %>Job, :type => :job do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end | ||
<% end -%> | ||
<% end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require_relative 'test_helper' | ||
<% module_namespacing do -%> | ||
class <%= class_name %>JobTest < MiniTest::Unit::TestCase | ||
def test_example | ||
skip "add some examples to (or delete) #{__FILE__}" | ||
end | ||
end | ||
<% end -%> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.