Sha256: 6deceb382f0f5f40d929419985917e9d07fe7a09573071cc1845d2702533a390

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

module Citrin
  class App
    def initialize(name, env="prod")
      @name = name
      @env = env
      @env ||= "prod"
    end

    def name
      @name
    end

    def env
      @env
    end

    def fullenv
      case(@env)
        when "prod"
          return "production"
        when "dev"
          return "development"
        when "test"
          return "test"
      else
        raise "Invalid Environment"
      end
    end

    def app_root
      "/var/www/rails_apps/#{@env}/#{@name}"
    end

    def url
      if @env == "dev"
        "dev.#{@name}.#{`hostname -f`}"
      elsif @env == "prod"
        "#{@name}.#{`hostname -f`}"
      else
        raise "Invalid Environment"
      end
    end

    def webserver_link_file
      "/etc/apache2/sites-enabled/#{@env}.#{@name}.conf"
    end

    def webserver_config_file
      "/etc/apache2/sites-available/#{@env}.#{@name}.conf"
    end

    def db_name
      "#{@name}_#{@env}"
    end

    def db_user
      "#{@name}_#{@env}"
    end

    def db_pass
      @db_pass ||=`pwgen -1asc 22`.chomp
      @db_pass
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
citrin-0.1.7 lib/citrin/app.rb
citrin-0.1.6 lib/citrin/app.rb
citrin-0.1.5 lib/citrin/app.rb
citrin-0.1.4 lib/citrin/app.rb
citrin-0.1.3 lib/citrin/app.rb
citrin-0.1.2 lib/citrin/app.rb