Class: Frank::Publish::SCP

Inherits:
Base
  • Object
show all
Defined in:
lib/frank/publish/scp.rb

Constant Summary

Constants included from Render

Render::LAYOUT_EXTS, Render::TMPL_EXTS

Instance Method Summary collapse

Methods inherited from Base

#call, #call!

Methods included from Render

#ext_from_handler, #layout_ext_or_first, #layout_for, #render, #setup_page, #tilt, #to_file_path

Methods included from TemplateHelpers

#capture, #content_for, #content_for?, #lorem, #refresh, #render_partial

Methods included from Rescue

#render_404, #render_500

Constructor Details

#initialize(options, &block) ⇒ SCP

Returns a new instance of SCP.



10
11
12
13
14
15
# File 'lib/frank/publish/scp.rb', line 10

def initialize(options, &block)
  super(options)
  instance_eval(&block) if block_given?

  @port ||= 22
end

Instance Method Details

#connectionObject



18
19
20
21
22
# File 'lib/frank/publish/scp.rb', line 18

def connection
  Net::SCP.start(hostname, username, :password => password) do |scp|
    yield scp
  end
end

#transfer!Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/frank/publish/scp.rb', line 24

def transfer!
  connection do |scp|
    old_name = ''
    scp.upload! local_path, remote_path do |ch, name|
      if old_name != name
        ok_message "Uploading #{name}", "    - "
      end
    end
  end
end