Class: Dragon::Deploy

Inherits:
Object
  • Object
show all
Defined in:
lib/dragon/deploy.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Deploy

Returns a new instance of Deploy.



4
5
6
7
8
# File 'lib/dragon/deploy.rb', line 4

def initialize(options)
   @options = options
   @boxes = Dragon::ServerSet.new @options
   @comrun = Dragon::CommandRunner.new @boxes.set
end

Instance Method Details

#default_commands(sequence) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dragon/deploy.rb', line 10

def default_commands sequence
   return {} if @options.local_settings.has_key?( "commands_run_default" )
   {
      use_git: [{
         git: "clone --depth=1 --branch=#{ @options.local_settings["git_branch"] } #{ @options.local_settings["git_url"] } #{ @options.release_dir }",
      }],
      local_upload: [{
         dir_upload: "#{ @options.local_settings["local_upload_dir"] }",
      }],
      current_linking: [{
         ln: "-nfs #{ @options.release_dir } #{ @options.local_settings["destination_symlink"] }",
      }]
   }[sequence]
end

#runObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/dragon/deploy.rb', line 25

def run

   # before
   unless @options.local_settings.has_key?( "local_upload_dir" )
      @comrun.run default_commands( :use_git )
   else
      @comrun.run default_commands( :local_upload )
   end

   # user commands
   @comrun.run @options.local_settings["commands"] if @options.local_settings.has_key?( "commands" )

   # after
   @comrun.run default_commands( :current_linking )

end