Sha256: 23bfec42373d06969fdd658d5c20515cce9a93fba014ae6a8b1febf71ef25819

Contents?: true

Size: 1.17 KB

Versions: 11

Compression:

Stored size: 1.17 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"
        )
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
plutonium-0.15.16 lib/generators/pu/core/install/install_generator.rb
plutonium-0.15.15 lib/generators/pu/core/install/install_generator.rb
plutonium-0.15.14 lib/generators/pu/core/install/install_generator.rb
plutonium-0.15.13 lib/generators/pu/core/install/install_generator.rb
plutonium-0.15.12 lib/generators/pu/core/install/install_generator.rb
plutonium-0.15.11 lib/generators/pu/core/install/install_generator.rb
plutonium-0.15.10 lib/generators/pu/core/install/install_generator.rb
plutonium-0.15.9 lib/generators/pu/core/install/install_generator.rb
plutonium-0.15.8 lib/generators/pu/core/install/install_generator.rb
plutonium-0.15.7 lib/generators/pu/core/install/install_generator.rb
plutonium-0.15.6 lib/generators/pu/core/install/install_generator.rb