Class: Rugular::GeneratorBase

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/rugular/tasks/generate/generator_base.rb

Direct Known Subclasses

Directive, Factory, Filter, Route

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



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

#create_route_foldersObject



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_moduleObject



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_filesObject



50
# File 'lib/rugular/tasks/generate/generator_base.rb', line 50

def template_files; []; end