module Ember::Generators::GeneratorHelpers

Public Instance Methods

application_name() click to toggle source
# File lib/generators/ember/generator_helpers.rb, line 26
def application_name
  if options[:app_name]
    options[:app_name]
  elsif rails_engine?
    engine_name
  elsif configuration.app_name
    configuration.app_name
  elsif defined?(::Rails) && ::Rails.application
    ::Rails.application.class.name.split('::').first
  else
    'App'
  end
end
class_name() click to toggle source
# File lib/generators/ember/generator_helpers.rb, line 40
def class_name
  (class_path + [file_name]).map!(&:camelize).join
end
configuration() click to toggle source
# File lib/generators/ember/generator_helpers.rb, line 71
def configuration
  ::Rails.configuration.ember if defined?(::Rails) && ::Rails.configuration
end
ember_path() click to toggle source
# File lib/generators/ember/generator_helpers.rb, line 6
def ember_path
  if options[:ember_path]
    options[:ember_path]
  elsif rails_engine?
    "app/assets/javascripts/#{engine_name}"
  elsif configuration.ember_path
    configuration.ember_path
  else
    'app/assets/javascripts'
  end
end
engine_extension() click to toggle source
# File lib/generators/ember/generator_helpers.rb, line 48
def engine_extension
  @engine_extension ||= begin
    extension_table = {
      'js' => 'js',
      'coffee' => 'coffee',
      'em' => 'em',
      'es6' => 'module.es6'
    }

    extension = extension_table[javascript_engine]

    if extension.nil?
      raise "Unsupported javascript engine: `#{javascript_engine}` (Supported engines are: [#{extension_table.keys.join(', ')}])"
    end

    extension
  end
end
engine_name() click to toggle source
# File lib/generators/ember/generator_helpers.rb, line 22
def engine_name
  ENGINE_PATH.split('/')[-2]
end
handlebars_template_path() click to toggle source
# File lib/generators/ember/generator_helpers.rb, line 44
def handlebars_template_path
  File.join(class_path, file_name).gsub(%r{^/}, '')
end
javascript_engine() click to toggle source
# File lib/generators/ember/generator_helpers.rb, line 67
def javascript_engine
  options[:javascript_engine].to_s
end
rails_engine?() click to toggle source
# File lib/generators/ember/generator_helpers.rb, line 18
def rails_engine?
  defined?(ENGINE_PATH)
end