Sha256: 03e67f4274531f736fa296b6233800d957120c049a5108a6c865ad9baf6ee8d2

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

require "yaml"

module Linner
  class Environment

    def initialize(path)
      @env ||= (YAML::load(File.read path) || Hash.new)
      @convension = YAML::load File.read(File.join File.dirname(__FILE__), "../../vendor", "config.default.yml")
      @env = @convension.rmerge!(@env)
    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
linner-0.6.1 lib/linner/environment.rb
linner-0.6.0 lib/linner/environment.rb