Sha256: e5bc6dd3b5d99dc6f9aa640a414f516d6f05e1a6442800c4d2b944b2ea1d879b

Contents?: true

Size: 733 Bytes

Versions: 44

Compression:

Stored size: 733 Bytes

Contents

module Opal
  module Sprockets

    class PathReader
      def initialize(env, context)
        @env ||= env
        @context ||= context
      end

      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.open(expand(path), 'rb:UTF-8'){|f| f.read}
        end
      rescue ::Sprockets::FileNotFound
        nil
      end

      def expand path
        env.resolve(path) or
          # Sprockets 3 just returns nil for unknown paths
          raise ::Sprockets::FileNotFound, path.inspect
      end

      def paths
        env.paths
      end

      attr_reader :env, :context
    end

  end
end

Version data entries

44 entries across 44 versions & 3 rubygems

Version Path
opal-sprockets-0.4.9.1.0.3.7 lib/opal/sprockets/path_reader.rb
opal-sprockets-0.4.8.1.0.3.7 lib/opal/sprockets/path_reader.rb
opal-sprockets-0.4.7.1.0.3.7 lib/opal/sprockets/path_reader.rb
opal-sprockets-0.4.6.1.0.3.7 lib/opal/sprockets/path_reader.rb
opal-sprockets-0.4.5.1.0.3.7 lib/opal/sprockets/path_reader.rb
opal-sprockets-0.4.4.1.0.3.7 lib/opal/sprockets/path_reader.rb
opal-sprockets-0.4.3.0.11.0.3.7 lib/opal/sprockets/path_reader.rb
opal-sprockets-0.4.2.0.11.0.3.1 lib/opal/sprockets/path_reader.rb
opal-sprockets-0.4.2.pre.1.0.11.0.3.1 lib/opal/sprockets/path_reader.rb
opal-0.10.6 lib/opal/sprockets/path_reader.rb
opal-0.10.6.beta lib/opal/sprockets/path_reader.rb
opal-sprockets-0.4.1.0.11.0.3.1 lib/opal/sprockets/path_reader.rb
opal-sprockets-0.4.1.0.11.0.rc1.3.1 lib/opal/sprockets/path_reader.rb
opal-0.10.5 lib/opal/sprockets/path_reader.rb
opal-sprockets-0.4.1.0.11.0.rc1.3.1.beta2 lib/opal/sprockets/path_reader.rb
opal-0.10.4 lib/opal/sprockets/path_reader.rb
opal-sprockets-0.4.0.0.11.0.rc1.3.1.beta2 lib/opal/sprockets/path_reader.rb
opal-0.10.3 lib/opal/sprockets/path_reader.rb
opal-sprockets-0.4.0.0.11.dev.3.1.beta1 lib/opal/sprockets/path_reader.rb
opal-0.10.2 lib/opal/sprockets/path_reader.rb