Class: NafGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/naf_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_configuration_filesObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/generators/naf_generator.rb', line 9

def add_configuration_files
  filename = "naf.rb"
  filepath = "config/initializers/#{filename}"
  path = "#{Rails.root}/#{filepath}"
  if File.exists?(path)
    puts "Skipping #{filepath} creation, as file already exists!"
  else
    puts "Adding Naf initializer (#{filepath})..."
    template filename, path
  end
end

#add_layouts_fileObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/generators/naf_generator.rb', line 25

def add_layouts_file
  filename = "naf_layout.html.erb"
  filepath = "app/views/layouts/#{filename}"
  path = "#{Rails.root}/#{filepath}"
  if File.exists?(path)
    puts "Skipping #{filepath} creation, as file already exists!"
  else
    puts "Adding naf_layout (#{filepath})..."
    template filename, path
  end
end

#add_log4r_configuration_filesObject



21
22
23
# File 'lib/generators/naf_generator.rb', line 21

def add_log4r_configuration_files
  directory "config"
end

#mount_engineObject



37
38
39
40
41
42
# File 'lib/generators/naf_generator.rb', line 37

def mount_engine
  puts "Mounting Naf::Engine at \"/job_system\" in config/routes.rb..."
  insert_into_file("#{Rails.root}/config/routes.rb", after: /routes.draw.do\n/) do
    %Q{\n  mount Naf::Engine, at: "/job_system"\n}
  end
end