sprockets 2.3.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sprockets might be problematic. Click here for more details.

Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +2 -2
  3. data/README.md +332 -115
  4. data/bin/sprockets +8 -0
  5. data/lib/rake/sprocketstask.rb +25 -13
  6. data/lib/sprockets/asset.rb +143 -205
  7. data/lib/sprockets/autoload/closure.rb +7 -0
  8. data/lib/sprockets/autoload/coffee_script.rb +7 -0
  9. data/lib/sprockets/autoload/eco.rb +7 -0
  10. data/lib/sprockets/autoload/ejs.rb +7 -0
  11. data/lib/sprockets/autoload/sass.rb +7 -0
  12. data/lib/sprockets/autoload/uglifier.rb +7 -0
  13. data/lib/sprockets/autoload/yui.rb +7 -0
  14. data/lib/sprockets/autoload.rb +11 -0
  15. data/lib/sprockets/base.rb +49 -257
  16. data/lib/sprockets/bower.rb +58 -0
  17. data/lib/sprockets/bundle.rb +65 -0
  18. data/lib/sprockets/cache/file_store.rb +165 -14
  19. data/lib/sprockets/cache/memory_store.rb +66 -0
  20. data/lib/sprockets/cache/null_store.rb +46 -0
  21. data/lib/sprockets/cache.rb +234 -0
  22. data/lib/sprockets/cached_environment.rb +69 -0
  23. data/lib/sprockets/closure_compressor.rb +53 -0
  24. data/lib/sprockets/coffee_script_processor.rb +25 -0
  25. data/lib/sprockets/coffee_script_template.rb +6 -0
  26. data/lib/sprockets/compressing.rb +74 -0
  27. data/lib/sprockets/configuration.rb +83 -0
  28. data/lib/sprockets/context.rb +125 -131
  29. data/lib/sprockets/dependencies.rb +73 -0
  30. data/lib/sprockets/digest_utils.rb +156 -0
  31. data/lib/sprockets/directive_processor.rb +209 -211
  32. data/lib/sprockets/eco_processor.rb +32 -0
  33. data/lib/sprockets/eco_template.rb +3 -35
  34. data/lib/sprockets/ejs_processor.rb +31 -0
  35. data/lib/sprockets/ejs_template.rb +3 -34
  36. data/lib/sprockets/encoding_utils.rb +258 -0
  37. data/lib/sprockets/engines.rb +45 -38
  38. data/lib/sprockets/environment.rb +17 -67
  39. data/lib/sprockets/erb_processor.rb +30 -0
  40. data/lib/sprockets/erb_template.rb +6 -0
  41. data/lib/sprockets/errors.rb +6 -13
  42. data/lib/sprockets/file_reader.rb +15 -0
  43. data/lib/sprockets/http_utils.rb +115 -0
  44. data/lib/sprockets/jst_processor.rb +35 -19
  45. data/lib/sprockets/legacy.rb +314 -0
  46. data/lib/sprockets/legacy_proc_processor.rb +35 -0
  47. data/lib/sprockets/legacy_tilt_processor.rb +29 -0
  48. data/lib/sprockets/loader.rb +176 -0
  49. data/lib/sprockets/manifest.rb +179 -98
  50. data/lib/sprockets/manifest_utils.rb +45 -0
  51. data/lib/sprockets/mime.rb +114 -32
  52. data/lib/sprockets/path_dependency_utils.rb +85 -0
  53. data/lib/sprockets/path_digest_utils.rb +47 -0
  54. data/lib/sprockets/path_utils.rb +282 -0
  55. data/lib/sprockets/paths.rb +81 -0
  56. data/lib/sprockets/processing.rb +157 -189
  57. data/lib/sprockets/processor_utils.rb +103 -0
  58. data/lib/sprockets/resolve.rb +208 -0
  59. data/lib/sprockets/sass_cache_store.rb +19 -15
  60. data/lib/sprockets/sass_compressor.rb +59 -0
  61. data/lib/sprockets/sass_functions.rb +2 -0
  62. data/lib/sprockets/sass_importer.rb +2 -29
  63. data/lib/sprockets/sass_processor.rb +285 -0
  64. data/lib/sprockets/sass_template.rb +4 -44
  65. data/lib/sprockets/server.rb +109 -84
  66. data/lib/sprockets/transformers.rb +145 -0
  67. data/lib/sprockets/uglifier_compressor.rb +63 -0
  68. data/lib/sprockets/uri_utils.rb +190 -0
  69. data/lib/sprockets/utils.rb +193 -44
  70. data/lib/sprockets/version.rb +1 -1
  71. data/lib/sprockets/yui_compressor.rb +65 -0
  72. data/lib/sprockets.rb +144 -53
  73. metadata +248 -238
  74. data/lib/sprockets/asset_attributes.rb +0 -126
  75. data/lib/sprockets/bundled_asset.rb +0 -79
  76. data/lib/sprockets/caching.rb +0 -96
  77. data/lib/sprockets/charset_normalizer.rb +0 -41
  78. data/lib/sprockets/index.rb +0 -99
  79. data/lib/sprockets/processed_asset.rb +0 -152
  80. data/lib/sprockets/processor.rb +0 -32
  81. data/lib/sprockets/safety_colons.rb +0 -28
  82. data/lib/sprockets/scss_template.rb +0 -13
  83. data/lib/sprockets/static_asset.rb +0 -57
  84. data/lib/sprockets/trail.rb +0 -90
@@ -1,37 +1,6 @@
1
- require 'tilt'
1
+ require 'sprockets/ejs_processor'
2
2
 
3
3
  module Sprockets
4
- # Tilt engine class for the EJS compiler. Depends on the `ejs` gem.
5
- #
6
- # For more infomation see:
7
- #
8
- # https://github.com/sstephenson/ruby-ejs
9
- #
10
- class EjsTemplate < Tilt::Template
11
- # Check to see if EJS is loaded
12
- def self.engine_initialized?
13
- defined? ::EJS
14
- end
15
-
16
- # Autoload ejs library. If the library isn't loaded, Tilt will produce
17
- # a thread safetly warning. If you intend to use `.ejs` files, you
18
- # should explicitly require it.
19
- def initialize_engine
20
- require_template_library 'ejs'
21
- end
22
-
23
- def prepare
24
- end
25
-
26
- # Compile template data with EJS compiler.
27
- #
28
- # Returns a JS function definition String. The result should be
29
- # assigned to a JS variable.
30
- #
31
- # # => "function(obj){...}"
32
- #
33
- def evaluate(scope, locals, &block)
34
- EJS.compile(data)
35
- end
36
- end
4
+ # Deprecated
5
+ EjsTemplate = EjsProcessor
37
6
  end
@@ -0,0 +1,258 @@
1
+ require 'base64'
2
+ require 'stringio'
3
+ require 'zlib'
4
+
5
+ module Sprockets
6
+ # Internal: HTTP transport encoding and charset detecting related functions.
7
+ # Mixed into Environment.
8
+ module EncodingUtils
9
+ extend self
10
+
11
+ ## Binary encodings ##
12
+
13
+ # Public: Use deflate to compress data.
14
+ #
15
+ # str - String data
16
+ #
17
+ # Returns a compressed String
18
+ def deflate(str)
19
+ deflater = Zlib::Deflate.new(
20
+ Zlib::BEST_COMPRESSION,
21
+ -Zlib::MAX_WBITS,
22
+ Zlib::MAX_MEM_LEVEL,
23
+ Zlib::DEFAULT_STRATEGY
24
+ )
25
+ deflater << str
26
+ deflater.finish
27
+ end
28
+
29
+ # Internal: Unmarshal optionally deflated data.
30
+ #
31
+ # Checks leading marshal header to see if the bytes are uncompressed
32
+ # otherwise inflate the data an unmarshal.
33
+ #
34
+ # str - Marshaled String
35
+ # window_bits - Integer deflate window size. See ZLib::Inflate.new()
36
+ #
37
+ # Returns unmarshaled Object or raises an Exception.
38
+ def unmarshaled_deflated(str, window_bits = -Zlib::MAX_WBITS)
39
+ major, minor = str[0], str[1]
40
+ if major && major.ord == Marshal::MAJOR_VERSION &&
41
+ minor && minor.ord <= Marshal::MINOR_VERSION
42
+ marshaled = str
43
+ else
44
+ begin
45
+ marshaled = Zlib::Inflate.new(window_bits).inflate(str)
46
+ rescue Zlib::DataError
47
+ marshaled = str
48
+ end
49
+ end
50
+ Marshal.load(marshaled)
51
+ end
52
+
53
+ # Public: Use gzip to compress data.
54
+ #
55
+ # str - String data
56
+ #
57
+ # Returns a compressed String
58
+ def gzip(str)
59
+ io = StringIO.new
60
+ gz = Zlib::GzipWriter.new(io, Zlib::BEST_COMPRESSION)
61
+ gz.mtime = 1
62
+ gz << str
63
+ gz.finish
64
+ io.string
65
+ end
66
+
67
+ # Public: Use base64 to encode data.
68
+ #
69
+ # str - String data
70
+ #
71
+ # Returns a encoded String
72
+ def base64(str)
73
+ Base64.strict_encode64(str)
74
+ end
75
+
76
+
77
+ ## Charset encodings ##
78
+
79
+ # Internal: Shorthand aliases for detecter functions.
80
+ CHARSET_DETECT = {}
81
+
82
+ # Internal: Mapping unicode encodings to byte order markers.
83
+ BOM = {
84
+ Encoding::UTF_32LE => [0xFF, 0xFE, 0x00, 0x00],
85
+ Encoding::UTF_32BE => [0x00, 0x00, 0xFE, 0xFF],
86
+ Encoding::UTF_8 => [0xEF, 0xBB, 0xBF],
87
+ Encoding::UTF_16LE => [0xFF, 0xFE],
88
+ Encoding::UTF_16BE => [0xFE, 0xFF]
89
+ }
90
+
91
+ # Public: Basic string detecter.
92
+ #
93
+ # Attempts to parse any Unicode BOM otherwise falls back to the
94
+ # environment's external encoding.
95
+ #
96
+ # str - ASCII-8BIT encoded String
97
+ #
98
+ # Returns encoded String.
99
+ def detect(str)
100
+ str = detect_unicode_bom(str)
101
+
102
+ # Attempt Charlock detection
103
+ if str.encoding == Encoding::BINARY
104
+ charlock_detect(str)
105
+ end
106
+
107
+ # Fallback to UTF-8
108
+ if str.encoding == Encoding::BINARY
109
+ str.force_encoding(Encoding.default_external)
110
+ end
111
+
112
+ str
113
+ end
114
+ CHARSET_DETECT[:default] = method(:detect)
115
+
116
+ # Internal: Use Charlock Holmes to detect encoding.
117
+ #
118
+ # To enable this code path, require 'charlock_holmes'
119
+ #
120
+ # Returns encoded String.
121
+ def charlock_detect(str)
122
+ if defined? CharlockHolmes::EncodingDetector
123
+ if detected = CharlockHolmes::EncodingDetector.detect(str)
124
+ str.force_encoding(detected[:encoding]) if detected[:encoding]
125
+ end
126
+ end
127
+
128
+ str
129
+ end
130
+
131
+ # Public: Detect Unicode string.
132
+ #
133
+ # Attempts to parse Unicode BOM and falls back to UTF-8.
134
+ #
135
+ # str - ASCII-8BIT encoded String
136
+ #
137
+ # Returns encoded String.
138
+ def detect_unicode(str)
139
+ str = detect_unicode_bom(str)
140
+
141
+ # Fallback to UTF-8
142
+ if str.encoding == Encoding::BINARY
143
+ str.force_encoding(Encoding::UTF_8)
144
+ end
145
+
146
+ str
147
+ end
148
+ CHARSET_DETECT[:unicode] = method(:detect_unicode)
149
+
150
+ # Public: Detect and strip BOM from possible unicode string.
151
+ #
152
+ # str - ASCII-8BIT encoded String
153
+ #
154
+ # Returns UTF 8/16/32 encoded String without BOM or the original String if
155
+ # no BOM was present.
156
+ def detect_unicode_bom(str)
157
+ bom_bytes = str.byteslice(0, 4).bytes.to_a
158
+
159
+ BOM.each do |encoding, bytes|
160
+ if bom_bytes[0, bytes.size] == bytes
161
+ str = str.dup
162
+ str.force_encoding(Encoding::BINARY)
163
+ str.slice!(0, bytes.size)
164
+ str.force_encoding(encoding)
165
+ return str
166
+ end
167
+ end
168
+
169
+ return str
170
+ end
171
+
172
+ # Public: Detect and strip @charset from CSS style sheet.
173
+ #
174
+ # str - String.
175
+ #
176
+ # Returns a encoded String.
177
+ def detect_css(str)
178
+ str = detect_unicode_bom(str)
179
+
180
+ if name = scan_css_charset(str)
181
+ encoding = Encoding.find(name)
182
+ str = str.dup
183
+ str.force_encoding(encoding)
184
+ len = "@charset \"#{name}\";".encode(encoding).size
185
+ str.slice!(0, len)
186
+ str
187
+ end
188
+
189
+ # Fallback to UTF-8
190
+ if str.encoding == Encoding::BINARY
191
+ str.force_encoding(Encoding::UTF_8)
192
+ end
193
+
194
+ str
195
+ end
196
+ CHARSET_DETECT[:css] = method(:detect_css)
197
+
198
+ # Internal: @charset bytes
199
+ CHARSET_START = [0x40, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65, 0x74, 0x20, 0x22]
200
+ CHARSET_SIZE = CHARSET_START.size
201
+
202
+ # Internal: Scan binary CSS string for @charset encoding name.
203
+ #
204
+ # str - ASCII-8BIT encoded String
205
+ #
206
+ # Returns encoding String name or nil.
207
+ def scan_css_charset(str)
208
+ buf = []
209
+ i = 0
210
+
211
+ str.each_byte.each do |byte|
212
+ # Halt on line breaks
213
+ break if byte == 0x0A || byte == 0x0D
214
+
215
+ # Only ascii bytes
216
+ next unless 0x0 < byte && byte <= 0xFF
217
+
218
+ if i < CHARSET_SIZE
219
+ elsif i == CHARSET_SIZE
220
+ if buf == CHARSET_START
221
+ buf = []
222
+ else
223
+ break
224
+ end
225
+ elsif byte == 0x22
226
+ return buf.pack('C*')
227
+ end
228
+
229
+ buf << byte
230
+ i += 1
231
+ end
232
+
233
+ nil
234
+ end
235
+
236
+ # Public: Detect charset from HTML document. Defaults to ISO-8859-1.
237
+ #
238
+ # str - String.
239
+ #
240
+ # Returns a encoded String.
241
+ def detect_html(str)
242
+ str = detect_unicode_bom(str)
243
+
244
+ # Attempt Charlock detection
245
+ if str.encoding == Encoding::BINARY
246
+ charlock_detect(str)
247
+ end
248
+
249
+ # Fallback to ISO-8859-1
250
+ if str.encoding == Encoding::BINARY
251
+ str.force_encoding(Encoding::ISO_8859_1)
252
+ end
253
+
254
+ str
255
+ end
256
+ CHARSET_DETECT[:html] = method(:detect_html)
257
+ end
258
+ end
@@ -1,22 +1,19 @@
1
- require 'sprockets/eco_template'
2
- require 'sprockets/ejs_template'
3
- require 'sprockets/jst_processor'
1
+ require 'sprockets/legacy_tilt_processor'
4
2
  require 'sprockets/utils'
5
- require 'tilt'
6
3
 
7
4
  module Sprockets
8
5
  # `Engines` provides a global and `Environment` instance registry.
9
6
  #
10
- # An engine is a type of processor that is bound to an filename
7
+ # An engine is a type of processor that is bound to a filename
11
8
  # extension. `application.js.coffee` indicates that the
12
- # `CoffeeScriptTemplate` engine will be ran on the file.
9
+ # `CoffeeScriptProcessor` engine will be ran on the file.
13
10
  #
14
11
  # Extensions can be stacked and will be evaulated from right to
15
- # left. `application.js.coffee.erb` will first run `ERBTemplate`
16
- # then `CoffeeScriptTemplate`.
12
+ # left. `application.js.coffee.erb` will first run `ERBProcessor`
13
+ # then `CoffeeScriptProcessor`.
17
14
  #
18
- # All `Engine`s must follow the `Tilt::Template` interface. It is
19
- # recommended to subclass `Tilt::Template`.
15
+ # All `Engine`s must follow the `Template` interface. It is
16
+ # recommended to subclass `Template`.
20
17
  #
21
18
  # Its recommended that you register engine changes on your local
22
19
  # `Environment` instance.
@@ -25,50 +22,60 @@ module Sprockets
25
22
  #
26
23
  # The global registry is exposed for plugins to register themselves.
27
24
  #
28
- # Sprockets.register_engine '.sass', SassTemplate
25
+ # Sprockets.register_engine '.sass', SassProcessor
29
26
  #
30
27
  module Engines
31
- # Returns an `Array` of `Engine`s registered on the
32
- # `Environment`. If an `ext` argument is supplied, the `Engine`
33
- # register under that extension will be returned.
28
+ include Utils
29
+
30
+ # Returns a `Hash` of `Engine`s registered on the `Environment`.
31
+ # If an `ext` argument is supplied, the `Engine` associated with
32
+ # that extension will be returned.
34
33
  #
35
34
  # environment.engines
36
- # # => [CoffeeScriptTemplate, SassTemplate, ...]
37
- #
38
- # environment.engines('.coffee')
39
- # # => CoffeeScriptTemplate
35
+ # # => {".coffee" => CoffeeScriptProcessor, ".sass" => SassProcessor, ...}
40
36
  #
41
- def engines(ext = nil)
42
- if ext
43
- ext = Sprockets::Utils.normalize_extension(ext)
44
- @engines[ext]
45
- else
46
- @engines.dup
47
- end
37
+ def engines
38
+ config[:engines]
48
39
  end
49
40
 
50
- # Returns an `Array` of engine extension `String`s.
41
+ # Internal: Returns a `Hash` of engine extensions to mime types.
51
42
  #
52
- # environment.engine_extensions
53
- # # => ['.coffee', '.sass', ...]
54
- def engine_extensions
55
- @engines.keys
43
+ # # => { '.coffee' => 'application/javascript' }
44
+ def engine_mime_types
45
+ config[:engine_mime_types]
56
46
  end
57
47
 
58
48
  # Registers a new Engine `klass` for `ext`. If the `ext` already
59
49
  # has an engine registered, it will be overridden.
60
50
  #
61
- # environment.register_engine '.coffee', CoffeeScriptTemplate
51
+ # environment.register_engine '.coffee', CoffeeScriptProcessor
62
52
  #
63
- def register_engine(ext, klass)
53
+ def register_engine(ext, klass, options = {})
64
54
  ext = Sprockets::Utils.normalize_extension(ext)
65
- @engines[ext] = klass
66
- end
67
55
 
68
- private
69
- def deep_copy_hash(hash)
70
- initial = Hash.new { |h, k| h[k] = [] }
71
- hash.inject(initial) { |h, (k, a)| h[k] = a.dup; h }
56
+ self.computed_config = {}
57
+
58
+ if klass.respond_to?(:call)
59
+ processor = klass
60
+ self.config = hash_reassoc(config, :engines) do |engines|
61
+ engines.merge(ext => klass)
62
+ end
63
+ if options[:mime_type]
64
+ self.config = hash_reassoc(config, :engine_mime_types) do |mime_types|
65
+ mime_types.merge(ext.to_s => options[:mime_type])
66
+ end
67
+ end
68
+ else
69
+ processor = LegacyTiltProcessor.new(klass)
70
+ self.config = hash_reassoc(config, :engines) do |engines|
71
+ engines.merge(ext => processor)
72
+ end
73
+ if klass.respond_to?(:default_mime_type) && klass.default_mime_type
74
+ self.config = hash_reassoc(config, :engine_mime_types) do |mime_types|
75
+ mime_types.merge(ext.to_s => klass.default_mime_type)
76
+ end
77
+ end
72
78
  end
79
+ end
73
80
  end
74
81
  end
@@ -1,14 +1,6 @@
1
1
  require 'sprockets/base'
2
- require 'sprockets/charset_normalizer'
3
- require 'sprockets/context'
4
- require 'sprockets/directive_processor'
5
- require 'sprockets/index'
6
- require 'sprockets/safety_colons'
7
-
8
- require 'hike'
9
- require 'logger'
10
- require 'pathname'
11
- require 'tilt'
2
+ require 'sprockets/cache/memory_store'
3
+ require 'sprockets/cached_environment'
12
4
 
13
5
  module Sprockets
14
6
  class Environment < Base
@@ -18,74 +10,32 @@ module Sprockets
18
10
  # env = Environment.new(Rails.root)
19
11
  #
20
12
  def initialize(root = ".")
21
- @trail = Hike::Trail.new(root)
22
-
23
- self.logger = Logger.new($stderr)
24
- self.logger.level = Logger::FATAL
25
-
26
- if respond_to?(:default_external_encoding)
27
- self.default_external_encoding = Encoding::UTF_8
28
- end
29
-
30
- # Create a safe `Context` subclass to mutate
31
- @context_class = Class.new(Context)
32
-
33
- # Set MD5 as the default digest
34
- require 'digest/md5'
35
- @digest_class = ::Digest::MD5
36
- @version = ''
37
-
38
- @mime_types = {}
39
- @engines = Sprockets.engines
40
- @preprocessors = Hash.new { |h, k| h[k] = [] }
41
- @postprocessors = Hash.new { |h, k| h[k] = [] }
42
- @bundle_processors = Hash.new { |h, k| h[k] = [] }
43
-
44
- @engines.each do |ext, klass|
45
- add_engine_to_trail(ext, klass)
46
- end
47
-
48
- register_mime_type 'text/css', '.css'
49
- register_mime_type 'application/javascript', '.js'
50
-
51
- register_preprocessor 'text/css', DirectiveProcessor
52
- register_preprocessor 'application/javascript', DirectiveProcessor
53
-
54
- register_postprocessor 'application/javascript', SafetyColons
55
- register_bundle_processor 'text/css', CharsetNormalizer
56
-
57
- expire_index!
58
-
13
+ initialize_configuration(Sprockets)
14
+ self.root = root
15
+ self.cache = Cache::MemoryStore.new
59
16
  yield self if block_given?
60
17
  end
61
18
 
62
19
  # Returns a cached version of the environment.
63
20
  #
64
- # All its file system calls are cached which makes `index` much
21
+ # All its file system calls are cached which makes `cached` much
65
22
  # faster. This behavior is ideal in production since the file
66
23
  # system only changes between deploys.
67
- def index
68
- Index.new(self)
24
+ def cached
25
+ CachedEnvironment.new(self)
69
26
  end
27
+ alias_method :index, :cached
70
28
 
71
- # Cache `find_asset` calls
72
- def find_asset(path, options = {})
73
- options[:bundle] = true unless options.key?(:bundle)
29
+ def find_asset(*args)
30
+ cached.find_asset(*args)
31
+ end
74
32
 
75
- # Ensure inmemory cached assets are still fresh on every lookup
76
- if (asset = @assets[cache_key_for(path, options)]) && asset.fresh?(self)
77
- asset
78
- elsif asset = index.find_asset(path, options)
79
- # Cache is pushed upstream by Index#find_asset
80
- asset
81
- end
33
+ def find_all_linked_assets(*args, &block)
34
+ cached.find_all_linked_assets(*args, &block)
82
35
  end
83
36
 
84
- protected
85
- def expire_index!
86
- # Clear digest to be recomputed
87
- @digest = nil
88
- @assets = {}
89
- end
37
+ def load(*args)
38
+ cached.load(*args)
39
+ end
90
40
  end
91
41
  end
@@ -0,0 +1,30 @@
1
+ require 'erb'
2
+
3
+ module Sprockets
4
+ class ERBProcessor
5
+ # Public: Return singleton instance with default options.
6
+ #
7
+ # Returns ERBProcessor object.
8
+ def self.instance
9
+ @instance ||= new
10
+ end
11
+
12
+ def self.call(input)
13
+ instance.call(input)
14
+ end
15
+
16
+ def initialize(&block)
17
+ @block = block
18
+ end
19
+
20
+ def call(input)
21
+ engine = ::ERB.new(input[:data], nil, '<>')
22
+ context = input[:environment].context_class.new(input)
23
+ klass = (class << context; self; end)
24
+ klass.class_eval(&@block) if @block
25
+ engine.def_method(klass, :_evaluate_template, input[:filename])
26
+ data = context._evaluate_template
27
+ context.metadata.merge(data: data)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,6 @@
1
+ require 'sprockets/erb_processor'
2
+
3
+ module Sprockets
4
+ # Deprecated
5
+ ERBTemplate = ERBProcessor
6
+ end
@@ -2,18 +2,11 @@
2
2
  module Sprockets
3
3
  class Error < StandardError; end
4
4
  class ArgumentError < Error; end
5
- class CircularDependencyError < Error; end
6
5
  class ContentTypeMismatch < Error; end
7
- class EncodingError < Error; end
8
- class FileNotFound < Error; end
9
- class FileOutsidePaths < Error; end
10
- class UnserializeError < Error; end
11
-
12
- module EngineError
13
- attr_accessor :sprockets_annotation
14
-
15
- def message
16
- [super, sprockets_annotation].compact.join("\n")
17
- end
18
- end
6
+ class NotImplementedError < Error; end
7
+ class NotFound < Error; end
8
+ class ConversionError < NotFound; end
9
+ class FileNotFound < NotFound; end
10
+ class FileOutsidePaths < NotFound; end
11
+ class VersionNotFound < NotFound; end
19
12
  end
@@ -0,0 +1,15 @@
1
+ require 'set'
2
+
3
+ module Sprockets
4
+ # Internal: The first processor in the pipeline that reads the file into
5
+ # memory and passes it along as `input[:data]`.
6
+ class FileReader
7
+ def self.call(input)
8
+ env = input[:environment]
9
+ data = env.read_file(input[:filename], input[:content_type])
10
+ dependencies = Set.new(input[:metadata][:dependencies])
11
+ dependencies += [env.build_file_digest_uri(input[:filename])]
12
+ { data: data, dependencies: dependencies }
13
+ end
14
+ end
15
+ end