class Fanforce::PluginFactory::CLI::Pow include Fanforce::PluginFactory::CLI::Utils attr_reader :plugin def initialize(plugin) @plugin = plugin end def setup create_domain(plugin.root_domain) create_domain(Fanforce.default_short_domain) end def destroy destroy_domain(plugin.root_domain) destroy_domain(Fanforce.default_short_domain) end def remove_domain_extension(domain) domain.gsub(/\.[a-z]+$/, '') end def create_domain(root_domain) domain = "#{plugin._id}.#{root_domain.gsub(/\.([a-z]+)$/, '')}" domain_extension = $1 symlink = "#{ENV['HOME']}/.pow/#{domain}" File.delete(symlink) if File.exists?(symlink) or File.symlink?(symlink) `ln -s #{plugin.dir} #{symlink}` puts "#{'Connected'.format(:bold,:green)} #{domain}.#{domain_extension} to #{plugin.dir}/" end def destroy_domain(root_domain) domain = "#{plugin._id}.#{root_domain.gsub(/\.([a-z]+)$/, '')}" domain_extension = $1 symlink = "#{ENV['HOME']}/.pow/#{domain}" if File.exists?(symlink) File.delete(symlink) puts "#{'Removed'.format(:bold,:green)} #{domain}.#{domain_extension}" else puts "#{'Already Removed'.format(:bold,:green)} #{domain}.#{domain_extension} to #{plugin.dir}/" end end end