Sha256: b89551c7919ff81d8d999035f6d0d4dc7f4eda209c43de9f4deddd8fcca01bfe

Contents?: true

Size: 534 Bytes

Versions: 22

Compression:

Stored size: 534 Bytes

Contents

# frozen_string_literal: true

module Rails
  class CommandGenerator < Rails::Generators::NamedBase

    source_root File.expand_path("../templates", __FILE__)
    check_class_collision suffix: "Command"

    def copy_files
      path = File.join("app", "commands", class_path, "#{file_name}_command.rb")
      template("command.rb.tt", path)
    end

    private

    def file_name
      @_file_name ||= remove_possible_suffix(super)
    end

    def remove_possible_suffix(name)
      name.sub(/_?command$/i, "")
    end

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
lite-command-3.3.3 lib/generators/rails/command_generator.rb
lite-command-3.3.2 lib/generators/rails/command_generator.rb
lite-command-3.3.1 lib/generators/rails/command_generator.rb
lite-command-3.3.0 lib/generators/rails/command_generator.rb
lite-command-3.2.1 lib/generators/rails/command_generator.rb
lite-command-3.2.0 lib/generators/rails/command_generator.rb
lite-command-3.1.5 lib/generators/rails/command_generator.rb
lite-command-3.1.4 lib/generators/rails/command_generator.rb
lite-command-3.1.3 lib/generators/rails/command_generator.rb
lite-command-3.1.2 lib/generators/rails/command_generator.rb
lite-command-3.1.1 lib/generators/rails/command_generator.rb
lite-command-3.1.0 lib/generators/rails/command_generator.rb
lite-command-3.0.1 lib/generators/rails/command_generator.rb
lite-command-3.0.0 lib/generators/rails/command_generator.rb
lite-command-2.1.3 lib/generators/rails/command_generator.rb
lite-command-2.1.2 lib/generators/rails/command_generator.rb
lite-command-2.1.1 lib/generators/rails/command_generator.rb
lite-command-2.1.0 lib/generators/rails/command_generator.rb
lite-command-2.0.3 lib/generators/rails/command_generator.rb
lite-command-2.0.2 lib/generators/rails/command_generator.rb