foresth-cloudfront_asset_host 1.0.4 → 1.0.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.
data/README.markdown CHANGED
@@ -26,7 +26,7 @@ Include the gem in your app's `environment.rb` or `Gemfile`.
26
26
 
27
27
  ### Dependencies
28
28
 
29
- The gem relies on `openssl md5` and `gzip` utilities. Make sure they are available locally and on your servers.
29
+ The gem relies on `gzip` utility. Make sure it is available locally and on your servers.
30
30
 
31
31
  ### Configuration
32
32
 
@@ -34,6 +34,12 @@ Make sure your s3-credentials are stored in _config/s3.yml_ like this:
34
34
 
35
35
  access_key_id: 'access_key'
36
36
  secret_access_key: 'secret'
37
+
38
+ or with environment specified:
39
+
40
+ production:
41
+ access_key_id: 'access_key'
42
+ secret_access_key: 'secret'
37
43
 
38
44
  Create an initializer to configure the plugin _config/initializers/cloudfront_asset_host.rb_
39
45
 
@@ -45,10 +51,11 @@ Create an initializer to configure the plugin _config/initializers/cloudfront_as
45
51
 
46
52
  # Extended configuration
47
53
  CloudfrontAssetHost.configure do |config|
48
- config.bucket = "bucketname" # required
49
- config.cname = "assets.domain.com" # if you have a cname configured for your distribution or bucket
50
- config.key_prefix = "app/" # if you share the bucket and want to keep things separated
51
- config.s3_config = "#{RAILS_ROOT}/config/s3.yml" # Alternative location of your s3-config file
54
+ config.bucket = "bucketname" # required
55
+ config.cname = "assets.domain.com" # if you have a cname configured for your distribution or bucket
56
+ config.key_prefix = "app/" # if you share the bucket and want to keep things separated
57
+ config.plain_prefix = "" # prefix for paths to uncompressed files
58
+ config.s3_config = "#{RAILS_ROOT}/config/s3.yml" # Alternative location of your s3-config file
52
59
 
53
60
  # gzip related configuration
54
61
  config.gzip = true # enable gzipped assets (defaults to true)
@@ -57,6 +64,8 @@ Create an initializer to configure the plugin _config/initializers/cloudfront_as
57
64
 
58
65
  config.enabled = true if Rails.env.production? # only enable in production
59
66
  end
67
+
68
+ The _cname_ config option also accepts Proc or string with the "%d" parameter (e.g. "http://assets%d.example.com" for multiple hosts).
60
69
 
61
70
  ## Usage
62
71
 
@@ -73,10 +82,6 @@ When using in combination with SASS and/or asset_packager it is recommended to g
73
82
 
74
83
  Feel free to fork the project and send pull-requests.
75
84
 
76
- ## Known Limitations
77
-
78
- - Does not delete old assets
79
-
80
85
  ## Compatibility
81
86
 
82
87
  Tested on Rails 2.3.5 with SASS and AssetPackager plugins
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.4
1
+ 1.0.6
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{foresth-cloudfront_asset_host}
8
- s.version = "1.0.4"
8
+ s.version = "1.0.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Menno van der Sman"]
@@ -34,7 +34,7 @@ module CloudfrontAssetHost
34
34
  mattr_accessor :gzip_prefix
35
35
 
36
36
  # Key-prefix under which to store plain (unzipped) assets
37
- mattr_accessor :plain_prefix
37
+ mattr_accessor :plain_prefix
38
38
 
39
39
  # Which extensions are likely to occur in css files
40
40
  mattr_accessor :image_extensions
@@ -58,7 +58,7 @@ module CloudfrontAssetHost
58
58
 
59
59
  yield(self)
60
60
 
61
- if properly_configured?
61
+ if properly_configured? && enabled
62
62
  enable!
63
63
  end
64
64
  end
@@ -100,11 +100,15 @@ module CloudfrontAssetHost
100
100
  end
101
101
 
102
102
  def enable!
103
- if enabled
104
- ActionController::Base.asset_host = Proc.new { |source, request| CloudfrontAssetHost.asset_host(source, request) }
105
- ActionView::Helpers::AssetTagHelper.send(:alias_method_chain, :rewrite_asset_path, :cloudfront)
106
- ActionView::Helpers::AssetTagHelper.send(:alias_method_chain, :rails_asset_id, :cloudfront)
107
- end
103
+ ActionController::Base.asset_host = Proc.new { |source, request| CloudfrontAssetHost.asset_host(source, request) }
104
+ ActionView::Helpers::AssetTagHelper.send(:alias_method_chain, :rewrite_asset_path, :cloudfront)
105
+ ActionView::Helpers::AssetTagHelper.send(:alias_method_chain, :rails_asset_id, :cloudfront)
106
+ end
107
+
108
+ def disable!
109
+ ActionController::Base.asset_host = nil
110
+ ActionView::Helpers::AssetTagHelper.send(:alias_method, :rewrite_asset_path, :rewrite_asset_path_without_cloudfront)
111
+ ActionView::Helpers::AssetTagHelper.send(:alias_method, :rails_asset_id, :rails_asset_id_without_cloudfront)
108
112
  end
109
113
 
110
114
  def key_for_path(path)
@@ -34,7 +34,7 @@ module CloudfrontAssetHost
34
34
 
35
35
  if path.present? && File.exists?(path)
36
36
  key = CloudfrontAssetHost.key_for_path(path) + path.gsub(Rails.public_path, '')
37
- "url(#{CloudfrontAssetHost.asset_host}/#{key})"
37
+ "url(#{CloudfrontAssetHost.asset_host(url)}/#{key})"
38
38
  else
39
39
  puts "Could not extract path: #{path}"
40
40
  asset_link
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foresth-cloudfront_asset_host
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 4
10
- version: 1.0.4
9
+ - 6
10
+ version: 1.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Menno van der Sman