[フレーム]

Class: Opal::Sprockets::PathReader

Inherits:
Object
  • Object
  • Opal::Sprockets::PathReader
show all
Defined in:
opal/lib/opal/sprockets/path_reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, context) ⇒ PathReader

Returns a new instance of PathReader

5
6
7
8
# File 'opal/lib/opal/sprockets/path_reader.rb', line 5
def initialize(env, context)
 @env ||= env
 @context ||= context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context

30
31
32
# File 'opal/lib/opal/sprockets/path_reader.rb', line 30
def context
 @context
end

#envObject (readonly)

Returns the value of attribute env

30
31
32
# File 'opal/lib/opal/sprockets/path_reader.rb', line 30
def env
 @env
end

Instance Method Details

#expand(path) ⇒ Object

22
23
24
# File 'opal/lib/opal/sprockets/path_reader.rb', line 22
def expand path
 env.resolve(path)
end

#pathsObject

26
27
28
# File 'opal/lib/opal/sprockets/path_reader.rb', line 26
def paths
 env.paths
end

#read(path) ⇒ Object

10
11
12
13
14
15
16
17
18
19
20
# File 'opal/lib/opal/sprockets/path_reader.rb', line 10
def read path
 if path.end_with? '.js'
 context.depend_on_asset(path)
 env[path, bundle: true].to_s
 else
 context.depend_on(path)
 File.read(expand(path))
 end
rescue ::Sprockets ::FileNotFound
 nil
end

AltStyle によって変換されたページ (->オリジナル) /