Sha256: 4240c909bed3e8f6a5b2bbf4ea1769b4dcbef4056004ded9994a6bde3fd8535c

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 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
      @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

1 entries across 1 versions & 1 rubygems

Version Path
condenser-0.0.5 lib/condenser/environment.rb