Class: Sprockets::Typescript::Compiler::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/sprockets/typescript/compiler.rb

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Context

Returns a new instance of Context.



25
26
27
# File 'lib/sprockets/typescript/compiler.rb', line 25

def initialize(context)
  @context = context
end

Instance Method Details

#depends_on(path) ⇒ Object



51
52
53
# File 'lib/sprockets/typescript/compiler.rb', line 51

def depends_on(path)
  @context.depend_on_asset(path)
end

#evaluate(path) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/sprockets/typescript/compiler.rb', line 37

def evaluate(path)
  pathname = Pathname.new(path)
  attributes = @context.environment.attributes_for(path)
  processors = attributes.processors
  processors = processors.reject { |p| p == Sprockets::Typescript::Template }
  if defined?(Sprockets::CommonJS)
    processors = processors.reject { |p| p == Sprockets::CommonJS }
  end

  context = @context.environment.context_class.new(@context.environment, attributes.logical_path, pathname)
  content = context.evaluate(pathname, :processors => processors)
  { :content => content, :context => self.class.new(context) }
end

#require(path) ⇒ Object



55
56
57
# File 'lib/sprockets/typescript/compiler.rb', line 55

def require(path)
  @context.require_asset(path)
end

#resolve(path) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/sprockets/typescript/compiler.rb', line 29

def resolve(path)
  if path == DEFAULT_LIB_PATH
    path
  else
    @context.resolve(path, :content_type => :self).to_s
  end
end