Class: Pushwagner::Static::Deployer

Inherits:
Object
  • Object
show all
Defined in:
lib/pushwagner/static.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment, opts = {}) ⇒ Deployer

Returns a new instance of Deployer.



9
10
11
# File 'lib/pushwagner/static.rb', line 9

def initialize(environment, opts = {})
  @environment = environment
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



7
8
9
# File 'lib/pushwagner/static.rb', line 7

def environment
  @environment
end

Instance Method Details

#deployObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/pushwagner/static.rb', line 13

def deploy
  environment.static.each do |name, files|
    environment.hosts.each do |host|
      Net::SCP.start(host, environment.user) do |scp|
        puts "Uploading files to #{host}:#{environment.path_prefix}/#{name}/"
        files.each do |f|
          if File.exists?(f)
            scp.upload!(f, "#{environment.path_prefix}/#{name}/", :recursive => File.directory?(f))
          else
            puts "Warning: File #{f} does not exist"
          end
        end
      end
    end
  end
end