Class: Rugular::GeneratorBase
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Rugular::GeneratorBase
- Includes:
- Thor::Actions
- Defined in:
- lib/rugular/tasks/generate/generator_base.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_sass_declaration ⇒ Object
- #create_route_folders ⇒ Object
- #inject_module_into_module ⇒ Object
- #template_files ⇒ Object
Class Method Details
.source_root ⇒ Object
16 17 18 |
# File 'lib/rugular/tasks/generate/generator_base.rb', line 16 def self.source_root __dir__.chomp('/tasks/generate') end |
Instance Method Details
#add_sass_declaration ⇒ Object
50 51 52 53 54 55 |
# File 'lib/rugular/tasks/generate/generator_base.rb', line 50 def add_sass_declaration append_to_file( 'src/application.sass', "@import '#{folder.sub('src/', '')}'" ) unless sass_declaration_present?(folder) end |
#create_route_folders ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rugular/tasks/generate/generator_base.rb', line 20 def create_route_folders route_pathnames.each do |pathname| next( "#{destination_file(pathname)} already exists" ) if File.exists? destination_file(pathname) create_file destination_file(pathname) do ERB.new(pathname.read).result( open_struct.instance_eval { binding } ) end end end |
#inject_module_into_module ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rugular/tasks/generate/generator_base.rb', line 34 def inject_module_into_module if nested? insert_into_file( nested_module_file, module_declaration, after: "angular.module '#{nested_module_name}', [\n" ) unless module_declaration_present?(nested_module_file) else insert_into_file( app_module_file, module_declaration, after: "angular.module 'app', [\n" ) unless module_declaration_present?(app_module_file) end end |
#template_files ⇒ Object
57 |
# File 'lib/rugular/tasks/generate/generator_base.rb', line 57 def template_files; []; end |