From fc53a5acf43649c2e0aa96502ba7eb03c5a0ab75 Mon Sep 17 00:00:00 2001 From: Sean Grove Date: Wed, 23 Mar 2011 01:27:22 -0700 Subject: [PATCH] Update to the new version of bushido gem --- lib/locomotive.rb | 2 +- lib/locomotive/bushido.rb | 41 +++++++++++++++++++------ lib/locomotive/bushido/custom_domain.rb | 2 +- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/lib/locomotive.rb b/lib/locomotive.rb index ef91c690..7cfca9f0 100644 --- a/lib/locomotive.rb +++ b/lib/locomotive.rb @@ -25,7 +25,7 @@ require 'locomotive/session_store' module Locomotive include Locomotive::Heroku - include Locomotive::Bushido + include Locomotive::BushidoSupport class << self attr_accessor :config diff --git a/lib/locomotive/bushido.rb b/lib/locomotive/bushido.rb index aa59df7f..85fa69e3 100644 --- a/lib/locomotive/bushido.rb +++ b/lib/locomotive/bushido.rb @@ -2,13 +2,16 @@ require 'bushido' require 'locomotive/bushido/custom_domain' module Locomotive - module Bushido + module BushidoSupport extend ActiveSupport::Concern included do - class << self - attr_accessor :bushido_domains + class << self + attr_accessor :bushido_domains + attr_accessor :bushido_subdomain + + puts @bushido_domains end end @@ -18,29 +21,49 @@ module Locomotive ENV["HOSTING_PLATFORM"] == "bushido" end + def enable_bushido self.enhance_site_model + + self.bushido_domains = Bushido::App.domains + self.bushido_subdomain = Bushido::App.subdomain end + def enhance_site_model - Site.send :include, Locomotive::Bushido::CustomDomain + Site.send :include, Locomotive::BushidoSupport::CustomDomain end # manage domains def add_bushido_domain(name) Locomotive.logger "[add bushido domain] #{name}" - Bushido::Domains.add_subdomain(name) - self.bushido_domains << name + Bushido::App.add_domain(name) + + if Bushido::Command.last_command_successful? + self.bushido_domains << name + end end + def remove_bushido_domain(name) Locomotive.logger "[remove bushido domain] #{name}" - Bushido::Domains.remove_subdomain(name) - self.bushido_domains.delete(name) + Bushido::App.remove_domain(name) + + if Bushido::Command.last_command_successful? + self.bushido_domains.delete(name) + end end - end + def set_bushido_subdomain(name) + Locomotive.logger "[set bushido subdomain] #{name}.bushi.do" + Bushido::App.set_subdomain(name) + + if Bushido::Command.last_command_successful? + self.bushido_subdomain = name + end + end + end end end diff --git a/lib/locomotive/bushido/custom_domain.rb b/lib/locomotive/bushido/custom_domain.rb index 5d399e41..d93f6808 100644 --- a/lib/locomotive/bushido/custom_domain.rb +++ b/lib/locomotive/bushido/custom_domain.rb @@ -1,5 +1,5 @@ module Locomotive - module Bushido + module BushidoSupport module CustomDomain extend ActiveSupport::Concern