Class: Condenser

Inherits:
Object
  • Object
show all
Includes:
Environment, Pipeline, Resolve
Defined in:
lib/condenser/errors.rb,
lib/condenser.rb,
lib/condenser/asset.rb,
lib/condenser/utils.rb,
lib/condenser/export.rb,
lib/condenser/server.rb,
lib/condenser/context.rb,
lib/condenser/resolve.rb,
lib/condenser/version.rb,
lib/condenser/manifest.rb,
lib/condenser/pipeline.rb,
lib/condenser/build_cache.rb,
lib/condenser/environment.rb,
lib/condenser/encoding_utils.rb,
lib/condenser/processors/node_processor.rb,
lib/condenser/transformers/sass_transformer.rb

Overview

Basic Condenser error classes

Defined Under Namespace

Modules: EncodingUtils, Environment, Pipeline, Resolve, Utils Classes: Asset, BabelProcessor, BuildCache, Cache, CacheStore, CommandNotFoundError, ContentTypeMismatch, Context, EjsTemplare, Error, Erubi, Export, FileNotFound, FileWriter, JstTransformer, Manifest, NodeProcessor, NotFound, RollupProcessor, SassMinifier, SassTransformer, ScssTransformer, Server, SyntaxError, UglifyMinifier, ZlibWriter

Constant Summary collapse

VERSION =
'0.3'

Constants included from Pipeline

Pipeline::CONFIG_VARS

Instance Attribute Summary collapse

Attributes included from Environment

#cache, #context_class, #npm_path, #path

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resolve

#[], #build, #build_cache, #decompose_path, #find, #find!, #find_export, #match_mime_type?, #match_mime_types?, #mime_type_match_accept?, #resolve, #resolve!, #reverse_mapping, #writers_for_mime_type

Methods included from Pipeline

#clear_pipeline, #minifier_for, prepended, #register_exporter, #register_mime_type, #register_minifier, #register_postprocessor, #register_preprocessor, #register_template, #register_transformer, #register_writer, #unregister_exporter, #unregister_minifier, #unregister_preprocessor, #unregister_writer

Methods included from Environment

#append_npm_path, #append_path, #clear_path, #load_processors, #new_context_class, #prepend_path

Constructor Details

#initialize(*path, logger: nil, digestor: nil, cache: nil, pipeline: nil, &block) ⇒ Condenser

Returns a new instance of Condenser.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/condenser.rb', line 38

def initialize(*path, logger: nil, digestor: nil, cache: nil, pipeline: nil, &block)
  @logger = logger || Logger.new($stdout, level: :info)
  @path = []
  @npm_path = nil
  append_path(path)
  @cache = cache || Cache::MemoryStore.new
  @build_cc = 0
  self.digestor = digestor || Digest::SHA256

  if block
    configure(&block)
  elsif pipeline != false
    self.configure do
      register_preprocessor 'application/javascript', Condenser::BabelProcessor
      register_exporter     'application/javascript', Condenser::RollupProcessor
      register_minifier     'application/javascript', Condenser::UglifyMinifier
    
      register_minifier  'text/css', Condenser::SassMinifier
    
      register_writer Condenser::FileWriter.new
      register_writer Condenser::ZlibWriter.new
    end
  end
end

Instance Attribute Details

#digestorObject

Returns the value of attribute digestor.



36
37
38
# File 'lib/condenser.rb', line 36

def digestor
  @digestor
end

#loggerObject

Returns the value of attribute logger.



36
37
38
# File 'lib/condenser.rb', line 36

def logger
  @logger
end

Class Method Details

.configure(&block) ⇒ Object



32
33
34
# File 'lib/condenser.rb', line 32

def self.configure(&block)
  instance_eval(&block)
end

Instance Method Details

#configure(&block) ⇒ Object



63
64
65
# File 'lib/condenser.rb', line 63

def configure(&block)
  instance_eval(&block)
end