Class: DaemonGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/daemon_generator.rb

Instance Method Summary collapse

Instance Method Details

#generate_daemonObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/generators/daemon_generator.rb', line 8

def generate_daemon
  daemons_dir = Daemons::Rails.configuration.daemons_directory

  unless File.exist?(Rails.root.join(daemons_dir, 'daemons'))
    copy_file "daemons", daemons_dir.join('daemons')
    chmod daemons_dir.join('daemons'), 0755
  end

  template "script.rb", daemons_dir.join("#{file_name}.rb")
  chmod daemons_dir.join("#{file_name}.rb"), 0755

  template "script_ctl", daemons_dir.join("#{file_name}_ctl")
  chmod daemons_dir.join("#{file_name}_ctl"), 0755

  unless File.exist?(Rails.root.join("config", "daemons.yml"))
    copy_file "daemons.yml", "config/daemons.yml"
  end
end