Sha256: af03d48f4afd87fef5f70e85f4e120d10924518c691acf592ec2cae88b82789d

Contents?: true

Size: 878 Bytes

Versions: 5

Compression:

Stored size: 878 Bytes

Contents

# frozen_string_literal: true

return if PlutoniumGenerators.rails?

module Pu
  module Gen
    class PugGenerator < Rails::Generators::Base
      source_root File.expand_path("templates", __dir__)

      desc "Create a new pug"

      argument :name
      class_option :desc, type: :string, desc: "Description of your pug"

      def start
        template "pug.rb.tt", "lib/generators/pu/#{pug_path}/#{pug_class.underscore}.rb"
        create_file "lib/generators/pu/#{pug_path}/templates/.keep"
      end

      def rubocop
        run "standardrb --fix"
      end

      protected

      def pug_name
        name.split(":").map(&:camelize).join("::")
      end

      def pug_path
        pug_name.underscore
      end

      def pug_module
        pug_name.deconstantize
      end

      def pug_class
        "#{pug_name.demodulize}Generator"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
plutonium-0.8.0 lib/generators/pu/gen/pug/pug_generator.rb
plutonium-0.6.2 lib/generators/pu/gen/pug/pug_generator.rb
plutonium-0.6.1 lib/generators/pu/gen/pug/pug_generator.rb
plutonium-0.6.0 lib/generators/pu/gen/pug/pug_generator.rb
plutonium-0.5.0 lib/generators/pu/gen/pug/pug_generator.rb