csscompress 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3bcac7ab2c8ad822c0c33debe3ef4e0b233ec7a7300d9046fe11f3cdc8eefb44
4
- data.tar.gz: 9d2d3d98d68f723f94b6fcd494d26e20097004285a665ac077291825fa5dc0c8
3
+ metadata.gz: 75ef7574672df524b20274f7deaef47683eec4558c713edd6cba223129c59491
4
+ data.tar.gz: 80872153f6e622744f79cf486f457e9c3494f9ad7865d4fb76648a14f2a21ff3
5
5
  SHA512:
6
- metadata.gz: f335b8f5bccaaa77d4d921629f6797f8b1c2ee2dec6ac77b1c7b3f69d34e7d6d3bec3120832130e2eaace7cb56fdefd1d52c8fc738983584a928f2b20e6a003b
7
- data.tar.gz: 88901742e9386db78af87f4f1c89fc06a7b986167057f0c9883246b8814fea758c458f46919274f626be362ef5dda57cd71b2ff959059ea314a8096cbc3389cd
6
+ metadata.gz: 0a22d517a045815343b28f56cf1e70db023c49d2e2b252436771616f035a9b3a6e24402e893f98d55e723d42eba51d63158a7b9d06432c1bf9eb12ad6efd5240
7
+ data.tar.gz: 645cac386629b8ac62d56919d60e6056c5fac1344ea7aa1f815211bc88aaf4b0e365bb27ee67ad6b8e23b8a941a9a8310fc052fc97cb51c9a0fc6a63f24b4c9f
data/README.md CHANGED
@@ -25,6 +25,14 @@ require "csscompress"
25
25
  minified_css_string = Csscompress.minify("/path/to/css/file")
26
26
  ```
27
27
 
28
+ ### Rails with Sprockets / Asset Pipeline
29
+
30
+ In `config/environments/production.rb` and `config/environments/test.rb`:
31
+
32
+ ```rb
33
+ config.assets.css_compressor = :csscompress
34
+ ```
35
+
28
36
  ## Contributing
29
37
 
30
38
  Bug reports and pull requests are welcome on GitHub at https://github.com/domchristie/csscompress. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/domchristie/csscompress/blob/main/CODE_OF_CONDUCT.md).
@@ -1,10 +1,19 @@
1
- compressor = ->(input) {
2
- Tempfile.create([input[:name], ".css"]) do |file|
3
- file << input[:data]
4
- file.close
5
- {data: Csscompress.minify(file.path)}
1
+ class CsscompressCompressor
2
+ VERSION = 1
3
+
4
+ def self.cache_key
5
+ "#{name}:#{Csscompress::VERSION}:#{VERSION}".freeze
6
+ end
7
+
8
+ def self.call(input)
9
+ puts "[#{name}] Compressing…"
10
+ Tempfile.create([input[:name], ".css"]) do |file|
11
+ file << input[:data]
12
+ file.close
13
+ {data: Csscompress.minify(file.path)}
14
+ end
6
15
  end
7
- }
16
+ end
8
17
 
9
18
  begin
10
19
  require "sprockets"
@@ -13,5 +22,5 @@ rescue LoadError
13
22
  end
14
23
 
15
24
  if defined?(Sprockets)
16
- Sprockets.register_compressor "text/css", :csscompress, compressor
25
+ Sprockets.register_compressor "text/css", :csscompress, CsscompressCompressor
17
26
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Csscompress
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csscompress
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dom Christie
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-13 00:00:00.000000000 Z
11
+ date: 2022-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs