Module: Ember::Generators::GeneratorHelpers

Instance Method Summary collapse

Instance Method Details

#application_nameObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# 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_nameObject



40
41
42
# File 'lib/generators/ember/generator_helpers.rb', line 40

def class_name
  (class_path + [file_name]).map!(&:camelize).join
end

#configurationObject



71
72
73
# File 'lib/generators/ember/generator_helpers.rb', line 71

def configuration
  ::Rails.configuration.ember if defined?(::Rails) && ::Rails.configuration
end

#ember_pathObject



6
7
8
9
10
11
12
13
14
15
16
# 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_extensionObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# 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_nameObject



22
23
24
# File 'lib/generators/ember/generator_helpers.rb', line 22

def engine_name
  ENGINE_PATH.split('/')[-2]
end

#handlebars_template_pathObject



44
45
46
# File 'lib/generators/ember/generator_helpers.rb', line 44

def handlebars_template_path
  File.join(class_path, file_name).gsub(%r{^/}, '')
end

#javascript_engineObject



67
68
69
# File 'lib/generators/ember/generator_helpers.rb', line 67

def javascript_engine
  options[:javascript_engine].to_s
end

#rails_engine?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/generators/ember/generator_helpers.rb', line 18

def rails_engine?
  defined?(ENGINE_PATH)
end