sinatra-exstatic-assets 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,9 +1,16 @@
1
1
  # CH CH CH CHANGES! #
2
2
 
3
+ ## Friday the 18th of April 2014, v2.0.1 ##
4
+
5
+ * Bug fix, remote urls were sometimes being prepended with the public folder, fixed.
6
+
7
+ ----
8
+
9
+
3
10
  ## Saturday the 25th of May 2013, v2.0.0 ##
4
11
 
5
12
  * First release as the renamed library.
6
13
  * Bumped version number to 2 to make complete break from previous version numbers.
7
14
  * Added this file!
8
15
 
9
- ----
16
+ ----
data/Gemfile CHANGED
@@ -13,6 +13,7 @@ group :test do
13
13
  gem "simplecov"
14
14
  gem 'turn', :require => false
15
15
  gem "rack-test-accepts", :require => "rack/test/accepts"
16
+ gem "timecop"
16
17
  end
17
18
 
18
19
  group :development do
@@ -0,0 +1 @@
1
+ // nowt
@@ -0,0 +1 @@
1
+ // nowt
@@ -1,6 +1,6 @@
1
1
  module Sinatra
2
2
  module Exstatic
3
3
  # Library version
4
- VERSION = "2.0.0"
4
+ VERSION = "2.0.1"
5
5
  end
6
6
  end
@@ -137,12 +137,13 @@ module Sinatra
137
137
  # @see Sinatra::Helpers#uri
138
138
  def sss_url_for(addr, options=nil)
139
139
  options ||= {}
140
- absolute = options.delete :absolute
140
+ opts = {timestamp: true}.merge options
141
+ absolute = opts.delete :absolute
141
142
  absolute = false if absolute.nil?
142
- script_tag = options.delete(:script_tag)
143
- script_tag = true if script_tag.nil?
143
+ script_tag = opts.delete(:script_tag)
144
+ script_tag = true if script_tag.nil? unless addr.is_uri?
144
145
  href = uri addr, absolute, script_tag
145
- addr.respond_to?(:querystring) ?
146
+ addr.respond_to?(:querystring) && opts[:timestamp] ?
146
147
  "#{href}#{addr.querystring}" :
147
148
  href
148
149
  end
@@ -193,7 +194,10 @@ module Sinatra
193
194
 
194
195
  # Make's sure the options don't get mixed up with the other args.
195
196
  def sss_extract_options(a)
196
- opts = a.last.respond_to?(:keys) ? a.pop : {}
197
+ opts = a.last.respond_to?(:keys) ?
198
+ a.pop :
199
+ {}
200
+ opts ||= {}
197
201
  [a, opts]
198
202
  end
199
203
 
@@ -283,7 +287,8 @@ module Sinatra
283
287
  # xhtml style like <link rel="shortcut icon" href="http://example.com/myicon.ico" />
284
288
  options[:rel] ||= settings.xhtml ? "shortcut icon" : "icon"
285
289
 
286
- options[:href] = sss_url_for(source, options.delete(:url_options))
290
+ url_options = options.delete(:url_options) || {}
291
+ options[:href] = sss_url_for(Asset.new(source), url_options.merge(timestamp: false))
287
292
 
288
293
  Tag.new "link", options
289
294
  end
data/spec/spec_helper.rb CHANGED
@@ -29,10 +29,19 @@ Dir[ File.join( Spec_dir, "/support/**/*.rb")].each do |f|
29
29
  end
30
30
 
31
31
  require 'rack/test/accepts'
32
+ require 'timecop'
32
33
 
33
34
  RSpec.configure do |config|
34
35
  config.treat_symbols_as_metadata_keys_with_true_values = true
35
36
 
36
37
  config.include Rack::Test::Accepts, :type => :request
38
+
39
+ config.before(:each, :time_sensitive => true) do
40
+ Timecop.freeze "2013-03-31 00:00:00 0000"
41
+ end
42
+
43
+ config.after(:each, :time_sensitive => true) do
44
+ Timecop.return
45
+ end
37
46
  end
38
47
 
@@ -22,7 +22,8 @@ describe Asset, :time_sensitive do
22
22
  its(:"is_uri?") { should be_false }
23
23
  its(:querystring) { should == "?ts=#{Time.now.to_i}" }
24
24
  end
25
- context "Given a url" do let(:filename) { "http://code.jquery.com/jquery-1.9.1.min.js" }
25
+ context "Given a url" do
26
+ let(:filename) { "http://code.jquery.com/jquery-1.9.1.min.js" }
26
27
  let(:expected) { "http://code.jquery.com/jquery-1.9.1.min.js" }
27
28
  it { should_not be_nil }
28
29
  it { should == expected }
@@ -111,12 +112,25 @@ describe "Private methods", :time_sensitive do
111
112
  it { should == expected }
112
113
  end
113
114
  context "Images" do
114
- let(:url) { "/images/foo.png" }
115
- let(:filename) { "/images/foo.png" }
116
- let(:expected) { %Q!<img src="/bar/images/foo.png?ts=#{time}" />! }
117
- subject { o.send :sss_image_tag, url }
118
- it { should_not be_nil }
119
- it { should == expected }
115
+ context "Local" do
116
+ let(:url) { "/images/foo.png" }
117
+ let(:filename) { "/images/foo.png" }
118
+ let(:expected) { %Q!<img src="/bar/images/foo.png?ts=#{time}" />! }
119
+ subject { o.send :sss_image_tag, url }
120
+ it { should_not be_nil }
121
+ it { should == expected }
122
+ end
123
+ context "Remote" do
124
+ let(:url) { "http://example.org/images/foo.png" }
125
+ let(:filename) { "/images/foo.png" }
126
+ let(:expected) { %Q!<img src="#{url}" />! }
127
+ subject {
128
+ o.send :sss_image_tag,
129
+ url
130
+ }
131
+ it { should_not be_nil }
132
+ it { should == expected }
133
+ end
120
134
  end
121
135
  end
122
136
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-exstatic-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-05-25 00:00:00.000000000 Z
13
+ date: 2014-04-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sinatra
@@ -48,12 +48,14 @@ files:
48
48
  - examples/app/public/css/screen.css
49
49
  - examples/app/public/favicon.ico
50
50
  - examples/app/public/images/3609420787_f7fc0e53c7.jpg
51
+ - examples/app/public/js/helpers.js
51
52
  - examples/app/views/index.erb
52
53
  - examples/app/views/layout.erb
53
54
  - examples/app2/main.rb
54
55
  - examples/app2/public/css/base.css
55
56
  - examples/app2/public/css/screen.css
56
57
  - examples/app2/public/favicon
58
+ - examples/app2/public/js/helpers.js
57
59
  - examples/app2/views/index.erb
58
60
  - examples/app2/views/layout.erb
59
61
  - examples/config.rb