Sha256: bf2cebd3b054336c7b020e1ede70b90b3786a5c2b91dffda7c1afa878356ea60

Contents?: true

Size: 937 Bytes

Versions: 273

Compression:

Stored size: 937 Bytes

Contents

require "fileutils"
require_relative "named_base_generator"

module Generators
  module Avo
    class ResourceToolGenerator < NamedBaseGenerator
      source_root File.expand_path("templates", __dir__)

      argument :name, type: :string, required: true

      namespace "avo:resource_tool"

      def handle
        # Add configuration file
        template "resource_tools/resource_tool.tt", "app/avo/resource_tools/#{file_name}.rb"

        # Add view file
        template "resource_tools/partial.tt", "app/views/avo/resource_tools/_#{file_name}.html.erb"
      end

      no_tasks do
        def file_name
          name.to_s.underscore
        end

        def controller_name
          file_name.to_s
        end

        def human_name
          file_name.humanize
        end

        def in_code(text)
          "<code class='p-1 rounded bg-gray-500 text-white text-sm'>#{text}</code>"
        end
      end
    end
  end
end

Version data entries

273 entries across 273 versions & 1 rubygems

Version Path
avo-3.14.3 lib/generators/avo/resource_tool_generator.rb
avo-3.14.2 lib/generators/avo/resource_tool_generator.rb
avo-3.14.1 lib/generators/avo/resource_tool_generator.rb
avo-3.14.0 lib/generators/avo/resource_tool_generator.rb
avo-3.13.7 lib/generators/avo/resource_tool_generator.rb
avo-3.13.6 lib/generators/avo/resource_tool_generator.rb
avo-3.13.5 lib/generators/avo/resource_tool_generator.rb
avo-3.13.4 lib/generators/avo/resource_tool_generator.rb
avo-3.13.3 lib/generators/avo/resource_tool_generator.rb
avo-3.13.2 lib/generators/avo/resource_tool_generator.rb
avo-3.13.1 lib/generators/avo/resource_tool_generator.rb
avo-3.13.0 lib/generators/avo/resource_tool_generator.rb
avo-2.53.0 lib/generators/avo/resource_tool_generator.rb
avo-3.12.0 lib/generators/avo/resource_tool_generator.rb
avo-3.11.10 lib/generators/avo/resource_tool_generator.rb
avo-3.11.9 lib/generators/avo/resource_tool_generator.rb
avo-3.11.8 lib/generators/avo/resource_tool_generator.rb
avo-3.11.7 lib/generators/avo/resource_tool_generator.rb
avo-3.11.6 lib/generators/avo/resource_tool_generator.rb
avo-3.11.5 lib/generators/avo/resource_tool_generator.rb