Class: Ploy::Command::Client

Inherits:
Base
  • Object
show all
Defined in:
lib/ploy/command/client.rb

Instance Method Summary collapse

Instance Method Details

#helpObject



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/ploy/command/client.rb', line 37

def help
  return "usage: ploy client OPTS\n\n\#{optparser}\n\nExamples:\n\n    $ ploy client -f set.yml -d foo -d bar\n    $ ploy client -b bucket -n this/that/set.yml -d foo -d bar\n    $ ploy client -u http://example.com/set.yml -d foo -d bar\n\n  All of those examples will try to install the same packages, but use\n  different sources for configuration. The first uses a file, the second\n  uses S3, and the third uses a web service.\n\nSummary:\n\n  The client command is like an \"install\" command that uses external\n  configuration instead of command-line options. It can use a file,\n  or talk to S3 or a web service.\n\n"
end

#installable_packages(target_packages, packages) ⇒ Object



62
63
64
65
66
# File 'lib/ploy/command/client.rb', line 62

def installable_packages(target_packages, packages)
  tph = {}
  target_packages.each { |tp| tph[tp] = true }
  installables = packages.find_all { |p| tph[p.deploy_name] && p.deployvia == 'ploy-install' }
end

#run(argv) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ploy/command/client.rb', line 9

def run(argv)
  o = {
    :target_packages => []
  }
  optparser(o).parse!(argv)
  conf = conf_from_opts(o)
  
  if conf then
    ps = Ploy::PackageSet.new(conf)
    if ps.locked?
      puts "locked. taking no action."
    else
      ips = installable_packages(o[:target_packages], ps.packages)
      ips.each do |package|
        if package.check_new_version then
          package.install
          puts "installed #{package.deploy_name}"
        else
          puts "no new #{package.deploy_name} available"
        end
      end
    end
  else
    puts "error reading conf"
    help()
  end
end