class MnoEnterprise::DummyGenerator

Constants

PASSTHROUGH_OPTIONS

Attributes

database[R]
lib_name[R]

Public Class Methods

source_paths() click to toggle source
# File lib/generators/mno_enterprise/dummy/dummy_generator.rb, line 11
def self.source_paths
  paths = self.superclass.source_paths
  paths << File.expand_path('../templates', __FILE__)
  paths.flatten
end

Public Instance Methods

clean_up() click to toggle source
# File lib/generators/mno_enterprise/dummy/dummy_generator.rb, line 17
def clean_up
  remove_directory_if_exists(dummy_path)
end
generate_test_dummy() click to toggle source
# File lib/generators/mno_enterprise/dummy/dummy_generator.rb, line 25
def generate_test_dummy
   # calling slice on a Thor::CoreExtensions::HashWithIndifferentAccess
  # object has been known to return nil
  opts = {}.merge(options).slice(*PASSTHROUGH_OPTIONS)
  opts[:database] = 'sqlite3' if opts[:database].blank?
  opts[:force] = true
  opts[:skip_bundle] = true

  say "Generating dummy Rails application..."
  invoke Rails::Generators::AppGenerator,
    [ File.expand_path(dummy_path, destination_root) ], opts
end
test_dummy_clean() click to toggle source
# File lib/generators/mno_enterprise/dummy/dummy_generator.rb, line 56
def test_dummy_clean
  inside dummy_path do
    remove_file ".gitignore"
    remove_file "doc"
    remove_file "Gemfile"
    remove_file "lib/tasks"
    remove_file "app/assets/images/rails.png"
    remove_file "public/index.html"
    remove_file "public/robots.txt"
    remove_file "README"
    remove_file "test"
    remove_file "vendor"
  end
end
test_dummy_config() click to toggle source
# File lib/generators/mno_enterprise/dummy/dummy_generator.rb, line 38
def test_dummy_config
  @lib_name = options[:lib_name]
  @database = options[:database]

  template "rails/database.yml", "#{dummy_path}/config/database.yml", force: true
  template "rails/boot.rb.erb", "#{dummy_path}/config/boot.rb", force: true
  template "rails/application.rb.erb", "#{dummy_path}/config/application.rb", force: true
  template "rails/routes.rb", "#{dummy_path}/config/routes.rb", force: true
  template "rails/test-env.rb", "#{dummy_path}/config/environments/test.rb", force: true
end
test_dummy_frontend() click to toggle source

Overwrite mnoe less file required by asset pipeline

# File lib/generators/mno_enterprise/dummy/dummy_generator.rb, line 50
def test_dummy_frontend
  if defined?(MnoEnterprise::Frontend)
    create_file("#{dummy_path}/app/assets/stylesheets/main.less", force: true)
  end
end

Protected Instance Methods

application_definition() click to toggle source
# File lib/generators/mno_enterprise/dummy/dummy_generator.rb, line 84
def application_definition
  @application_definition ||= begin

    dummy_application_path = File.expand_path("#{dummy_path}/config/application.rb", destination_root)
    unless options[:pretend] || !File.exists?(dummy_application_path)
      contents = File.read(dummy_application_path)
      contents[(contents.index("module #{module_name}"))..-1]
    end
  end
end
dummy_path() click to toggle source
# File lib/generators/mno_enterprise/dummy/dummy_generator.rb, line 76
def dummy_path
  ENV['DUMMY_PATH'] || 'spec/dummy'
end
gemfile_path() click to toggle source
# File lib/generators/mno_enterprise/dummy/dummy_generator.rb, line 100
def gemfile_path
  '../../../../Gemfile'
end
module_name() click to toggle source
# File lib/generators/mno_enterprise/dummy/dummy_generator.rb, line 80
def module_name
  'Dummy'
end
remove_directory_if_exists(path) click to toggle source
# File lib/generators/mno_enterprise/dummy/dummy_generator.rb, line 96
def remove_directory_if_exists(path)
  remove_dir(path) if File.directory?(path)
end
store_application_definition!()