class Ember::Generators::BootstrapGenerator

Public Instance Methods

create_adapter_file() click to toggle source
# File lib/generators/ember/bootstrap_generator.rb, line 41
def create_adapter_file
  template "application_adapter.#{engine_extension}", "#{ember_path}/adapters/application_adapter.#{engine_extension}"
end
create_app_file() click to toggle source
# File lib/generators/ember/bootstrap_generator.rb, line 33
def create_app_file
  template "app.#{engine_extension}", "#{ember_path}/#{application_name.underscore}.#{engine_extension}"
end
create_dir_layout() click to toggle source
# File lib/generators/ember/bootstrap_generator.rb, line 26
def create_dir_layout
  %W{models controllers views routes helpers components templates templates/components mixins adapters}.each do |dir|
    empty_directory "#{ember_path}/#{dir}"
    create_file "#{ember_path}/#{dir}/.gitkeep" unless options[:skip_git]
  end
end
create_router_file() click to toggle source
# File lib/generators/ember/bootstrap_generator.rb, line 37
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
    inject_into_application_file(engine_extension)
  rescue Exception => e
    inject_into_application_file('js')
  end
end

Private Instance Methods

get_options_from_contents(contents) click to toggle source
# File lib/generators/ember/bootstrap_generator.rb, line 64
def get_options_from_contents(contents)
  if contents =~ regex = /^.*require_tree.*$/
                          {:before => regex}
                        elsif contents =~ regex = /^\s*$/
                          {:before => regex}
                        else
                          regex = /\z/
                          {:after => regex}
                        end
end
inject_into_application_file(safe_extension) click to toggle source
# File lib/generators/ember/bootstrap_generator.rb, line 47
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