virtual_asset_path 0.1.0 → 0.1.1

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -13,6 +13,13 @@ module ActionView::Helpers::AssetTagHelper
13
13
  if id.present?
14
14
  case VirtualAssetPath.style
15
15
  when :folder, nil then "/asset-v#{id}#{asset_path}"
16
+ when :suffix
17
+ suffix = "-asset-v#{id}"
18
+ if asset_path.include?('.')
19
+ asset_path.sub(/\.[^\.]*$/, "#{suffix}\\0")
20
+ else
21
+ "#{asset_path}#{suffix}"
22
+ end
16
23
  when :query then "#{asset_path}?#{id}"
17
24
  end
18
25
  else
@@ -45,7 +52,7 @@ module ActionView::Helpers::AssetTagHelper
45
52
  # overwrite to disable / use mtime ?
46
53
  def virtual_asset_folder_id(path)
47
54
  case VirtualAssetPath.method
48
- when :md5,nil then Digest::MD5.file(path).hexdigest[0..6]
55
+ when :MD5,nil then Digest::MD5.file(path).hexdigest[0..6]
49
56
  when :mtime then File.mtime(path).to_i.to_s
50
57
  else
51
58
  raise "unsupported hashing method"
@@ -0,0 +1 @@
1
+ baz
@@ -55,6 +55,24 @@ class VirtualAssetPathTest < ActionController::TestCase
55
55
  @response.body.strip.should == "<img alt=\"\" src=\"/asset-v#{File.mtime('test/public/bar/foo.jpg').to_i}/bar/foo.jpg\" />"
56
56
  end
57
57
 
58
+ test "caches with query" do
59
+ VirtualAssetPath.style = :query
60
+ get :index, :image => '/bar/foo.jpg'
61
+ @response.body.strip.should == "<img alt=\"\" src=\"/bar/foo.jpg?d41d8cd\" />"
62
+ end
63
+
64
+ test "caches with suffix" do
65
+ VirtualAssetPath.style = :suffix
66
+ get :index, :image => '/bar/foo.jpg'
67
+ @response.body.strip.should == "<img alt=\"\" src=\"/bar/foo-asset-vd41d8cd.jpg\" />"
68
+ end
69
+
70
+ test "caches with suffix and no ." do
71
+ VirtualAssetPath.style = :suffix
72
+ get :index, :image => '/bar/baz'
73
+ @response.body.strip.should == "<img alt=\"\" src=\"/bar/baz-asset-v258622b\" />"
74
+ end
75
+
58
76
  test "has a version" do
59
77
  VirtualAssetPath::VERSION.should =~ /^\d+\.\d+\.\d+$/
60
78
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{virtual_asset_path}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  "VERSION",
20
20
  "init.rb",
21
21
  "lib/virtual_asset_path.rb",
22
+ "test/public/bar/baz",
22
23
  "test/public/bar/foo.jpg",
23
24
  "test/test_helper.rb",
24
25
  "test/views/virtual_asset_path_test/index.erb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virtual_asset_path
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser
@@ -35,6 +35,7 @@ files:
35
35
  - VERSION
36
36
  - init.rb
37
37
  - lib/virtual_asset_path.rb
38
+ - test/public/bar/baz
38
39
  - test/public/bar/foo.jpg
39
40
  - test/test_helper.rb
40
41
  - test/views/virtual_asset_path_test/index.erb