propshaft 0.9.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/propshaft/assembly.rb +3 -8
- data/lib/propshaft/asset.rb +11 -2
- data/lib/propshaft/output_path.rb +2 -9
- data/lib/propshaft/processor.rb +5 -5
- data/lib/propshaft/railtie.rb +1 -0
- data/lib/propshaft/resolver/dynamic.rb +2 -2
- data/lib/propshaft/resolver/static.rb +2 -2
- data/lib/propshaft/server.rb +1 -3
- data/lib/propshaft/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bdd01776a4cf66e324271ccb59f41d8473b2863c75ace4d2d75f7295e2fad36
|
4
|
+
data.tar.gz: c1e8d1e3a3bfaee8ee77bd53b760bc272df4d25f4fc4c494eb14e99bc125acd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fddd9f7d38b01958b449f966143894f065d8a0c35a51dcd0b5234230daf3ac7897107289af615f6484d253f883d6c2c5351a6281b1fd0f9465efd3df0d92e6ad
|
7
|
+
data.tar.gz: 26f5105052b942c55f41f6f049eb3e28c1200231a51edad58c41645b936f51fbe98721ae1823b2ec293243c369cadb657368be4afee35747450fb01d948cee93
|
data/lib/propshaft/assembly.rb
CHANGED
@@ -19,8 +19,8 @@ class Propshaft::Assembly
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def resolver
|
22
|
-
@resolver ||= if manifest_path.exist?
|
23
|
-
Propshaft::Resolver::Static.new manifest_path: manifest_path, prefix: config.prefix
|
22
|
+
@resolver ||= if config.manifest_path.exist?
|
23
|
+
Propshaft::Resolver::Static.new manifest_path: config.manifest_path, prefix: config.prefix
|
24
24
|
else
|
25
25
|
Propshaft::Resolver::Dynamic.new load_path: load_path, prefix: config.prefix
|
26
26
|
end
|
@@ -32,7 +32,7 @@ class Propshaft::Assembly
|
|
32
32
|
|
33
33
|
def processor
|
34
34
|
Propshaft::Processor.new \
|
35
|
-
load_path: load_path, output_path: config.output_path, compilers: compilers
|
35
|
+
load_path: load_path, output_path: config.output_path, compilers: compilers, manifest_path: config.manifest_path
|
36
36
|
end
|
37
37
|
|
38
38
|
def compilers
|
@@ -51,9 +51,4 @@ class Propshaft::Assembly
|
|
51
51
|
asset.send(path_type)
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
55
|
-
private
|
56
|
-
def manifest_path
|
57
|
-
config.output_path.join(Propshaft::Processor::MANIFEST_FILENAME)
|
58
|
-
end
|
59
54
|
end
|
data/lib/propshaft/asset.rb
CHANGED
@@ -4,12 +4,21 @@ require "action_dispatch/http/mime_type"
|
|
4
4
|
class Propshaft::Asset
|
5
5
|
attr_reader :path, :logical_path, :load_path
|
6
6
|
|
7
|
+
class << self
|
8
|
+
def extract_path_and_digest(digested_path)
|
9
|
+
digest = digested_path[/-([0-9a-zA-Z]{7,128})\.(?!digested)([^.]|.map)+\z/, 1]
|
10
|
+
path = digest ? digested_path.sub("-#{digest}", "") : digested_path
|
11
|
+
|
12
|
+
[path, digest]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
7
16
|
def initialize(path, logical_path:, load_path:)
|
8
17
|
@path, @logical_path, @load_path = path, Pathname.new(logical_path), load_path
|
9
18
|
end
|
10
19
|
|
11
|
-
def content
|
12
|
-
File.
|
20
|
+
def content(encoding: "ASCII-8BIT")
|
21
|
+
File.read(path, encoding: encoding)
|
13
22
|
end
|
14
23
|
|
15
24
|
def content_type
|
@@ -26,7 +26,7 @@ class Propshaft::OutputPath
|
|
26
26
|
Hash.new.tap do |files|
|
27
27
|
all_files_from_tree(path).each do |file|
|
28
28
|
digested_path = file.relative_path_from(path)
|
29
|
-
logical_path, digest = extract_path_and_digest(digested_path)
|
29
|
+
logical_path, digest = Propshaft::Asset.extract_path_and_digest(digested_path.to_s)
|
30
30
|
|
31
31
|
files[digested_path.to_s] = {
|
32
32
|
logical_path: logical_path.to_s,
|
@@ -42,7 +42,7 @@ class Propshaft::OutputPath
|
|
42
42
|
modified_at = [ 0, Time.now - mtime ].max
|
43
43
|
modified_at < expires_at || limit < count
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
def remove(path)
|
47
47
|
FileUtils.rm(@path.join(path))
|
48
48
|
Propshaft.logger.info "Removed #{path}"
|
@@ -51,11 +51,4 @@ class Propshaft::OutputPath
|
|
51
51
|
def all_files_from_tree(path)
|
52
52
|
path.children.flat_map { |child| child.directory? ? all_files_from_tree(child) : child }
|
53
53
|
end
|
54
|
-
|
55
|
-
def extract_path_and_digest(digested_path)
|
56
|
-
digest = digested_path.to_s[/-([0-9a-f]{7,128})\.(?!digested)[^.]+\z/, 1]
|
57
|
-
path = digest ? digested_path.sub("-#{digest}", "") : digested_path
|
58
|
-
|
59
|
-
[path, digest]
|
60
|
-
end
|
61
54
|
end
|
data/lib/propshaft/processor.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
require "propshaft/output_path"
|
2
2
|
|
3
3
|
class Propshaft::Processor
|
4
|
-
|
4
|
+
attr_reader :load_path, :output_path, :compilers, :manifest_path
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
def initialize(load_path:, output_path:, compilers:)
|
6
|
+
def initialize(load_path:, output_path:, compilers:, manifest_path:)
|
9
7
|
@load_path, @output_path = load_path, output_path
|
8
|
+
@manifest_path = manifest_path
|
10
9
|
@compilers = compilers
|
11
10
|
end
|
12
11
|
|
@@ -31,7 +30,8 @@ class Propshaft::Processor
|
|
31
30
|
|
32
31
|
|
33
32
|
def write_manifest
|
34
|
-
|
33
|
+
FileUtils.mkdir_p(File.dirname(manifest_path))
|
34
|
+
File.open(manifest_path, "wb+") do |manifest|
|
35
35
|
manifest.write load_path.manifest.to_json
|
36
36
|
end
|
37
37
|
end
|
data/lib/propshaft/railtie.rb
CHANGED
@@ -34,6 +34,7 @@ module Propshaft
|
|
34
34
|
config.assets.relative_url_root ||= app.config.relative_url_root
|
35
35
|
config.assets.output_path ||=
|
36
36
|
Pathname.new(File.join(app.config.paths["public"].first, app.config.assets.prefix))
|
37
|
+
config.assets.manifest_path ||= config.assets.output_path.join(".manifest.json")
|
37
38
|
|
38
39
|
app.assets = Propshaft::Assembly.new(app.config.assets)
|
39
40
|
|
@@ -12,9 +12,9 @@ module Propshaft::Resolver
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def read(logical_path)
|
15
|
+
def read(logical_path, encoding: "ASCII-8BIT")
|
16
16
|
if asset_path = parsed_manifest[logical_path]
|
17
|
-
manifest_path.dirname.join(asset_path)
|
17
|
+
File.read(manifest_path.dirname.join(asset_path), encoding: encoding)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
data/lib/propshaft/server.rb
CHANGED
@@ -35,10 +35,8 @@ class Propshaft::Server
|
|
35
35
|
private
|
36
36
|
def extract_path_and_digest(env)
|
37
37
|
full_path = Rack::Utils.unescape(env["PATH_INFO"].to_s.sub(/^\//, ""))
|
38
|
-
digest = full_path[/-([0-9a-zA-Z]{7,128})\.(?!digested)([^.]|.map)+\z/, 1]
|
39
|
-
path = digest ? full_path.sub("-#{digest}", "") : full_path
|
40
38
|
|
41
|
-
|
39
|
+
Propshaft::Asset.extract_path_and_digest(full_path)
|
42
40
|
end
|
43
41
|
|
44
42
|
if Gem::Version.new(Rack::RELEASE) < Gem::Version.new("3")
|
data/lib/propshaft/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: propshaft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
|
-
rubygems_version: 3.5.
|
117
|
+
rubygems_version: 3.5.16
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Deliver assets for Rails.
|