Sha256: b35d86e23796d0d14836bf9e4d7a3091a7eb410b25d21229ada60940e3e41ce2

Contents?: true

Size: 1.83 KB

Versions: 39

Compression:

Stored size: 1.83 KB

Contents

class DispatchJob < Rails::Generators::Base

  class Publisher < Rails::Generators::Base
    source_root File.expand_path('../templates/publisher', __FILE__)
    argument :handler_name, type: :string, required: true
    argument :publisher_name, type: :string, required: true

    class Rspec < Rails::Generators::Base
      source_root File.expand_path('../templates/publisher', __FILE__)
      argument :handler_name, type: :string, required: true
      argument :publisher_name, type: :string, required: true

      def generate_publisher_spec
        template "publisher_spec.rb.erb", "spec/publishers/#{publisher_name}_spec.rb"
      end
    end

    def generate_publisher
      template "publisher.rb.erb", "app/publishers/#{publisher_name}.rb"
    end

    hook_for :test_framework, in: "dispatch_job:publisher"
  end

  class Handler < Rails::Generators::Base
    source_root File.expand_path('../templates/handler', __FILE__)
    argument :handler_name, type: :string, required: true

    class Rspec < Rails::Generators::Base
      source_root File.expand_path('../templates/handler', __FILE__)
      argument :handler_name, type: :string, required: true

      def generate_handler_spec
        template "handler_spec.rb.erb", "spec/handlers/#{handler_name}_spec.rb"
      end
    end

    def generate_handler
      template "handler.rb.erb", "app/handlers/#{handler_name}.rb"
    end

    hook_for :test_framework, in: "dispatch_job:handler"
  end

  # source_root File.expand_path('../templates', __FILE__)

  class_option :publisher, default: :publisher, hide: true
  class_option :handler, default: :handler, hide: true

  argument :handler_name, type: :string

  hook_for :publisher do |publisher|
    invoke publisher, [handler_name, handler_name.underscore + "_publisher"]
  end

  hook_for :handler do |handler|
    invoke handler, [handler_name]
  end

end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
dispatch-rider-1.9.0 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.8.6 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.8.5 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.8.4 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.8.3 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.8.2 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.8.1 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.8.0 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.7.2 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.7.1 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.7.0 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.6.2 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.6.1 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.6.0 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.5.3 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.5.2 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.5.1 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.5.0 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.4.2 lib/generators/dispatch_rider/job/dispatch_job_generator.rb
dispatch-rider-1.4.0 lib/generators/dispatch_rider/job/dispatch_job_generator.rb