Sha256: 2891992c24c2ed981b2419ee1104d96566b01d9ad5a9825f87eb1e3e1c122960

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 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.exists? path
      end
    end

    %w(revision notification manifest).each do |method|
      define_method("#{method}") do
        @env[method]
      end
    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

    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

6 entries across 6 versions & 1 rubygems

Version Path
linner-0.6.7 lib/linner/environment.rb
linner-0.6.6 lib/linner/environment.rb
linner-0.6.5 lib/linner/environment.rb
linner-0.6.4 lib/linner/environment.rb
linner-0.6.3 lib/linner/environment.rb
linner-0.6.2 lib/linner/environment.rb