Sha256: 8dbe6a6fcdb75f8a8a713b9dcf271fd3945cd2deb8e289f9476edf3f3c3f597d

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'pushwagner/ext'
require 'pushwagner/maven'
require 'yaml'

module Pushwagner

  class Environment
    attr_reader :config
    attr_accessor :current, :version

    def initialize(opts = {})
      opts = HashWithIndifferentAccess.new(opts)

      config_file = opts[:config_file] || File.join(File.dirname(__FILE__), '/config/deploy.yml')
      @version = opts[:version] && opts[:version].to_s
      @current = opts[:environment] || 'development'

      @config = HashWithIndifferentAccess.new(YAML::load_file(config_file) || {})
    end

    def path_prefix
      config['path_prefix'] || '/srv/www'
    end

    def maven
      @maven = (config['maven'] ? Maven.new(config['maven'], version) : {})
    end

    def maven?
      maven.any?
    end

    def static
      config['static'] || {}
    end

    def static?
      static.any?
    end

    def environments
      config['environments'] || {}
    end

    def environment
      environments[current] || {}
    end

    def hosts
      environment['hosts'] || []
    end

    def user
      environment['user'] || "nobody"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pushwagner-0.0.1.2 lib/pushwagner/environment.rb