asset 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/asset.gemspec +2 -2
- data/lib/assets/util.rb +15 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e22ae9abea9fbf33633e5884f0da5df397e9e318
|
4
|
+
data.tar.gz: ba47b72995401b3f3e74f10fc57dee2ed76bbf5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a861c4ef0817bf478f0e09087b8edfa4d9d8f9d763a322a5f162a7b9c2b820e774ff97ff94b2d80ea5707701dff3a57834e2ed599acc398cb53d510238bbe6f
|
7
|
+
data.tar.gz: 283001062c093ca36b3c23f10a16eb8d949a057f2492da706a7d0522200d66ffc0b0a4b6d04aa37e23a6949b3a78e6821545ba89b15cef02ee83122f49a48de2
|
data/asset.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'asset'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.6'
|
4
4
|
s.date = '2017-01-18'
|
5
|
-
s.summary = "Compress and serve your CSS and JS automatically"
|
5
|
+
s.summary = "Compress and serve your CSS and JS assets automatically"
|
6
6
|
s.description = "The only thing you need for your assets."
|
7
7
|
s.authors = ["Fugroup Limited"]
|
8
8
|
s.email = 'vidar@fugroup.net'
|
data/lib/assets/util.rb
CHANGED
@@ -12,32 +12,36 @@ module Asset
|
|
12
12
|
end
|
13
13
|
|
14
14
|
# Digest
|
15
|
-
def self.digest(
|
16
|
-
Digest::MD5.hexdigest(
|
15
|
+
def self.digest(string)
|
16
|
+
Digest::MD5.hexdigest(string)
|
17
17
|
end
|
18
18
|
|
19
19
|
# Load manifest
|
20
20
|
def self.load_manifest
|
21
|
-
list = Dir["#{Asset.path}/{css,js}/**/*"].select{|f| File.file?(f)}.map{|f| f.gsub(Asset.path + '/', '')}
|
22
21
|
manifest = []
|
23
|
-
list.each do |file|
|
24
|
-
|
25
|
-
type, name = $1, $2
|
22
|
+
list = Dir["#{Asset.path}/{css,js}/**/*"].select{|f| File.file?(f)}.each do |file|
|
23
|
+
# Extract type and name
|
24
|
+
file =~ /(js|css)\/(.+)$/; type, name = $1, $2
|
26
25
|
|
26
|
+
# Get the modified time
|
27
27
|
# Get the modified time of the asset
|
28
28
|
modified = mtime("#{type}/#{name}")
|
29
29
|
|
30
30
|
# Loading manifest with items
|
31
|
-
manifest << ::Asset::Item.new(name, type, digest(
|
31
|
+
manifest << ::Asset::Item.new(name, type, digest(File.read(file)), modified)
|
32
32
|
end
|
33
33
|
|
34
34
|
# Insert the css bundle
|
35
|
-
|
36
|
-
|
35
|
+
css = manifest.select{|r| r.type == 'css'}
|
36
|
+
# Get the max modified date and the keys
|
37
|
+
max, keys = css.map{|r| r.modified}.max, css.map{|r| r.key}.join
|
38
|
+
manifest.insert(0, ::Asset::Item.new('bundle.css', 'css', digest(keys), max))
|
37
39
|
|
38
40
|
# Insert the js bundle
|
39
|
-
|
40
|
-
|
41
|
+
js = manifest.select{|r| r.type == 'js'}
|
42
|
+
# Get the max modified date and the keys
|
43
|
+
max, keys = js.map{|r| r.modified}.max, js.map{|r| r.key}.join
|
44
|
+
manifest.insert(0, ::Asset::Item.new('bundle.js', 'js', digest(keys), max))
|
41
45
|
|
42
46
|
manifest
|
43
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asset
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fugroup Limited
|
@@ -221,5 +221,5 @@ rubyforge_project:
|
|
221
221
|
rubygems_version: 2.6.8
|
222
222
|
signing_key:
|
223
223
|
specification_version: 4
|
224
|
-
summary: Compress and serve your CSS and JS automatically
|
224
|
+
summary: Compress and serve your CSS and JS assets automatically
|
225
225
|
test_files: []
|