Class: Karo::Assets

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/karo/assets.rb

Instance Method Summary collapse

Instance Method Details

#pullObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/karo/assets.rb', line 15

def pull
  configuration = Config.load_configuration(options)

   path_local  = File.expand_path("public/system/dragonfly/development")
   empty_directory path_local unless File.exists?(path_local)

   path_server = File.join(configuration["path"], "shared/system/dragonfly/#{options[:environment]}")

  host = "deploy@#{configuration["host"]}"
  cmd  = "rsync -az --progress #{host}:#{path_server}/ #{path_local}/"

   system "#{cmd}"

   say "Assets sync complete", :green
end

#pushObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/karo/assets.rb', line 32

def push
   configuration = Config.load_configuration(options)

   path_local  = File.expand_path("public/system/dragonfly/development")
   unless File.exists?(path_local)
     raise Thor::Error, "Please make sure that this local path exists? '#{path_local}'"
   end

   host = "deploy@#{configuration["host"]}"

   path_server = File.join(configuration["path"], "shared/system/dragonfly/#{options[:environment]}")

   cmd_1  = "ssh #{host} 'mkdir -p #{path_server}'"
   cmd_2  = "rsync -az --progress #{path_local}/ #{host}:#{path_server}/"

   if yes?("Are you sure?", :yellow)
     system "#{cmd_1}"
     system "#{cmd_2}"
     say "Assets sync complete", :green
   else
     say "Assets sync cancelled", :yellow
   end
end