Sha256: b2a9f5db4d4769642205048a3a2e8a4719ab1f2e73ca2691f40d1249cd204acf

Contents?: true

Size: 1.21 KB

Versions: 31

Compression:

Stored size: 1.21 KB

Contents

class Fanforce::AppFactory::CLI::Pow
  include Fanforce::AppFactory::CLI::Utils

  attr_reader :app

  def initialize(app)
    @app = app
  end

  def setup
    create_domain(app.root_domain)
    create_domain(Fanforce.default_short_domain)
  end

  def destroy
    destroy_domain(app.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 = "#{app._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 #{app.dir} #{symlink}`
    puts "#{'Connected'.format(:bold,:green)} #{domain}.#{domain_extension} to #{app.dir}/"
  end

  def destroy_domain(root_domain)
    domain = "#{app._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 #{app.dir}/"
    end
  end

end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
fanforce-app-factory-2.0.0.rc38 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc37 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc36 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc35 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc34 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc33 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc32 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc31 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc30 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc29 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc27 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc26 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc25 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc24 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc23 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc22 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc21 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc20 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc19 lib/fanforce/app_factory/cli/lib/pow.rb
fanforce-app-factory-2.0.0.rc18 lib/fanforce/app_factory/cli/lib/pow.rb