From c2736e6e1762908f74f040f4a6d87fd0fd2905e7 Mon Sep 17 00:00:00 2001 From: Pavel Kunc Date: Sat, 20 Mar 2010 15:20:52 +0000 Subject: [PATCH] [merb-assets] Moving :asset_timestamp to the Plugin config. It should be local to Merb::Plugin.config[:asset_helpers] not in the global configuration. --- merb-assets/lib/merb-assets.rb | 1 + merb-assets/lib/merb-assets/assets_mixin.rb | 10 +++++----- merb-assets/spec/merb-assets_spec.rb | 16 ++++++++-------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/merb-assets/lib/merb-assets.rb b/merb-assets/lib/merb-assets.rb index 3ae0d6ba..ae0b6d0b 100644 --- a/merb-assets/lib/merb-assets.rb +++ b/merb-assets/lib/merb-assets.rb @@ -12,6 +12,7 @@ :asset_domain => "assets%s", :domain => "my-awesome-domain.com", :use_ssl => false, + :asset_timestamp => false, # Global prefix/suffix for css/js include tags, overridable in js_include_tag and css_include_tag # diff --git a/merb-assets/lib/merb-assets/assets_mixin.rb b/merb-assets/lib/merb-assets/assets_mixin.rb index 4eb2c89a..a0d27ab0 100644 --- a/merb-assets/lib/merb-assets/assets_mixin.rb +++ b/merb-assets/lib/merb-assets/assets_mixin.rb @@ -35,10 +35,10 @@ def self.append_random_query_string?(intention, allow_default = true) # Merb::AssetsMixin.append_timestamp_query_string?(options[:timestamp], !absolute) # # @param [Boolean] intention: true if a timestamp string shall be appended - # @param [Boolean] allow_default: true if it's ok to use Merb::Config[:asset_timestamps] + # @param [Boolean] allow_default: true if it's ok to use Merb::Plugins.config[:asset_helpers][:asset_timestamp] # @return [Boolean] true if a timestamp query string shall be appended def self.append_timestamp_query_string?(intention, allow_default = true) - intention.nil? && allow_default ? Merb::Config[:asset_timestamps] : intention + intention.nil? && allow_default ? Merb::Plugins.config[:asset_helpers][:asset_timestamp] : intention end # Automatically generates link for CSS and JS @@ -148,7 +148,7 @@ def link_to(name, url='', opts={}) # Override the Merb::Config[:reload_templates] value. If true, a random query param will be appended # to the image url # @option opts [Boolean, String] :timestamp - # Override the Merb::Config[:asset_timestamp] value. If true, a timestamp query param will be appended + # Override the Merb::Plugins.config[:asset_helpers][:asset_timestamp] value. If true, a timestamp query param will be appended # to the image url. The value will be File.mtime(Merb.dir_for(:public) / path). # If String is passed than it will be used as the timestamp. # @@ -496,7 +496,7 @@ def include_required_css(options = {}) # Override the Merb::Config[:reload_templates] value. If true, a random query param will be appended # to the js url # @option opts [Boolean, String] :timestamp - # Override the Merb::Config[:asset_timestamp] value. If true, a timestamp query param will be appended + # Override the Merb::Plugins.config[:asset_helpers][:asset_timestamp] value. If true, a timestamp query param will be appended # to the image url. The value will be File.mtime(Merb.dir_for(:public) / path). # If String is passed than it will be used as the timestamp. # @@ -587,7 +587,7 @@ def js_include_tag(*scripts) # Override the Merb::Config[:reload_templates] value. If true, a random query param will be appended # to the css url # @option opts [Boolean, String] :timestamp - # Override the Merb::Config[:asset_timestamp] value. If true, a timestamp query param will be appended + # Override the Merb::Plugins.config[:asset_helper][:asset_timestamp] value. If true, a timestamp query param will be appended # to the image url. The value will be File.mtime(Merb.dir_for(:public) / path). # If String is passed than it will be used as the timestamp. # diff --git a/merb-assets/spec/merb-assets_spec.rb b/merb-assets/spec/merb-assets_spec.rb index 80342136..a32c9f17 100644 --- a/merb-assets/spec/merb-assets_spec.rb +++ b/merb-assets/spec/merb-assets_spec.rb @@ -184,12 +184,12 @@ end end -describe "With Merb::Config[:asset_timestamps] set," do +describe "With Merb::Plugins.config[:asset_helpers][:asset_timestamp] set," do before(:all) do - Merb::Config[:asset_timestamps] = true + Merb::Plugins.config[:asset_helpers][:asset_timestamp] = true end after(:all) do - Merb::Config[:asset_timestamps] = false + Merb::Plugins.config[:asset_helpers][:asset_timestamp] = false end it "should create image tag with absolute url" do @@ -358,19 +358,19 @@ end end - describe "with Merb::Config[:asset_timestamps] set" do + describe "with Merb::Plugins.config[:asset_helpers][:asset_timestamp] set" do it "should create a css include tag with a timestamp query string" do - Merb::Config[:asset_timestamps] = true + Merb::Plugins.config[:asset_helpers][:asset_timestamp] = true result = css_include_tag('style.css') result.should match(%r{/stylesheets/style.css\?\d+}) - Merb::Config[:asset_timestamps] = false + Merb::Plugins.config[:asset_helpers][:asset_timestamp] = false end it "should create a js include tag with a timestamp query string" do - Merb::Config[:asset_timestamps] = true + Merb::Plugins.config[:asset_helpers][:asset_timestamp] = true result = js_include_tag('jquery.js') result.should match(%r{/javascripts/jquery.js\?\d+}) - Merb::Config[:asset_timestamps] = false + Merb::Plugins.config[:asset_helpers][:asset_timestamp] = false end end