Class: Cynq::Command

Inherits:
Thor
  • Object
show all
Defined in:
lib/cynq/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#local_dirObject (readonly)

Returns the value of attribute local_dir.



20
21
22
# File 'lib/cynq/command.rb', line 20

def local_dir
  @local_dir
end

#remote_dirObject (readonly)

Returns the value of attribute remote_dir.



20
21
22
# File 'lib/cynq/command.rb', line 20

def remote_dir
  @remote_dir
end

Instance Method Details

#deploy(remote) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/cynq/command.rb', line 23

def deploy(remote)
  load_config(remote)

  if options.dry_run?
    puts "  Dry run executing...".green
  end

  establish_roots

  all_keys.each do |key|
    case
    when local_dir.missing?(key)
      puts "  deleting #{key}".red
      remote_dir.delete(key) unless options.dry_run?
    when remote_dir.missing?(key)
      puts "    adding #{key} #{local_dir[key].content_type}".green
      remote_dir << local_dir[key] unless options.dry_run?
    when remote_dir.modified?(local_dir[key])
      puts "  modified #{key}".magenta
      remote_dir << local_dir[key] unless options.dry_run?
    when !remote_dir.meta_equal?(local_dir[key])
      puts "      meta #{key} #{local_dir[key].content_type}".white.on_magenta
      remote_dir << local_dir[key] unless options.dry_run?
    else
      puts " unchanged #{key}" unless options.dry_run?
    end
  end
end