Sha256: ebcb92c798daeca151a0b27d67a7c47ff4447d753a91f7e02100ea4d3a78a3f2

Contents?: true

Size: 1.18 KB

Versions: 31

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require_relative "../../lib/plutonium_generators"

module Pu
  module Core
    class InstallGenerator < Rails::Generators::Base
      include PlutoniumGenerators::Generator

      source_root File.expand_path("templates", __dir__)

      desc "Set up the base requirements for Plutonium"

      def start
        setup_packages
        setup_app
        eject_views
        setup_active_record
      rescue => e
        exception "#{self.class} failed:", e
      end

      private

      def setup_packages
        copy_file "config/packages.rb"
        create_file "packages/.keep"
        insert_into_file "config/application.rb", "\nrequire_relative \"packages\"\n", after: /Bundler\.require.*\n/
      end

      def setup_app
        directory "config"
        directory "app"
      end

      def eject_views
        invoke "pu:eject:layout", [], dest: "main_app",
          force: options[:force],
          skip: options[:skip]
      end

      def setup_active_record
        inject_into_class(
          "app/models/application_record.rb",
          "ApplicationRecord",
          "  include Plutonium::Resource::Record\n\n"
        )
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
plutonium-0.19.8 lib/generators/pu/core/install/install_generator.rb
plutonium-0.19.7 lib/generators/pu/core/install/install_generator.rb
plutonium-0.19.6 lib/generators/pu/core/install/install_generator.rb
plutonium-0.19.5 lib/generators/pu/core/install/install_generator.rb
plutonium-0.19.4 lib/generators/pu/core/install/install_generator.rb
plutonium-0.19.3 lib/generators/pu/core/install/install_generator.rb
plutonium-0.19.2 lib/generators/pu/core/install/install_generator.rb
plutonium-0.19.1 lib/generators/pu/core/install/install_generator.rb
plutonium-0.19.0 lib/generators/pu/core/install/install_generator.rb
plutonium-0.18.8 lib/generators/pu/core/install/install_generator.rb
plutonium-0.18.7 lib/generators/pu/core/install/install_generator.rb
plutonium-0.18.6 lib/generators/pu/core/install/install_generator.rb
plutonium-0.18.5 lib/generators/pu/core/install/install_generator.rb
plutonium-0.18.4 lib/generators/pu/core/install/install_generator.rb
plutonium-0.18.3 lib/generators/pu/core/install/install_generator.rb
plutonium-0.18.2 lib/generators/pu/core/install/install_generator.rb
plutonium-0.18.1 lib/generators/pu/core/install/install_generator.rb
plutonium-0.18.0 lib/generators/pu/core/install/install_generator.rb
plutonium-0.16.5 lib/generators/pu/core/install/install_generator.rb
plutonium-0.16.4 lib/generators/pu/core/install/install_generator.rb