propshaft 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b03a78a54847aa4fb74c996259230818db5262c8c246367f4826dd222f763d62
4
- data.tar.gz: c393121a10fcb3cd1b151077869673260afdf99d4a7294dd88b8f600e3debe55
3
+ metadata.gz: 4916558d76e8ddba23bdf10ae312e22ed3c819a6e8a29dbee96f5de1af5c4d1c
4
+ data.tar.gz: 1a463043b2d214683b39646eabe9041d927634cbed03eb723368574100fa3bb9
5
5
  SHA512:
6
- metadata.gz: f2807deda69e1f1ddb336985b69c4f2f617398450402ca60de1917599f5e6a8ad5b483386ffcd85cd62f3729ff9fb16d7a2d487e39e15de160c29342d03d4ba1
7
- data.tar.gz: d16949bc2e7b81634d310413ea0f29065dfbe9eb4e421fb2321b9709ef460c82eaf93b2ab73d07de23dbd8111730d7755a1995081d8986d96ed28916940b8e94
6
+ metadata.gz: b57b13ef013c61ac2059c853bd40eb3c24a0eb1391425d4d71bcc359e3cc63abfd892455ece2be410c00d61ed2c84b255ea83aaace5edad3a9876d6b3f4cfda7
7
+ data.tar.gz: 70c066315e322d9429ff51581796c94f21983ec2816ce8bd90dcbf6c1bfe401ae25670b14198194cb0e3b585e8a4817b853f8984f7e7e26db617b225de797c56
@@ -11,8 +11,12 @@ class Propshaft::LoadPath
11
11
  assets_by_path[asset_name]
12
12
  end
13
13
 
14
- def assets
15
- assets_by_path.values
14
+ def assets(content_types: nil)
15
+ if content_types
16
+ assets_by_path.values.select { |asset| asset.content_type.in?(content_types) }
17
+ else
18
+ assets_by_path.values
19
+ end
16
20
  end
17
21
 
18
22
  def manifest
@@ -1,5 +1,6 @@
1
1
  class Propshaft::Processor
2
2
  MANIFEST_FILENAME = ".manifest.json"
3
+ COMPRESSABLE_CONTENT_TYPES = [ Mime[:js], Mime[:css], Mime[:text], Mime[:svg] ]
3
4
 
4
5
  attr_reader :load_path, :output_path, :compilers
5
6
 
@@ -41,10 +42,6 @@ class Propshaft::Processor
41
42
  compile_asset(asset) || copy_asset(asset)
42
43
  end
43
44
 
44
- def copy_asset(asset)
45
- FileUtils.copy asset.path, output_path.join(asset.digested_path)
46
- end
47
-
48
45
  def compile_asset(asset)
49
46
  File.open(output_path.join(asset.digested_path), "w+") do |file|
50
47
  begin
@@ -56,10 +53,13 @@ class Propshaft::Processor
56
53
  end if compilers.compilable?(asset)
57
54
  end
58
55
 
56
+ def copy_asset(asset)
57
+ FileUtils.copy asset.path, output_path.join(asset.digested_path)
58
+ end
59
+
59
60
 
60
61
  def compress_assets
61
- # FIXME: Only try to compress text assets with brotli
62
- load_path.assets.each do |asset|
62
+ load_path.assets(content_types: COMPRESSABLE_CONTENT_TYPES).each do |asset|
63
63
  compress_asset output_path.join(asset.digested_path)
64
64
  end if compressor_available?
65
65
  end
@@ -1,3 +1,3 @@
1
1
  module Propshaft
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: propshaft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson