Module: Ember::Generators::GeneratorHelpers
- Included in:
- AdapterGenerator, BootstrapGenerator, ComponentGenerator, ControllerGenerator, InitializerGenerator, InstanceInitializerGenerator, ModelGenerator, ResourceGenerator, RouteGenerator, ServiceGenerator, TemplateGenerator, ViewGenerator
- Defined in:
- lib/generators/ember/generator_helpers.rb
Instance Method Summary collapse
- #application_name ⇒ Object
- #class_name ⇒ Object
- #configuration ⇒ Object
- #ember_path ⇒ Object
- #engine_extension ⇒ Object
- #engine_name ⇒ Object
- #handlebars_template_path ⇒ Object
- #javascript_engine ⇒ Object
- #rails_engine? ⇒ Boolean
Instance Method Details
#application_name ⇒ Object
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 [:app_name] [: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 ⇒ Object
40 41 42 |
# File 'lib/generators/ember/generator_helpers.rb', line 40 def class_name (class_path + [file_name]).map!(&:camelize).join end |
#configuration ⇒ Object
71 72 73 |
# File 'lib/generators/ember/generator_helpers.rb', line 71 def configuration ::Rails.configuration.ember if defined?(::Rails) && ::Rails.configuration end |
#ember_path ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/generators/ember/generator_helpers.rb', line 6 def ember_path if [:ember_path] [: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 ⇒ Object
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_name ⇒ Object
22 23 24 |
# File 'lib/generators/ember/generator_helpers.rb', line 22 def engine_name ENGINE_PATH.split('/')[-2] end |
#handlebars_template_path ⇒ Object
44 45 46 |
# File 'lib/generators/ember/generator_helpers.rb', line 44 def File.join(class_path, file_name).gsub(%r{^/}, '') end |
#javascript_engine ⇒ Object
67 68 69 |
# File 'lib/generators/ember/generator_helpers.rb', line 67 def javascript_engine [:javascript_engine].to_s end |
#rails_engine? ⇒ Boolean
18 19 20 |
# File 'lib/generators/ember/generator_helpers.rb', line 18 def rails_engine? defined?(ENGINE_PATH) end |