Sha256: 336f46a50a2c36fd56a0a054470afeaa7b93a8be9c423ae1eb42683fc708af4d

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

require 'digest/sha2'
require 'condenser/context'
require 'condenser/cache_store'
require 'condenser/cache/null_store'
require 'condenser/cache/memory_store'
require 'condenser/cache/file_store'

class Condenser
  module Environment
    
    attr_reader :path, :npm_path
    attr_accessor :cache, :build_cache
    
    def initialize(*args)
      @context_class = Class.new(Condenser::Context)
      super
    end

    def prepend_path(*paths)
      paths.flatten.each do |path|
        path = File.expand_path(path)
        raise ArgumentError, "Path \"#{path}\" does not exists" if !File.directory?(path)
        @path.unshift(path)
      end
    end
  
    def append_path(*paths)
      paths.flatten.each do |path|
        path = File.expand_path(path)
        raise ArgumentError, "Path \"#{path}\" does not exists" if !File.directory?(path)
        @path.push(path)
      end
    end

    def npm_path=(path)
      path = File.expand_path(path)
      raise ArgumentError, "Path \"#{path}\" does not exists" if !File.directory?(path)
      @npm_path = path
    end
  
    def append_npm_path(*paths)
      paths.flatten.each do |path|
        self.npm_path = path
      end
    end
  
    def clear_path
      @path.clear
    end
    
    def new_context_class
      context_class.new(self)
    end
    
    # This class maybe mutated and mixed in with custom helpers.
    #
    #     environment.context_class.instance_eval do
    #       include MyHelpers
    #       def asset_url; end
    #     end
    #
    attr_reader :context_class
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
condenser-0.0.8 lib/condenser/environment.rb
condenser-0.0.7 lib/condenser/environment.rb