Sha256: e2cb8472e60b8d5a56710f1fd9cbd5dfe4a604ba60e9780fdbff262dd607c1bc

Contents?: true

Size: 933 Bytes

Versions: 28

Compression:

Stored size: 933 Bytes

Contents

module Generators
  module PandaCms
    class InstallGenerator < ::Rails::Generators::Base
      source_root File.expand_path("templates", __dir__)

      namespace "panda_cms:install"
      desc "Adds the basic configuration for Panda CMS to your Rails app."

      def create_initializer_file
        # Add the initializer
        initializer_path = "config/initializers/panda_cms.rb"
        unless File.exist?("#{::Rails.root}/#{initializer_path}")
          FileUtils.cp "#{::PandaCms::Engine.root}/#{initializer_path}", "#{::Rails.root}/#{initializer_path}"
        end

        # Add the seed loader to the seeds.rb file
        unless File.read("#{::Rails.root}/db/seeds.rb")&.include?("PandaCms::Engine.load_seed")
          existing_seeds = File.read("#{::Rails.root}/db/seeds.rb")
          IO.write("#{::Rails.root}/db/seeds.rb", "PandaCms::Engine.load_seed\n\n#{existing_seeds}")
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
panda_cms-0.5.10 lib/generators/panda_cms/install_generator.rb
panda_cms-0.5.9 lib/generators/panda_cms/install_generator.rb
panda_cms-0.5.8 lib/generators/panda_cms/install_generator.rb
panda_cms-0.5.7 lib/generators/panda_cms/install_generator.rb
panda_cms-0.5.6 lib/generators/panda_cms/install_generator.rb
panda_cms-0.5.5 lib/generators/panda_cms/install_generator.rb
panda_cms-0.5.4 lib/generators/panda_cms/install_generator.rb
panda_cms-0.5.3 lib/generators/panda_cms/install_generator.rb
panda_cms-0.5.2 lib/generators/panda_cms/install_generator.rb
panda_cms-0.5.1 lib/generators/panda_cms/install_generator.rb
panda_cms-0.5.0 lib/generators/panda_cms/install_generator.rb
panda_cms-0.3.15 lib/generators/panda_cms/install_generator.rb
panda_cms-0.3.14 lib/generators/panda_cms/install_generator.rb
panda_cms-0.3.13 lib/generators/panda_cms/install_generator.rb
panda_cms-0.3.12 lib/generators/panda_cms/install_generator.rb
panda_cms-0.3.11 lib/generators/panda_cms/install_generator.rb
panda_cms-0.3.10 lib/generators/panda_cms/install_generator.rb
panda_cms-0.3.9 lib/generators/panda_cms/install_generator.rb
panda_cms-0.3.8 lib/generators/panda_cms/install_generator.rb
panda_cms-0.3.7 lib/generators/panda_cms/install_generator.rb