class Disco::Generators::AppGenerator

Public Class Methods

banner() click to toggle source

Public Instance Methods

add_event_source_route() click to toggle source
# File lib/generators/disco/app/app_generator.rb, line 78
def add_event_source_route
  return if behavior == :revoke
  route "get 'event_source/:projection/:event' => 'event_source#projected', as: 'event_source'"
end
enable_concurrency() click to toggle source
# File lib/generators/disco/app/app_generator.rb, line 94
def enable_concurrency
  return if behavior == :revoke
  application 'config.preload_frameworks = true'
  application 'config.allow_concurrency = true'
rescue
  puts "Seems like you invoked it from an engine, so remember to put\n
  config.preload_frameworks = true
  config.allow_concurrency = true\n
  in your application.rb from the main application"
end
enable_rake_tasks() click to toggle source
# File lib/generators/disco/app/app_generator.rb, line 83
      def enable_rake_tasks
        return if behavior == :revoke
        content = "
require 'rails-disco/tasks'"
        inject_into_file File.join('config/application.rb'), content, after: /require 'rails\/all'/
      rescue
        puts "Seems like you invoked it from an engine, so put\n
        require 'rails-disco/tasks'\n
        in your application.rb from the main application to have the rails disco rake tasks available"
      end
source_paths() click to toggle source
# File lib/generators/disco/app/app_generator.rb, line 71
def source_paths
  [
    File.join(Gem::Specification.find_by_name('railties').gem_dir, 'lib/rails/generators/rails/app/templates'),
    File.expand_path('../templates', __FILE__),
  ]
end

Private Instance Methods

domain_database(env, indent_level) click to toggle source
# File lib/generators/disco/app/app_generator.rb, line 117
def domain_database(env, indent_level)
  config = YAML.load(File.read('config/database.yml'))[env.to_s]
  config['database'].sub!(/.*#{env}/, '\0_domain')
  indent(({'domain_database' => config}.to_yaml(indentation: 2))[4..-1], indent_level)
end
get_builder_class() click to toggle source
# File lib/generators/disco/app/app_generator.rb, line 113
def get_builder_class
  defined?(::AppBuilder) ? ::AppBuilder : Disco::AppBuilder
end
indent(content, multiplier = 2) click to toggle source
# File lib/generators/disco/app/app_generator.rb, line 130
def indent(content, multiplier = 2)
  spaces = ' ' * multiplier
  content.each_line.map { |line| line.blank? ? line : "#{spaces}#{line}" }.join
end
module_namespacing(&block) click to toggle source

copied namespace support from NamedBase

# File lib/generators/disco/app/app_generator.rb, line 124
def module_namespacing(&block)
  content = capture(&block)
  content = wrap_with_namespace(content) if namespace
  concat(content)
end
namespace() click to toggle source
# File lib/generators/disco/app/app_generator.rb, line 140
def namespace
  Rails::Generators.namespace
end
wrap_with_namespace(content) click to toggle source
# File lib/generators/disco/app/app_generator.rb, line 135
def wrap_with_namespace(content)
  content = indent(content).chomp
  "module #{namespace.name}\n#{content}\nend\n"
end