Class: Sumodev::Generators::Fork::V3

Inherits:
Sumodev::Generator show all
Includes:
General::Capistrano
Defined in:
lib/sumodev/generators/fork/v3.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from General::Capistrano

#generate_capfile

Methods included from Actions

#copy_dest_file, #git, #git_track, #replace_in_file

Instance Attribute Details

#destination_dirObject

Returns the value of attribute destination_dir.



15
16
17
# File 'lib/sumodev/generators/fork/v3.rb', line 15

def destination_dir
  @destination_dir
end

Instance Method Details

#checkout_forkObject



23
24
25
26
27
# File 'lib/sumodev/generators/fork/v3.rb', line 23

def checkout_fork
  git :clone    => "#{options[:fork_repository]} ."
  git :checkout => "origin/#{options[:branch]}"
  FileUtils.rm_rf '.git'
end

#create_rootObject



17
18
19
20
21
# File 'lib/sumodev/generators/fork/v3.rb', line 17

def create_root
  self.destination_root = self.destination_dir = Pathname.pwd + client + name
  FileUtils.mkdir_p destination_dir
  FileUtils.chdir   destination_dir
end

#initialize_repoObject



29
30
31
32
# File 'lib/sumodev/generators/fork/v3.rb', line 29

def initialize_repo
  git :init
  git_track 'Initial commit'
end

#setup_globalsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/sumodev/generators/fork/v3.rb', line 34

def setup_globals
  git_track 'Setting up globals' do
    copy_dest_file 'library/globals.base.php', 'library/globals.php'
    copy_dest_file 'library/globals_frontend.base.php', 'library/globals_frontend.php'
    copy_dest_file 'library/globals_backend.base.php', 'library/globals_backend.php'

    replace_in_file 'library/globals.php', {
      "'<debug-mode>'"         => 'true',
      "<spoon-debug-email>"    => '[email protected]',
      "<database-name>"        => name,
      "<database-hostname>"    => 'localhost',
      "<database-port>"        => '3306',
      "<database-username>"    => config[:db][:username],
      "<database-password>"    => config[:db][:password],
      "<site-domain>"          => "#{name}.#{client}.dev",
      "'<site-multilanguage>'" => options[:multilanguage].to_s,
      "<action-group-tag>"     => '@actiongroup',
      "<action-rights-level>"  => 7,
      "<path-www>"             => destination_dir + "default_www",
      "<path-library>"         => destination_dir + "library"
    }

    replace_in_file 'library/globals_frontend.php', {
      '<site-default-language>' => options[:default_language]
    }
  end
end