lib/capistrano/cloudflare.rb in capistrano-cloudflare-0.0.2 vs lib/capistrano/cloudflare.rb in capistrano-cloudflare-1.0.0

- old
+ new

@@ -1,9 +1,10 @@ require 'capistrano' require 'capistrano/cloudflare/version' require 'json' require 'net/http' +require 'rake' module Capistrano module CloudFlare def self.send_request(options = {}) uri = URI('https://www.cloudflare.com/api_json.html') @@ -18,32 +19,9 @@ :email => options[:email] }) response = JSON.parse(http.request(request).body) end - - def self.load_into(configuration) - configuration.set :capistrano_cloudflare, self - configuration.load do - namespace :cloudflare do - namespace :cache do - desc "Purge the CloudFlare cache" - task :purge do - raise unless fetch(:cloudflare_options).respond_to?(:[]) - response = capistrano_cloudflare.send_request(cloudflare_options) - if response['result'] == 'success' - logger.info("Purged CloudFlare cache for #{cloudflare_options[:domain]}") - else - logger.info("CloudFlare cache purge failed. Reason: #{response['msg'] || 'unknown.'}") - end - end - end - end - - end - end end end -if Capistrano::Configuration.instance - Capistrano::CloudFlare.load_into(Capistrano::Configuration.instance) -end +load File.expand_path('../tasks/cloudflare.rake', __FILE__)