sprockets 3.0.0.beta.4 → 3.0.0.beta.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sprockets/cache/file_store.rb +26 -2
- data/lib/sprockets/context.rb +4 -0
- data/lib/sprockets/directive_processor.rb +66 -0
- data/lib/sprockets/legacy.rb +8 -0
- data/lib/sprockets/loader.rb +0 -1
- data/lib/sprockets/sass_cache_store.rb +2 -0
- data/lib/sprockets/sass_functions.rb +2 -0
- data/lib/sprockets/sass_importer.rb +2 -0
- data/lib/sprockets/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a6bee17ca558f25cc69850e82405f479f3d3af3
|
4
|
+
data.tar.gz: b513251bb8582e5fc2d30ccf3b0a65336e14edd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b16c9ea238f143f8b9e0881c74748446ae160179db5895195d00075e72eb7982630270ab8e1609ed93d05a86259d48b21c29723d9c9e90749b6010fa6599b89
|
7
|
+
data.tar.gz: 02c9e685bb2b994590402d7761b5476dc6c67afb49563ea04b6493c5b89a16d17069176ab4c3d7900367b41176ee059d2f653416d002dc4b7393c64ce9622794
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'digest/md5'
|
2
2
|
require 'fileutils'
|
3
3
|
require 'logger'
|
4
|
+
require 'zlib'
|
4
5
|
|
5
6
|
module Sprockets
|
6
7
|
class Cache
|
@@ -52,7 +53,13 @@ module Sprockets
|
|
52
53
|
|
53
54
|
value = safe_open(path) do |f|
|
54
55
|
begin
|
55
|
-
|
56
|
+
raw = f.read
|
57
|
+
if raw =~ /\A\x04\x08/
|
58
|
+
marshaled = raw
|
59
|
+
else
|
60
|
+
marshaled = Zlib::Inflate.new(Zlib::MAX_WBITS).inflate(raw)
|
61
|
+
end
|
62
|
+
Marshal.load(marshaled)
|
56
63
|
rescue Exception => e
|
57
64
|
@logger.error do
|
58
65
|
"#{self.class}[#{path}] could not be unmarshaled: " +
|
@@ -85,9 +92,26 @@ module Sprockets
|
|
85
92
|
# Check if cache exists before writing
|
86
93
|
exists = File.exist?(path)
|
87
94
|
|
95
|
+
# Serialize value
|
96
|
+
marshaled = Marshal.dump(value)
|
97
|
+
|
98
|
+
# Compress if larger than 4KB
|
99
|
+
if marshaled.bytesize > 4 * 1024
|
100
|
+
deflater = Zlib::Deflate.new(
|
101
|
+
Zlib::BEST_COMPRESSION,
|
102
|
+
Zlib::MAX_WBITS,
|
103
|
+
Zlib::MAX_MEM_LEVEL,
|
104
|
+
Zlib::DEFAULT_STRATEGY
|
105
|
+
)
|
106
|
+
deflater << marshaled
|
107
|
+
raw = deflater.finish
|
108
|
+
else
|
109
|
+
raw = marshaled
|
110
|
+
end
|
111
|
+
|
88
112
|
# Write data
|
89
113
|
PathUtils.atomic_write(path) do |f|
|
90
|
-
|
114
|
+
f.write(raw)
|
91
115
|
@size += f.size unless exists
|
92
116
|
end
|
93
117
|
|
data/lib/sprockets/context.rb
CHANGED
@@ -21,6 +21,9 @@ module Sprockets
|
|
21
21
|
class Context
|
22
22
|
attr_reader :environment, :filename, :pathname
|
23
23
|
|
24
|
+
# Deprecated
|
25
|
+
attr_accessor :__LINE__
|
26
|
+
|
24
27
|
def initialize(input)
|
25
28
|
@environment = input[:environment]
|
26
29
|
@metadata = input[:metadata]
|
@@ -67,6 +70,7 @@ module Sprockets
|
|
67
70
|
attr_reader :content_type
|
68
71
|
|
69
72
|
# Internal
|
73
|
+
# TODO: Cleanup relative resolver logic shared between directive processor.
|
70
74
|
def _resolve(method, path, options = {})
|
71
75
|
options[:content_type] = self.content_type if options[:content_type] == :self
|
72
76
|
options[:accept] = options.delete(:content_type)
|
@@ -337,6 +337,71 @@ module Sprockets
|
|
337
337
|
end
|
338
338
|
end
|
339
339
|
|
340
|
+
# `link_directory` links all the files inside a single
|
341
|
+
# directory. It's similar to `path/*` since it does not follow
|
342
|
+
# nested directories.
|
343
|
+
#
|
344
|
+
# //= link_directory "./fonts"
|
345
|
+
#
|
346
|
+
def process_link_directory_directive(path = ".")
|
347
|
+
if @environment.relative_path?(path)
|
348
|
+
root = expand_relative_path(path)
|
349
|
+
|
350
|
+
unless (stats = @environment.stat(root)) && stats.directory?
|
351
|
+
raise ArgumentError, "link_directory argument must be a directory"
|
352
|
+
end
|
353
|
+
|
354
|
+
@dependency_paths << root
|
355
|
+
|
356
|
+
@environment.stat_directory(root).each do |subpath, stat|
|
357
|
+
if subpath == @filename
|
358
|
+
next
|
359
|
+
elsif stat.directory?
|
360
|
+
next
|
361
|
+
elsif uri = @environment.locate(subpath)
|
362
|
+
asset = @environment.load(uri)
|
363
|
+
@dependency_paths.merge(asset.metadata[:dependency_paths])
|
364
|
+
@links << asset.uri
|
365
|
+
end
|
366
|
+
end
|
367
|
+
else
|
368
|
+
# The path must be relative and start with a `./`.
|
369
|
+
raise ArgumentError, "link_directory argument must be a relative path"
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
# `link_tree` links all the nested files in a directory.
|
374
|
+
# Its glob equivalent is `path/**/*`.
|
375
|
+
#
|
376
|
+
# //= link_tree "./images"
|
377
|
+
#
|
378
|
+
def process_link_tree_directive(path = ".")
|
379
|
+
if @environment.relative_path?(path)
|
380
|
+
root = expand_relative_path(path)
|
381
|
+
|
382
|
+
unless (stats = @environment.stat(root)) && stats.directory?
|
383
|
+
raise ArgumentError, "link_tree argument must be a directory"
|
384
|
+
end
|
385
|
+
|
386
|
+
@dependency_paths << root
|
387
|
+
|
388
|
+
@environment.stat_sorted_tree(root).each do |subpath, stat|
|
389
|
+
if subpath == @filename
|
390
|
+
next
|
391
|
+
elsif stat.directory?
|
392
|
+
@dependency_paths << subpath
|
393
|
+
elsif uri = @environment.locate(subpath)
|
394
|
+
asset = @environment.load(uri)
|
395
|
+
@dependency_paths.merge(asset.metadata[:dependency_paths])
|
396
|
+
@links << asset.uri
|
397
|
+
end
|
398
|
+
end
|
399
|
+
else
|
400
|
+
# The path must be relative and start with a `./`.
|
401
|
+
raise ArgumentError, "link_tree argument must be a relative path"
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
340
405
|
private
|
341
406
|
def expand_relative_path(path)
|
342
407
|
File.expand_path(path, @dirname)
|
@@ -350,6 +415,7 @@ module Sprockets
|
|
350
415
|
_resolve(:resolve, path, options)
|
351
416
|
end
|
352
417
|
|
418
|
+
# TODO: Cleanup relative resolver logic shared between context.
|
353
419
|
def _resolve(method, path, options = {})
|
354
420
|
if @environment.absolute_path?(path)
|
355
421
|
raise FileOutsidePaths, "can't require absolute file: #{path}"
|
data/lib/sprockets/legacy.rb
CHANGED
data/lib/sprockets/loader.rb
CHANGED
data/lib/sprockets/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.beta.
|
4
|
+
version: 3.0.0.beta.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-11-
|
12
|
+
date: 2014-11-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -260,7 +260,10 @@ files:
|
|
260
260
|
- lib/sprockets/paths.rb
|
261
261
|
- lib/sprockets/processing.rb
|
262
262
|
- lib/sprockets/resolve.rb
|
263
|
+
- lib/sprockets/sass_cache_store.rb
|
263
264
|
- lib/sprockets/sass_compressor.rb
|
265
|
+
- lib/sprockets/sass_functions.rb
|
266
|
+
- lib/sprockets/sass_importer.rb
|
264
267
|
- lib/sprockets/sass_template.rb
|
265
268
|
- lib/sprockets/server.rb
|
266
269
|
- lib/sprockets/transformers.rb
|