giga-lite-hub 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/giga-lite-hub.gemspec +12 -0
- data/sprockets-4.2.2/CHANGELOG.md +118 -0
- data/sprockets-4.2.2/MIT-LICENSE +21 -0
- data/sprockets-4.2.2/README.md +716 -0
- data/sprockets-4.2.2/bin/sprockets +93 -0
- data/sprockets-4.2.2/lib/rake/sprocketstask.rb +157 -0
- data/sprockets-4.2.2/lib/sprockets/add_source_map_comment_to_asset_processor.rb +60 -0
- data/sprockets-4.2.2/lib/sprockets/asset.rb +212 -0
- data/sprockets-4.2.2/lib/sprockets/autoload/babel.rb +8 -0
- data/sprockets-4.2.2/lib/sprockets/autoload/closure.rb +8 -0
- data/sprockets-4.2.2/lib/sprockets/autoload/coffee_script.rb +8 -0
- data/sprockets-4.2.2/lib/sprockets/autoload/eco.rb +8 -0
- data/sprockets-4.2.2/lib/sprockets/autoload/ejs.rb +8 -0
- data/sprockets-4.2.2/lib/sprockets/autoload/jsminc.rb +8 -0
- data/sprockets-4.2.2/lib/sprockets/autoload/sass.rb +8 -0
- data/sprockets-4.2.2/lib/sprockets/autoload/sassc.rb +8 -0
- data/sprockets-4.2.2/lib/sprockets/autoload/uglifier.rb +8 -0
- data/sprockets-4.2.2/lib/sprockets/autoload/yui.rb +8 -0
- data/sprockets-4.2.2/lib/sprockets/autoload/zopfli.rb +7 -0
- data/sprockets-4.2.2/lib/sprockets/autoload.rb +16 -0
- data/sprockets-4.2.2/lib/sprockets/babel_processor.rb +66 -0
- data/sprockets-4.2.2/lib/sprockets/base.rb +147 -0
- data/sprockets-4.2.2/lib/sprockets/bower.rb +61 -0
- data/sprockets-4.2.2/lib/sprockets/bundle.rb +105 -0
- data/sprockets-4.2.2/lib/sprockets/cache/file_store.rb +208 -0
- data/sprockets-4.2.2/lib/sprockets/cache/memory_store.rb +84 -0
- data/sprockets-4.2.2/lib/sprockets/cache/null_store.rb +54 -0
- data/sprockets-4.2.2/lib/sprockets/cache.rb +271 -0
- data/sprockets-4.2.2/lib/sprockets/cached_environment.rb +64 -0
- data/sprockets-4.2.2/lib/sprockets/closure_compressor.rb +48 -0
- data/sprockets-4.2.2/lib/sprockets/coffee_script_processor.rb +39 -0
- data/sprockets-4.2.2/lib/sprockets/compressing.rb +134 -0
- data/sprockets-4.2.2/lib/sprockets/configuration.rb +79 -0
- data/sprockets-4.2.2/lib/sprockets/context.rb +305 -0
- data/sprockets-4.2.2/lib/sprockets/dependencies.rb +74 -0
- data/sprockets-4.2.2/lib/sprockets/digest_utils.rb +197 -0
- data/sprockets-4.2.2/lib/sprockets/directive_processor.rb +432 -0
- data/sprockets-4.2.2/lib/sprockets/eco_processor.rb +33 -0
- data/sprockets-4.2.2/lib/sprockets/ejs_processor.rb +32 -0
- data/sprockets-4.2.2/lib/sprockets/encoding_utils.rb +261 -0
- data/sprockets-4.2.2/lib/sprockets/environment.rb +46 -0
- data/sprockets-4.2.2/lib/sprockets/erb_processor.rb +43 -0
- data/sprockets-4.2.2/lib/sprockets/errors.rb +12 -0
- data/sprockets-4.2.2/lib/sprockets/exporters/base.rb +71 -0
- data/sprockets-4.2.2/lib/sprockets/exporters/file_exporter.rb +24 -0
- data/sprockets-4.2.2/lib/sprockets/exporters/zlib_exporter.rb +33 -0
- data/sprockets-4.2.2/lib/sprockets/exporters/zopfli_exporter.rb +14 -0
- data/sprockets-4.2.2/lib/sprockets/exporting.rb +73 -0
- data/sprockets-4.2.2/lib/sprockets/file_reader.rb +16 -0
- data/sprockets-4.2.2/lib/sprockets/http_utils.rb +135 -0
- data/sprockets-4.2.2/lib/sprockets/jsminc_compressor.rb +32 -0
- data/sprockets-4.2.2/lib/sprockets/jst_processor.rb +50 -0
- data/sprockets-4.2.2/lib/sprockets/loader.rb +347 -0
- data/sprockets-4.2.2/lib/sprockets/manifest.rb +339 -0
- data/sprockets-4.2.2/lib/sprockets/manifest_utils.rb +48 -0
- data/sprockets-4.2.2/lib/sprockets/mime.rb +96 -0
- data/sprockets-4.2.2/lib/sprockets/npm.rb +52 -0
- data/sprockets-4.2.2/lib/sprockets/path_dependency_utils.rb +77 -0
- data/sprockets-4.2.2/lib/sprockets/path_digest_utils.rb +48 -0
- data/sprockets-4.2.2/lib/sprockets/path_utils.rb +367 -0
- data/sprockets-4.2.2/lib/sprockets/paths.rb +82 -0
- data/sprockets-4.2.2/lib/sprockets/preprocessors/default_source_map.rb +49 -0
- data/sprockets-4.2.2/lib/sprockets/processing.rb +228 -0
- data/sprockets-4.2.2/lib/sprockets/processor_utils.rb +170 -0
- data/sprockets-4.2.2/lib/sprockets/resolve.rb +295 -0
- data/sprockets-4.2.2/lib/sprockets/sass_cache_store.rb +30 -0
- data/sprockets-4.2.2/lib/sprockets/sass_compressor.rb +63 -0
- data/sprockets-4.2.2/lib/sprockets/sass_functions.rb +3 -0
- data/sprockets-4.2.2/lib/sprockets/sass_importer.rb +3 -0
- data/sprockets-4.2.2/lib/sprockets/sass_processor.rb +313 -0
- data/sprockets-4.2.2/lib/sprockets/sassc_compressor.rb +56 -0
- data/sprockets-4.2.2/lib/sprockets/sassc_processor.rb +297 -0
- data/sprockets-4.2.2/lib/sprockets/server.rb +315 -0
- data/sprockets-4.2.2/lib/sprockets/source_map_processor.rb +66 -0
- data/sprockets-4.2.2/lib/sprockets/source_map_utils.rb +483 -0
- data/sprockets-4.2.2/lib/sprockets/transformers.rb +173 -0
- data/sprockets-4.2.2/lib/sprockets/uglifier_compressor.rb +66 -0
- data/sprockets-4.2.2/lib/sprockets/unloaded_asset.rb +139 -0
- data/sprockets-4.2.2/lib/sprockets/uri_tar.rb +99 -0
- data/sprockets-4.2.2/lib/sprockets/uri_utils.rb +194 -0
- data/sprockets-4.2.2/lib/sprockets/utils/gzip.rb +99 -0
- data/sprockets-4.2.2/lib/sprockets/utils.rb +210 -0
- data/sprockets-4.2.2/lib/sprockets/version.rb +4 -0
- data/sprockets-4.2.2/lib/sprockets/yui_compressor.rb +56 -0
- data/sprockets-4.2.2/lib/sprockets.rb +232 -0
- metadata +126 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
$VERBOSE = nil
|
|
3
|
+
|
|
4
|
+
require 'sprockets'
|
|
5
|
+
require 'optparse'
|
|
6
|
+
require 'shellwords'
|
|
7
|
+
|
|
8
|
+
unless ARGV.delete("--noenv")
|
|
9
|
+
if File.exist?(path = "./.sprocketsrc")
|
|
10
|
+
rcflags = Shellwords.split(File.read(path))
|
|
11
|
+
ARGV.unshift(*rcflags)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
paths = []
|
|
16
|
+
environment = Sprockets::Environment.new(Dir.pwd)
|
|
17
|
+
manifest = nil
|
|
18
|
+
|
|
19
|
+
(ENV['SPROCKETS_PATH'] || "").split(File::PATH_SEPARATOR).each do |path|
|
|
20
|
+
environment.append_path path
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
OptionParser.new do |opts|
|
|
24
|
+
opts.summary_width = 28
|
|
25
|
+
opts.banner = "Usage: sprockets [options] filename [filename ...]"
|
|
26
|
+
|
|
27
|
+
def opts.show_usage
|
|
28
|
+
puts self
|
|
29
|
+
exit 1
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
opts.on("-r", "--require LIBRARY", "Require the LIBRARY before doing anything") do |lib|
|
|
33
|
+
require lib
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
opts.on("-I DIRECTORY", "--include=DIRECTORY", "Adds the directory to the Sprockets load path") do |directory|
|
|
37
|
+
environment.append_path directory
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
opts.on("-o DIRECTORY", "--output=DIRECTORY", "Copy provided assets into DIRECTORY") do |directory|
|
|
41
|
+
manifest = Sprockets::Manifest.new(environment, directory)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
opts.on("--css-compressor=COMPRESSOR", "Use CSS compressor") do |compressor|
|
|
45
|
+
environment.css_compressor = compressor.to_sym
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
opts.on("--js-compressor=COMPRESSOR", "Use JavaScript compressor") do |compressor|
|
|
49
|
+
environment.js_compressor = compressor.to_sym
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
opts.on("--noenv", "Disables .sprocketsrc file") do
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
opts.on("--cache=DIRECTORY", "Enables the FileStore cache using the specified directory") do |directory|
|
|
56
|
+
environment.cache = Sprockets::Cache::FileStore.new(directory)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
opts.on_tail("-h", "--help", "Shows this help message") do
|
|
60
|
+
opts.show_usage
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
opts.on_tail("-v", "--version", "Shows version") do
|
|
64
|
+
puts Sprockets::VERSION
|
|
65
|
+
exit
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
opts.show_usage if ARGV.empty?
|
|
69
|
+
|
|
70
|
+
begin
|
|
71
|
+
opts.order(ARGV) do |path|
|
|
72
|
+
paths << path
|
|
73
|
+
end
|
|
74
|
+
rescue OptionParser::ParseError => e
|
|
75
|
+
opts.warn e.message
|
|
76
|
+
opts.show_usage
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
if environment.paths.empty?
|
|
81
|
+
warn "No load paths given"
|
|
82
|
+
warn "Usage: sprockets -Ijavascripts/ path"
|
|
83
|
+
exit 1
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
if manifest
|
|
87
|
+
manifest.compile(paths)
|
|
88
|
+
elsif paths.length == 1
|
|
89
|
+
puts environment.find_asset(paths.first).to_s
|
|
90
|
+
else
|
|
91
|
+
warn "Only one file can be compiled to stdout at a time"
|
|
92
|
+
exit 1
|
|
93
|
+
end
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'rake'
|
|
3
|
+
require 'rake/tasklib'
|
|
4
|
+
|
|
5
|
+
require 'sprockets'
|
|
6
|
+
require 'logger'
|
|
7
|
+
|
|
8
|
+
module Rake
|
|
9
|
+
# Simple Sprockets compilation Rake task macro.
|
|
10
|
+
#
|
|
11
|
+
# Rake::SprocketsTask.new do |t|
|
|
12
|
+
# t.environment = Sprockets::Environment.new
|
|
13
|
+
# t.output = "./public/assets"
|
|
14
|
+
# t.assets = %w( application.js application.css )
|
|
15
|
+
# end
|
|
16
|
+
#
|
|
17
|
+
class SprocketsTask < Rake::TaskLib
|
|
18
|
+
# Name of the task. Defaults to "assets".
|
|
19
|
+
#
|
|
20
|
+
# The name will also be used to suffix the clean and clobber
|
|
21
|
+
# tasks, "clean_assets" and "clobber_assets".
|
|
22
|
+
attr_accessor :name
|
|
23
|
+
|
|
24
|
+
# `Environment` instance used for finding assets.
|
|
25
|
+
#
|
|
26
|
+
# You'll most likely want to reassign `environment` to your own.
|
|
27
|
+
#
|
|
28
|
+
# Rake::SprocketsTask.new do |t|
|
|
29
|
+
# t.environment = Foo::Assets
|
|
30
|
+
# end
|
|
31
|
+
#
|
|
32
|
+
def environment
|
|
33
|
+
if !@environment.is_a?(Sprockets::Base) && @environment.respond_to?(:call)
|
|
34
|
+
@environment = @environment.call
|
|
35
|
+
else
|
|
36
|
+
@environment
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
attr_writer :environment
|
|
40
|
+
|
|
41
|
+
# Returns cached cached environment
|
|
42
|
+
def cached
|
|
43
|
+
@cached ||= environment.cached if environment
|
|
44
|
+
end
|
|
45
|
+
alias_method :index, :cached
|
|
46
|
+
|
|
47
|
+
# `Manifest` instance used for already compiled assets.
|
|
48
|
+
#
|
|
49
|
+
# Will be created by default if an environment and output
|
|
50
|
+
# directory are given
|
|
51
|
+
def manifest
|
|
52
|
+
if !@manifest.is_a?(Sprockets::Manifest) && @manifest.respond_to?(:call)
|
|
53
|
+
@manifest = @manifest.call
|
|
54
|
+
else
|
|
55
|
+
@manifest
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
attr_writer :manifest
|
|
59
|
+
|
|
60
|
+
# Directory to write compiled assets too. As well as the manifest file.
|
|
61
|
+
#
|
|
62
|
+
# t.output = "./public/assets"
|
|
63
|
+
#
|
|
64
|
+
attr_accessor :output
|
|
65
|
+
|
|
66
|
+
# Array of asset logical paths to compile.
|
|
67
|
+
#
|
|
68
|
+
# t.assets = %w( application.js jquery.js application.css )
|
|
69
|
+
#
|
|
70
|
+
attr_accessor :assets
|
|
71
|
+
|
|
72
|
+
# Minimum number of old assets to keep. See Sprockets::Manifest#clean for more information.
|
|
73
|
+
attr_accessor :keep
|
|
74
|
+
|
|
75
|
+
# Assets created within this age will be kept. See Sprockets::Manifest#clean for more information.
|
|
76
|
+
attr_accessor :age
|
|
77
|
+
|
|
78
|
+
# Logger to use during rake tasks. Defaults to using stderr.
|
|
79
|
+
#
|
|
80
|
+
# t.logger = Logger.new($stdout)
|
|
81
|
+
#
|
|
82
|
+
attr_accessor :logger
|
|
83
|
+
|
|
84
|
+
# Returns logger level Integer.
|
|
85
|
+
def log_level
|
|
86
|
+
@logger.level
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Set logger level with constant or symbol.
|
|
90
|
+
#
|
|
91
|
+
# t.log_level = Logger::INFO
|
|
92
|
+
# t.log_level = :debug
|
|
93
|
+
#
|
|
94
|
+
def log_level=(level)
|
|
95
|
+
if level.is_a?(Integer)
|
|
96
|
+
@logger.level = level
|
|
97
|
+
else
|
|
98
|
+
@logger.level = Logger.const_get(level.to_s.upcase)
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def initialize(name = :assets)
|
|
103
|
+
@name = name
|
|
104
|
+
@environment = lambda { Sprockets::Environment.new(Dir.pwd) }
|
|
105
|
+
@manifest = lambda { Sprockets::Manifest.new(cached, output) }
|
|
106
|
+
@logger = Logger.new($stderr)
|
|
107
|
+
@logger.level = Logger::INFO
|
|
108
|
+
@keep = 2
|
|
109
|
+
@age = 3600
|
|
110
|
+
|
|
111
|
+
yield self if block_given?
|
|
112
|
+
|
|
113
|
+
define
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Define tasks
|
|
117
|
+
def define
|
|
118
|
+
desc name == :assets ? "Compile assets" : "Compile #{name} assets"
|
|
119
|
+
task name do
|
|
120
|
+
with_logger do
|
|
121
|
+
manifest.compile(assets)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
desc name == :assets ? "Remove all assets" : "Remove all #{name} assets"
|
|
126
|
+
task "clobber_#{name}" do
|
|
127
|
+
with_logger do
|
|
128
|
+
manifest.clobber
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
task clobber: ["clobber_#{name}"]
|
|
133
|
+
|
|
134
|
+
desc name == :assets ? "Clean old assets" : "Clean old #{name} assets"
|
|
135
|
+
task "clean_#{name}" do
|
|
136
|
+
with_logger do
|
|
137
|
+
manifest.clean(keep, age)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
task clean: ["clean_#{name}"]
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
private
|
|
145
|
+
# Sub out environment logger with our rake task logger that
|
|
146
|
+
# writes to stderr.
|
|
147
|
+
def with_logger
|
|
148
|
+
if env = manifest.environment
|
|
149
|
+
old_logger = env.logger
|
|
150
|
+
env.logger = @logger
|
|
151
|
+
end
|
|
152
|
+
yield
|
|
153
|
+
ensure
|
|
154
|
+
env.logger = old_logger if env
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'sprockets/uri_utils'
|
|
3
|
+
require 'sprockets/path_utils'
|
|
4
|
+
|
|
5
|
+
module Sprockets
|
|
6
|
+
# This is a processor designed to add a source map "comment"
|
|
7
|
+
# to the bottom of a css or JS file that is serving a source
|
|
8
|
+
# map. An example of a comment might look like this
|
|
9
|
+
#
|
|
10
|
+
# //# application.js-80af0efcc960fc2ac93eda2f7b12e3db40ab360bf6ea269ceed3bea3678326f9.map
|
|
11
|
+
#
|
|
12
|
+
# As an asset is built it gets source map information added
|
|
13
|
+
# to the `asset.to_hash[:metadata][:map]` key. This contains all the
|
|
14
|
+
# information that is needed to build a source map file.
|
|
15
|
+
#
|
|
16
|
+
# To add this comment we must have an asset we can link to.
|
|
17
|
+
# To do this we ensure that the original asset is loaded, then
|
|
18
|
+
# we use a use a special mime type. For example `application/js-sourcemap+json`
|
|
19
|
+
# for a JS source map.
|
|
20
|
+
#
|
|
21
|
+
# This will trigger a new asset to be loaded and generated by the
|
|
22
|
+
# `SourceMapProcessor` processor.
|
|
23
|
+
#
|
|
24
|
+
# Finally once we have that file, we can generate a link to it
|
|
25
|
+
# with it's full fingerprint. This is done and then
|
|
26
|
+
# added to the original asset as a comment at the bottom.
|
|
27
|
+
#
|
|
28
|
+
class AddSourceMapCommentToAssetProcessor
|
|
29
|
+
def self.call(input)
|
|
30
|
+
|
|
31
|
+
case input[:content_type]
|
|
32
|
+
when "application/javascript"
|
|
33
|
+
comment = "\n//# sourceMappingURL=%s"
|
|
34
|
+
map_type = "application/js-sourcemap+json"
|
|
35
|
+
when "text/css"
|
|
36
|
+
comment = "\n/*# sourceMappingURL=%s */"
|
|
37
|
+
map_type = "application/css-sourcemap+json"
|
|
38
|
+
else
|
|
39
|
+
fail input[:content_type]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
env = input[:environment]
|
|
43
|
+
|
|
44
|
+
uri, _ = env.resolve!(input[:filename], accept: input[:content_type])
|
|
45
|
+
asset = env.load(uri)
|
|
46
|
+
|
|
47
|
+
uri, _ = env.resolve!(input[:filename], accept: map_type)
|
|
48
|
+
map = env.load(uri)
|
|
49
|
+
|
|
50
|
+
uri, params = URIUtils.parse_asset_uri(input[:uri])
|
|
51
|
+
uri = env.expand_from_root(params[:index_alias]) if params[:index_alias]
|
|
52
|
+
path = PathUtils.relative_path_from(PathUtils.split_subpath(input[:load_path], uri), map.digest_path)
|
|
53
|
+
|
|
54
|
+
asset.metadata.merge(
|
|
55
|
+
data: asset.source + (comment % path) + "\n",
|
|
56
|
+
links: asset.links + [asset.uri, map.uri]
|
|
57
|
+
)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
require 'sprockets/digest_utils'
|
|
4
|
+
|
|
5
|
+
module Sprockets
|
|
6
|
+
class Asset
|
|
7
|
+
attr_reader :logical_path
|
|
8
|
+
|
|
9
|
+
# Private: Initialize Asset wrapper from attributes Hash.
|
|
10
|
+
#
|
|
11
|
+
# Asset wrappers should not be initialized directly, only
|
|
12
|
+
# Environment#find_asset should vend them.
|
|
13
|
+
#
|
|
14
|
+
# attributes - Hash of ivars
|
|
15
|
+
#
|
|
16
|
+
# Returns Asset.
|
|
17
|
+
def initialize(attributes = {})
|
|
18
|
+
@attributes = attributes
|
|
19
|
+
@content_type = attributes[:content_type]
|
|
20
|
+
@filename = attributes[:filename]
|
|
21
|
+
@id = attributes[:id]
|
|
22
|
+
@load_path = attributes[:load_path]
|
|
23
|
+
@logical_path = attributes[:logical_path]
|
|
24
|
+
@metadata = attributes[:metadata]
|
|
25
|
+
@name = attributes[:name]
|
|
26
|
+
@source = attributes[:source]
|
|
27
|
+
@uri = attributes[:uri]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Internal: Return all internal instance variables as a hash.
|
|
31
|
+
#
|
|
32
|
+
# Returns a Hash.
|
|
33
|
+
def to_hash
|
|
34
|
+
@attributes
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Public: Metadata accumulated from pipeline process.
|
|
38
|
+
#
|
|
39
|
+
# The API status of the keys is dependent on the pipeline processors
|
|
40
|
+
# itself. So some values maybe considered public and others internal.
|
|
41
|
+
# See the pipeline processor documentation itself.
|
|
42
|
+
#
|
|
43
|
+
# Returns Hash.
|
|
44
|
+
attr_reader :metadata
|
|
45
|
+
|
|
46
|
+
# Public: Returns String path of asset.
|
|
47
|
+
attr_reader :filename
|
|
48
|
+
|
|
49
|
+
# Internal: Unique asset object ID.
|
|
50
|
+
#
|
|
51
|
+
# Returns a String.
|
|
52
|
+
attr_reader :id
|
|
53
|
+
|
|
54
|
+
# Public: Internal URI to lookup asset by.
|
|
55
|
+
#
|
|
56
|
+
# NOT a publicly accessible URL.
|
|
57
|
+
#
|
|
58
|
+
# Returns URI.
|
|
59
|
+
attr_reader :uri
|
|
60
|
+
|
|
61
|
+
# Public: Return logical path with digest spliced in.
|
|
62
|
+
#
|
|
63
|
+
# "foo/bar-37b51d194a7513e45b56f6524f2d51f2.js"
|
|
64
|
+
#
|
|
65
|
+
# Returns String.
|
|
66
|
+
def digest_path
|
|
67
|
+
if DigestUtils.already_digested?(@name)
|
|
68
|
+
logical_path
|
|
69
|
+
else
|
|
70
|
+
logical_path.sub(/\.(\w+)$/) { |ext| "-#{etag}#{ext}" }
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Public: Return load path + logical path with digest spliced in.
|
|
75
|
+
#
|
|
76
|
+
# Returns String.
|
|
77
|
+
def full_digest_path
|
|
78
|
+
File.join(@load_path, digest_path)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Public: Returns String MIME type of asset. Returns nil if type is unknown.
|
|
82
|
+
attr_reader :content_type
|
|
83
|
+
|
|
84
|
+
# Public: Get all externally linked asset filenames from asset.
|
|
85
|
+
#
|
|
86
|
+
# All linked assets should be compiled anytime this asset is.
|
|
87
|
+
#
|
|
88
|
+
# Returns Set of String asset URIs.
|
|
89
|
+
def links
|
|
90
|
+
metadata[:links] || Set.new
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Public: Return `String` of concatenated source.
|
|
94
|
+
#
|
|
95
|
+
# Returns String.
|
|
96
|
+
def source
|
|
97
|
+
if @source
|
|
98
|
+
@source
|
|
99
|
+
else
|
|
100
|
+
# File is read everytime to avoid memory bloat of large binary files
|
|
101
|
+
File.binread(filename)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Public: Alias for #source.
|
|
106
|
+
#
|
|
107
|
+
# Returns String.
|
|
108
|
+
def to_s
|
|
109
|
+
source
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Public: Get charset of source.
|
|
113
|
+
#
|
|
114
|
+
# Returns a String charset name or nil if binary.
|
|
115
|
+
def charset
|
|
116
|
+
metadata[:charset]
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Public: Returns Integer length of source.
|
|
120
|
+
def length
|
|
121
|
+
metadata[:length]
|
|
122
|
+
end
|
|
123
|
+
alias_method :bytesize, :length
|
|
124
|
+
|
|
125
|
+
# Public: Returns String byte digest of source.
|
|
126
|
+
def digest
|
|
127
|
+
metadata[:digest]
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Private: Return the version of the environment where the asset was generated.
|
|
131
|
+
def environment_version
|
|
132
|
+
metadata[:environment_version]
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Public: Returns String hexdigest of source.
|
|
136
|
+
def hexdigest
|
|
137
|
+
DigestUtils.pack_hexdigest(digest)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Public: ETag String of Asset.
|
|
141
|
+
def etag
|
|
142
|
+
version = environment_version
|
|
143
|
+
|
|
144
|
+
if version && version != ""
|
|
145
|
+
DigestUtils.hexdigest(version + digest)
|
|
146
|
+
else
|
|
147
|
+
DigestUtils.pack_hexdigest(digest)
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Public: Returns String base64 digest of source.
|
|
152
|
+
def base64digest
|
|
153
|
+
DigestUtils.pack_base64digest(digest)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Public: A "named information" URL for subresource integrity.
|
|
157
|
+
def integrity
|
|
158
|
+
DigestUtils.integrity_uri(digest)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# Public: Add enumerator to allow `Asset` instances to be used as Rack
|
|
162
|
+
# compatible body objects.
|
|
163
|
+
#
|
|
164
|
+
# block
|
|
165
|
+
# part - String body chunk
|
|
166
|
+
#
|
|
167
|
+
# Returns nothing.
|
|
168
|
+
def each
|
|
169
|
+
yield to_s
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Deprecated: Save asset to disk.
|
|
173
|
+
#
|
|
174
|
+
# filename - String target
|
|
175
|
+
#
|
|
176
|
+
# Returns nothing.
|
|
177
|
+
def write_to(filename)
|
|
178
|
+
FileUtils.mkdir_p File.dirname(filename)
|
|
179
|
+
|
|
180
|
+
PathUtils.atomic_write(filename) do |f|
|
|
181
|
+
f.write source
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
nil
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# Public: Pretty inspect
|
|
188
|
+
#
|
|
189
|
+
# Returns String.
|
|
190
|
+
def inspect
|
|
191
|
+
"#<#{self.class}:#{object_id.to_s(16)} #{uri.inspect}>"
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Public: Implements Object#hash so Assets can be used as a Hash key or
|
|
195
|
+
# in a Set.
|
|
196
|
+
#
|
|
197
|
+
# Returns Integer hash of the id.
|
|
198
|
+
def hash
|
|
199
|
+
id.hash
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# Public: Compare assets.
|
|
203
|
+
#
|
|
204
|
+
# Assets are equal if they share the same path and digest.
|
|
205
|
+
#
|
|
206
|
+
# Returns true or false.
|
|
207
|
+
def eql?(other)
|
|
208
|
+
self.class == other.class && self.id == other.id
|
|
209
|
+
end
|
|
210
|
+
alias_method :==, :eql?
|
|
211
|
+
end
|
|
212
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Sprockets
|
|
3
|
+
module Autoload
|
|
4
|
+
autoload :Babel, 'sprockets/autoload/babel'
|
|
5
|
+
autoload :Closure, 'sprockets/autoload/closure'
|
|
6
|
+
autoload :CoffeeScript, 'sprockets/autoload/coffee_script'
|
|
7
|
+
autoload :Eco, 'sprockets/autoload/eco'
|
|
8
|
+
autoload :EJS, 'sprockets/autoload/ejs'
|
|
9
|
+
autoload :JSMinC, 'sprockets/autoload/jsminc'
|
|
10
|
+
autoload :Sass, 'sprockets/autoload/sass'
|
|
11
|
+
autoload :SassC, 'sprockets/autoload/sassc'
|
|
12
|
+
autoload :Uglifier, 'sprockets/autoload/uglifier'
|
|
13
|
+
autoload :YUI, 'sprockets/autoload/yui'
|
|
14
|
+
autoload :Zopfli, 'sprockets/autoload/zopfli'
|
|
15
|
+
end
|
|
16
|
+
end
|