Sha256: 7c0369b40a358f66a7f267c38693ea8d1a8745af979b6f769e4e3b191268d182

Contents?: true

Size: 1.46 KB

Versions: 12

Compression:

Stored size: 1.46 KB

Contents

require "yaml"

module Linner
  class Environment

    def initialize(path)
      @env ||= (YAML::load(File.read path) || Hash.new)
      merge_with_convension
    end

    %w(app test vendor public).each do |method|
      define_method("#{method}_folder") do
        @env["paths"][method]
      end
    end

    def paths
      groups.map { |group| group["paths"] }.flatten.uniq
    end

    def watched_paths
      [app_folder, vendor_folder, test_folder].select do |path|
        File.exist? path
      end
    end

    %w(revision notification).each do |method|
      define_method("#{method}") do
        @env[method]
      end
    end

    def manifest
      revision["manifest"]
    end

    def bundles
      @env["bundles"] || []
    end

    def sprites
      @env["sprites"] || {}
    end

    def modules_ignored
      Dir.glob(@env["modules"]["ignored"])
    end

    def wrapper
      @env["modules"]["wrapper"]
    end

    def definition
      File.join public_folder, @env["modules"]["definition"]
    end

    def groups
      @env["groups"].values
    end

    def environments
      @env["environments"] || {}
    end

    def merge_with_environment(environment)
      return @env unless picked = environments[environment]
      @env = @env.rmerge!(picked)
    end

    private
    def merge_with_convension
      convension = YAML::load File.read(File.join File.dirname(__FILE__), "../../vendor", "config.default.yml")
      @env = convension.rmerge!(@env)
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
linner-hc-1.0.0 lib/linner/environment.rb
linner-0.12.0 lib/linner/environment.rb
linner-0.11.6 lib/linner/environment.rb
linner-0.11.5 lib/linner/environment.rb
linner-0.11.4 lib/linner/environment.rb
linner-0.11.3 lib/linner/environment.rb
linner-0.11.2 lib/linner/environment.rb
linner-0.11.1 lib/linner/environment.rb
linner-0.11.0 lib/linner/environment.rb
linner-0.10.0 lib/linner/environment.rb
linner-0.9.1 lib/linner/environment.rb
linner-0.9.0 lib/linner/environment.rb