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



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

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}/"

   say cmd, :green if options[:verbose]

   system cmd

   say "Assets sync complete", :green
end

#pushObject



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
61
62
# File 'lib/karo/assets.rb', line 35

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 options[:verbose]
     say cmd_1, :green
     say cmd_2, :green
   end

   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