class Ember::Generators::BootstrapGenerator

Public Instance Methods

create_adapter_file() click to toggle source
# File lib/generators/ember/bootstrap_generator.rb, line 44
def create_adapter_file
  template "application_adapter.#{engine_extension}", "#{ember_path}/adapters/application.#{engine_extension}"
end
create_app_file() click to toggle source
# File lib/generators/ember/bootstrap_generator.rb, line 36
def create_app_file
  template "app.#{engine_extension}", "#{ember_path}/#{application_name.underscore.dasherize}.#{engine_extension}"
end
create_dir_layout() click to toggle source
# File lib/generators/ember/bootstrap_generator.rb, line 29
def create_dir_layout
  ember_prefix_dirs.each do |dir|
    empty_directory "#{ember_path}/#{dir}"
    create_file "#{ember_path}/#{dir}/.gitkeep" unless options[:skip_git]
  end
end
create_env_file() click to toggle source
# File lib/generators/ember/bootstrap_generator.rb, line 48
def create_env_file
  template "environment.#{engine_extension}", "#{ember_path}/environment.#{engine_extension}"
end
create_router_file() click to toggle source
# File lib/generators/ember/bootstrap_generator.rb, line 40
def create_router_file
  template "router.#{engine_extension}", "#{ember_path}/router.#{engine_extension}"
end
inject_ember() click to toggle source
# File lib/generators/ember/bootstrap_generator.rb, line 17
def inject_ember
  begin
    if javascript_engine == 'es6'
      inject_into_application_file('es6') # Don't use `.module.es6`.
    else
      inject_into_application_file(engine_extension)
    end
  rescue Exception
    inject_into_application_file('js')
  end
end

Private Instance Methods

ember_prefix_dirs() click to toggle source
# File lib/generators/ember/bootstrap_generator.rb, line 82
def ember_prefix_dirs
  dirs =
    if configuration
      Array(configuration.prefix_dirs)
    else
      %w(models controllers views routes components helpers mixins serializers adapters transforms)
    end

  dirs + %w(templates templates/components)
end
get_options_from_contents(contents) click to toggle source
# File lib/generators/ember/bootstrap_generator.rb, line 71
def get_options_from_contents(contents)
  regex = /^.*require_tree.*$/
  return {:before => regex} if contents =~ regex

  regex = /^\s*$/
  return {:before => regex} if contents =~ regex

  regex = /\z/
  {:after => regex}
end
inject_into_application_file(safe_extension) click to toggle source
# File lib/generators/ember/bootstrap_generator.rb, line 54
def inject_into_application_file(safe_extension)
  application_file = "application.#{safe_extension}"
  full_path = Pathname.new(destination_root).join(ember_path, application_file)

  if full_path.exist?
    injection_options = get_options_from_contents(full_path.read)

    inject_into_file(full_path.to_s, injection_options) do
      context = instance_eval('binding')
      source  = File.expand_path(find_in_source_paths(application_file))
      ERB.new(::File.binread(source), nil, '-', '@output_buffer').result(context)
    end
  else
    template application_file, full_path
  end
end