Sha256: 413e9785a8e535a236bfd29d5b73a47b98022c2da858fe21afb0f48b7a557d3c

Contents?: true

Size: 1.26 KB

Versions: 12

Compression:

Stored size: 1.26 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

    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 & 1 rubygems

Version Path
linner-0.8.7 lib/linner/environment.rb
linner-0.8.6 lib/linner/environment.rb
linner-0.8.5 lib/linner/environment.rb
linner-0.8.4 lib/linner/environment.rb
linner-0.8.3 lib/linner/environment.rb
linner-0.8.2 lib/linner/environment.rb
linner-0.8.1 lib/linner/environment.rb
linner-0.8.0 lib/linner/environment.rb
linner-0.7.3 lib/linner/environment.rb
linner-0.7.2 lib/linner/environment.rb
linner-0.7.1 lib/linner/environment.rb
linner-0.7.0 lib/linner/environment.rb