Sha256: 7b81c9f40baa266816cf196fbe2844d7a6b630d35f69fe064a49441fc3b078d6

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

namespace :website do
  namespace :capfile do
    DESTINATION = "Capfile"
    
    task(:default) { show }
    
    desc <<-DESC
      Display the content of latest Capfile without downloading it.
    DESC
    task :show do
      site = website.fetch_current
      puts_title "Capfile for site: #{site}"
      puts site.get("/capfile.rb")
    end
    
    desc <<-DESC
      Download the latest Capfile for the current website.
    DESC
    task :download do
      if File.exist?(DESTINATION) && !File.read(DESTINATION).blank?
        puts_title "Backing up previous Capfile"
        backup = Dir.tmpdir + "/#{File.basename DESTINATION}.#{Time.now.to_f}"
        FileUtils.mv(DESTINATION, backup)
        puts "Backup location: #{backup}"
      end
      puts_title "Downloading latest Capfile"
      begin
        File.open(DESTINATION, "w") do |f|
          f.puts website.fetch_current!.get("/capfile.rb")
        end
        puts "Downloaded: %.2f KB" % [File.size(DESTINATION) / 1024.0]
      rescue WebService::ResourceNotFound
        puts "(No Capfile for the application type of the website.)"
      end
    end
    
    def downloaded?
      File.file?(DESTINATION)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Flucti-flucti-cli-0.1.16 lib/flucti/tasks/website/capfile_tasks.rb