class Snaptoken::Commands::Deploy

Public Class Methods

name() click to toggle source
# File lib/snaptoken/commands/deploy.rb, line 2
def self.name
  "deploy"
end
summary() click to toggle source
# File lib/snaptoken/commands/deploy.rb, line 6
def self.summary
  "Push output files in doc/html_out/ to\n" +
  "production server (requires ftp.yml)."
end
usage() click to toggle source
# File lib/snaptoken/commands/deploy.rb, line 11
def self.usage
  "[pattern...]"
end

Public Instance Methods

run() click to toggle source
# File lib/snaptoken/commands/deploy.rb, line 18
def run
  needs! :config, :doc, :doc_out, :ftp

  only = @args.empty? ? nil : @args

  FileUtils.cd(File.join(@config[:path], "doc/html_out")) do
    ftp_config = YAML.load(File.read(File.join(@config[:path], "ftp.yml")))
    Net::FTP.open(ftp_config[:host], ftp_config[:username], ftp_config[:password]) do |ftp|
      ftp.chdir(ftp_config[:root])
      Dir["**/*"].each do |f|
        if only.nil? || only.any? { |o| f[o] }
          puts f
          if File.directory?(f)
            ftp.mkdir(f) rescue Net::FTPPermError
          elsif File.file?(f)
            ftp.putbinaryfile(f, f)
          end
        end
      end
    end
  end
end
setopts!(o) click to toggle source
# File lib/snaptoken/commands/deploy.rb, line 15
def setopts!(o)
end