Sha256: ead25a6c8629d02dc69f69cd476fe789f3f96dd7985f0770d588d7927c2a2e8c

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

require "rails/generators"
require "rails/generators/rails/app/app_generator"

require "jobshop/version"

module Jobshop
  class AppBuilder < Rails::AppBuilder
    def readme
      template "README.md.tt"
    end

    def gemfile
      super
      append_to_file "Gemfile", <<~GEMFILE
        \ngem "jobshop", "~> #{Jobshop.gem_version}"
      GEMFILE
    end

    def config
      super
      template "config/secrets.yml.tt", force: true
    end

    def mount_engine
      route %Q(mount Jobshop::Engine => "/")
    end
  end

  module Generators
    class AppGenerator < Rails::Generators::AppGenerator
      def self.source_root
        File.expand_path("templates", __dir__)
      end

      def self.source_paths
        [ Rails::Generators::AppGenerator.source_root,
          Jobshop::Generators::AppGenerator.source_root ]
      end

      hide!

      class_option :help, type: :boolean, aliases: "-h", group: :other,
        desc: "Show this help message and quit"

      class_options[:database].instance_variable_set(:@default, "postgresql")

      class_option :version, type: :boolean, aliases: "-v", group: :other,
              desc: "Show Jobshop version number and quit"

      def self.banner
        "jobshop new #{arguments.map(&:usage).join(' ')} [options]"
      end

      def finish_template
        build :mount_engine
        super
      end

      def run_bundle
        super
        bundle_command("binstub jobshop") if bundle_install?
      end

    protected
      def get_builder_class
        Jobshop::AppBuilder
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jobshop-0.0.101 lib/generators/jobshop/app/app_generator.rb