Class: CoffeescriptGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- CoffeescriptGenerator
- Defined in:
- lib/generators/coffeescript/coffeescript_generator.rb
Instance Attribute Summary collapse
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
Instance Method Summary collapse
- #copy_template_file ⇒ Object
- #file_path ⇒ Object private
- #function_name ⇒ Object private
- #namespace_path ⇒ Object private
- #singular_name ⇒ Object private
Instance Attribute Details
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
11 12 13 |
# File 'lib/generators/coffeescript/coffeescript_generator.rb', line 11 def namespace @namespace end |
Instance Method Details
#copy_template_file ⇒ Object
13 14 15 16 17 18 |
# File 'lib/generators/coffeescript/coffeescript_generator.rb', line 13 def copy_template_file @namespace = class_name.split("::") @namespace.pop @namespace = @namespace.join("::") template "coffeescript.coffee.erb", file_path end |
#file_path ⇒ Object (private)
26 27 28 |
# File 'lib/generators/coffeescript/coffeescript_generator.rb', line 26 def file_path Rails.root.join("app/javascript/packs", namespace_path, "#{file_name}.coffee") end |
#function_name ⇒ Object (private)
22 23 24 |
# File 'lib/generators/coffeescript/coffeescript_generator.rb', line 22 def function_name file_name.camelize(:lower) end |
#namespace_path ⇒ Object (private)
30 31 32 33 34 35 36 |
# File 'lib/generators/coffeescript/coffeescript_generator.rb', line 30 def namespace_path if namespace.blank? return "" else namespace.split("::").map(&:underscore).join("/") + "/" end end |
#singular_name ⇒ Object (private)
38 39 40 |
# File 'lib/generators/coffeescript/coffeescript_generator.rb', line 38 def singular_name super.singularize end |