asset 0.1.5 → 0.1.6

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/asset.gemspec +2 -2
  3. data/lib/assets/util.rb +15 -11
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79324a6a074bc04bca16da39d57e2f4dc0c152b5
4
- data.tar.gz: 17ba912dfa3881fb46828ba8743e5f3763611311
3
+ metadata.gz: e22ae9abea9fbf33633e5884f0da5df397e9e318
4
+ data.tar.gz: ba47b72995401b3f3e74f10fc57dee2ed76bbf5d
5
5
  SHA512:
6
- metadata.gz: 04e03ba158217c029ba9cde16659b6f1b77dc1237a281365c91b181348c0f580afa7abd2a6dff05ab2cd22c0dd73c6c961cdaa5ab81829c97179fb970a42abf5
7
- data.tar.gz: bc060a99a62b72841ace1024d22f4fa965d2497fa4c34219ef872ccd1bf9e300353afb63d8a614eb02b6fa9b5e975048476f29bc4a03944d75bbc839b76fbb83
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.5'
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(path, time = mtime(path))
16
- Digest::MD5.hexdigest(%{#{path}#{time.to_i}})
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
- file =~ /(js|css)\/(.+)/
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(name, modified), modified)
31
+ manifest << ::Asset::Item.new(name, type, digest(File.read(file)), modified)
32
32
  end
33
33
 
34
34
  # Insert the css bundle
35
- max = manifest.select{|r| r.type == 'css'}.map{|r| r.modified}.max
36
- manifest.insert(0, ::Asset::Item.new('bundle.css', 'css', digest('bundle.css', max), max))
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
- max = manifest.select{|r| r.type == 'js'}.map{|r| r.modified}.max
40
- manifest.insert(0, ::Asset::Item.new('bundle.js', 'js', digest('bundle.js', max), max))
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.5
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: []