asset_hash 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/asset_hash.rb +3 -3
  2. metadata +3 -3
@@ -28,7 +28,7 @@ module AssetHash
28
28
  end
29
29
 
30
30
  def self.path_prefix
31
- File.join Rails.root, 'public'
31
+ defined?(Rails) ? File.join(Rails.root, 'public') : ''
32
32
  end
33
33
 
34
34
  def self.asset_paths=(paths)
@@ -53,10 +53,10 @@ module AssetHash
53
53
  }
54
54
  end
55
55
 
56
- def self.fingerprint(path)
56
+ def self.fingerprint(path, original_path = nil)
57
57
  path = File.join path_prefix, path unless path =~ /#{path_prefix}/
58
58
  begin
59
- d = Digest::MD5.file(path).hexdigest
59
+ d = Digest::MD5.file(original_path || path).hexdigest
60
60
  path = path.gsub(path_prefix, '')
61
61
  extension = (path =~ /\.gz$/ ? File.extname(File.basename(path, ".gz")) + ".gz" : File.extname(path))
62
62
  File.join File.dirname(path), "#{File.basename(path, extension)}-#{d}#{extension}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asset_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mime-types
17
- requirement: &70242249784880 !ruby/object:Gem::Requirement
17
+ requirement: &70360428650560 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: '1.16'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70242249784880
25
+ version_requirements: *70360428650560
26
26
  description: This gem allows you to copy your static assets to include a unique hash
27
27
  in their filename. By using this and modifying your Rails asset path you can easily
28
28
  enable your Rails application to serve static content using CloudFront with a custom