Sha256: fb3420b4bf6d062bc3b8a9f96d9c054606b76bc1c421d7be040a6640ee449810
Contents?: true
Size: 1.3 KB
Versions: 15
Compression:
Stored size: 1.3 KB
Contents
require "rails/generators/rails/app/app_generator" module Jobshop class DummyApp class << self def require_environment! if exist? require File.join(path, "config/environment") else abort("Dummy app does not exist. Please run `rake jobshop:dummy` to create it.") end end def exist? Dir.exist?(path) end def destroy! FileUtils.rmtree(path) Object.send(:remove_const, constant_name) end def path @path ||= File.expand_path("spec/dummy-#{Rails::VERSION::STRING}") end def constant_name @constant_name = File.basename(path) .gsub(/\W/, '_').squeeze('_').camelize end def rakefile File.join(path, "Rakefile") end def template @template ||= File.expand_path("templates/dummy_template.rb", __dir__) end end def initialize options = { api: false, database: "postgresql", skip_gemfile: true, skip_git: true, skip_bundle: true, skip_listen: true, skip_test: true, template: DummyApp.template } DummyApp.destroy! if DummyApp.exist? Rails::Generators::AppGenerator.new([ DummyApp.path ], options).invoke_all end end end
Version data entries
15 entries across 15 versions & 1 rubygems