Class: Webbynode::Engines::Django

Inherits:
Object
  • Object
show all
Includes:
Engine
Defined in:
lib/webbynode/engines/django.rb

Instance Method Summary collapse

Methods included from Engine

included

Instance Method Details

#change_settings(settings) ⇒ Object



30
31
32
33
34
# File 'lib/webbynode/engines/django.rb', line 30

def change_settings(settings)
  settings.each_pair do |k,v|
    io.sed 'settings.template.py', /'#{k}': '[^ ,]*'/, "'#{k}': '#{v}'"
  end
end

#change_templatesObject



36
37
38
# File 'lib/webbynode/engines/django.rb', line 36

def change_templates
  io.sed 'settings.template.py', /TEMPLATE_DIRS = \(/, "TEMPLATE_DIRS = (\n    '@app_dir@/templates'"
end

#prepareObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/webbynode/engines/django.rb', line 7

def prepare
  unless io.file_exists?('settings.py')
    raise Webbynode::Command::CommandError, 
      "Couldn't create the settings template because settings.py was not found. Please check and try again."
  end
  
  unless io.file_exists?('settings.template.py')
    io.log 'Creating settings.template.py from your settings.py...'
    io.copy_file 'settings.py', 'settings.template.py'

    change_templates

    change_settings({
      'ENGINE' => '@app_engine@', 
      'NAME' => '@app_name@',                      
      'USER' => '@app_name@',                      
      'PASSWORD' => '@app_pwd@',                  
      'HOST' => '@db_host@',                      
      'PORT' => '@db_port@',
    })
  end
end