sinatra-bundles 0.5.2 → 0.5.3

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/Gemfile CHANGED
@@ -1,3 +1,2 @@
1
1
  source 'http://rubygems.org'
2
-
3
- gemspec
2
+ gemspec
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+ gemspec
3
+ gem 'sinatra', '1.2'
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+ gemspec
3
+ gem 'sinatra', '1.3'
@@ -1,27 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sinatra-bundles (0.5.1)
4
+ sinatra-bundles (0.5.2)
5
5
  packr (~> 3.1.0)
6
6
  rack (~> 1.0)
7
7
  rainpress (~> 1.0)
8
- sinatra (~> 1.0)
8
+ sinatra (~> 1.2)
9
9
 
10
10
  GEM
11
11
  remote: http://rubygems.org/
12
12
  specs:
13
- columnize (0.3.3)
14
- diff-lcs (1.1.2)
15
- linecache (0.45)
16
- oyster (0.9.4)
17
- packr (3.1.0)
18
- oyster
19
- rack (1.3.0)
20
- rack-test (0.6.0)
13
+ diff-lcs (1.1.3)
14
+ oyster (0.9.5)
15
+ packr (3.1.1)
16
+ oyster (>= 0.9.5)
17
+ rack (1.3.5)
18
+ rack-protection (1.1.4)
19
+ rack
20
+ rack-test (0.6.1)
21
21
  rack (>= 1.0)
22
22
  rainpress (1.0)
23
- rake (0.9.2)
24
- require_relative (1.0.2)
23
+ rake (0.9.2.2)
24
+ require_relative (1.0.3)
25
25
  rspec (2.6.0)
26
26
  rspec-core (~> 2.6.0)
27
27
  rspec-expectations (~> 2.6.0)
@@ -30,25 +30,20 @@ GEM
30
30
  rspec-expectations (2.6.0)
31
31
  diff-lcs (~> 1.1.2)
32
32
  rspec-mocks (2.6.0)
33
- ruby-debug (0.10.4)
34
- columnize (>= 0.1)
35
- ruby-debug-base (~> 0.10.4.0)
36
- ruby-debug-base (0.10.4)
37
- linecache (>= 0.3)
38
- sinatra (1.2.6)
39
- rack (~> 1.1)
40
- tilt (< 2.0, >= 1.2.2)
41
- tilt (1.3.2)
42
- yard (0.7.2)
33
+ sinatra (1.3.1)
34
+ rack (>= 1.3.4, ~> 1.3)
35
+ rack-protection (>= 1.1.2, ~> 1.1)
36
+ tilt (>= 1.3.3, ~> 1.3)
37
+ tilt (1.3.3)
38
+ yard (0.7.3)
43
39
 
44
40
  PLATFORMS
45
41
  ruby
46
42
 
47
43
  DEPENDENCIES
48
- rack-test (>= 0.5.3)
44
+ rack-test (~> 0.6.0)
49
45
  rake
50
46
  require_relative
51
- rspec (~> 2.6)
52
- ruby-debug
47
+ rspec (~> 2.6.0)
53
48
  sinatra-bundles!
54
49
  yard
data/Rakefile CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'bundler'
3
3
  require 'date'
4
- require 'ruby-debug'
5
4
 
6
5
  #############################################################################
7
6
  #
@@ -1,7 +1,7 @@
1
1
  module Sinatra
2
2
  # Main Bundles Module
3
3
  module Bundles
4
- Version = '0.5.2'
4
+ Version = '0.5.3'
5
5
 
6
6
  mypath = File.dirname(__FILE__)
7
7
  autoload :Helpers, "#{mypath}/bundles/helpers"
@@ -62,7 +62,7 @@ module Sinatra
62
62
  end
63
63
 
64
64
  app.get(%r{/#{Regexp.quote(app.javascripts)}/bundles/(\w+)(?:/(\d+))?\.js}) do |bundle, stamp| # Don't really care about the stamp.
65
- content_type('text/javascript')
65
+ content_type('application/javascript')
66
66
  headers['Vary'] = 'Accept-Encoding'
67
67
  if settings.cache_bundles
68
68
  expires(settings.bundle_cache_time, :public, :must_revalidate)
@@ -21,17 +21,14 @@ module Sinatra
21
21
  def files
22
22
  @files ||= @names.map do |f|
23
23
  full_path = path(f)
24
- if File.file?(full_path)
25
- f
26
- else
27
- ext = File.extname(full_path)
28
- Dir[full_path].map do |file|
29
- if File.exists?(file)
30
- file.chomp(ext).gsub("#{root}/", '')
31
- end
24
+ next f if File.file?(full_path)
25
+ ext = File.extname(full_path)
26
+ Dir[full_path].sort.map do |file|
27
+ if File.exists?(file)
28
+ file.chomp(ext).gsub("#{root}/", '')
32
29
  end
33
30
  end
34
- end.flatten.uniq
31
+ end.flatten.compact.uniq
35
32
  end
36
33
 
37
34
  # Since we pass Bundles back as the body,
@@ -82,6 +79,10 @@ module Sinatra
82
79
 
83
80
  private
84
81
 
82
+ def public_folder
83
+ @public ||= @app.respond_to?(:public_folder) ? @app.public_folder : @app.public
84
+ end
85
+
85
86
  def options_hash
86
87
  {
87
88
  :compress => @app.compress_bundles,
@@ -94,7 +95,7 @@ module Sinatra
94
95
  #
95
96
  # @return [Integer] The timestamp of the bundle
96
97
  def stamp
97
- files.map { |f| File.mtime(path(f)) }.sort.last.to_i
98
+ files.map { |f| File.mtime(path(f)) }.max.to_i
98
99
  end
99
100
  end
100
101
  end
@@ -23,7 +23,7 @@ module Sinatra
23
23
 
24
24
  # The root of these bundles, for path purposes
25
25
  def root
26
- @root ||= File.join(@app.public, @app.javascripts)
26
+ @root ||= File.join(public_folder, @app.javascripts)
27
27
  end
28
28
 
29
29
  protected
@@ -25,7 +25,7 @@ module Sinatra
25
25
 
26
26
  # The root of these bundles, for path purposes
27
27
  def root
28
- @root ||= File.join(@app.public, @app.stylesheets)
28
+ @root ||= File.join(public_folder, @app.stylesheets)
29
29
  end
30
30
 
31
31
  protected
@@ -15,8 +15,8 @@ Gem::Specification.new do |s|
15
15
  ## If your rubyforge_project name is different, then edit it and comment out
16
16
  ## the sub! line in the Rakefile
17
17
  s.name = 'sinatra-bundles'
18
- s.version = '0.5.2'
19
- s.date = '2011-06-18'
18
+ s.version = '0.5.3'
19
+ s.date = '2011-10-30'
20
20
 
21
21
  ## Make sure your summary is short. The description may be as long
22
22
  ## as you like.
@@ -39,15 +39,14 @@ Gem::Specification.new do |s|
39
39
  s.add_dependency('rainpress', ['~> 1.0'])
40
40
  s.add_dependency('packr', ['~> 3.1.0'])
41
41
  s.add_dependency('rack', ['~> 1.0'])
42
- s.add_dependency('sinatra', ['~> 1.0'])
42
+ s.add_dependency('sinatra', ['~> 1.2'])
43
43
 
44
44
  ## List your development dependencies here. Development dependencies are
45
45
  ## those that are only needed during development
46
- s.add_development_dependency('rspec', ['~> 2.6'])
47
- s.add_development_dependency('rack-test', ['>= 0.5.3'])
46
+ s.add_development_dependency('rspec', ['~> 2.6.0'])
47
+ s.add_development_dependency('rack-test', ['~> 0.6.0'])
48
48
  s.add_development_dependency('yard')
49
49
  s.add_development_dependency('rake')
50
- s.add_development_dependency('ruby-debug')
51
50
  s.add_development_dependency('require_relative')
52
51
 
53
52
  ## Leave this section as-is. It will be automatically generated from the
@@ -56,6 +55,8 @@ Gem::Specification.new do |s|
56
55
  # = MANIFEST =
57
56
  s.files = %w[
58
57
  Gemfile
58
+ Gemfile.1.2
59
+ Gemfile.1.3
59
60
  Gemfile.lock
60
61
  LICENSE
61
62
  README.md
@@ -1,5 +1,5 @@
1
1
  function goodbye(name) {
2
- alert('Hello, ' + name);
2
+ alert('Goodbye, ' + name);
3
3
  }
4
4
 
5
5
  goodbye('Bob');
@@ -9,15 +9,17 @@ require 'base_app'
9
9
  describe 'sinatra-bundles' do
10
10
  def app(env = :test)
11
11
  case env
12
- when :production
13
- ProductionApp
14
- when :custom
15
- CustomApp
16
- else
17
- TestApp
12
+ when :production then ProductionApp
13
+ when :custom then CustomApp
14
+ else TestApp
18
15
  end
19
16
  end
20
17
 
18
+ def get_base_app(a)
19
+ return a if a.is_a?(Sinatra::Base)
20
+ get_base_app(a.instance_eval { @app })
21
+ end
22
+
21
23
  def stamp(type, ext, names)
22
24
  names.map do |name|
23
25
  File.expand_path(File.join(File.dirname(__FILE__), 'public', type, "#{name}.#{ext}"))
@@ -86,37 +88,30 @@ describe 'sinatra-bundles' do
86
88
  end
87
89
 
88
90
  it 'should create a tag without a stamp if stamps are disabled' do
89
- app.new.instance_eval do
90
- @app.instance_eval do
91
- settings.disable(:stamp_bundles)
92
- javascript_bundle_include_tag(:test)
93
- end
91
+ get_base_app(app.new).instance_eval do
92
+ settings.disable(:stamp_bundles)
93
+ javascript_bundle_include_tag(:test)
94
94
  end.should == "<script type='text/javascript' src='/javascripts/bundles/test.js'></script>"
95
95
  end
96
96
 
97
97
  it 'should create cusomized tag if path is CUSTOM' do
98
- app(:custom).new.instance_eval do
99
- @app.instance_eval do
100
- settings.disable(:stamp_bundles)
101
- javascript_bundle_include_tag(:test)
102
- end
98
+ get_base_app(app(:custom).new).instance_eval do
99
+ settings.disable(:stamp_bundles)
100
+ javascript_bundle_include_tag(:test)
103
101
  end.should == "<script type='text/javascript' src='/s/js/bundles/test.js'></script>"
104
102
  end
105
103
 
106
104
  it 'should stamp bundles with the timestamp of the newest file in the bundle' do
107
- app.new.instance_eval do
108
- @app.instance_eval do
109
- javascript_bundle_include_tag(:test)
110
- end
105
+ get_base_app(app.new).instance_eval do
106
+ javascript_bundle_include_tag(:test)
111
107
  end.should == "<script type='text/javascript' src='/javascripts/bundles/test/#{js_stamp(%w(eval test1 test2))}.js'></script>"
112
108
  end
113
109
 
114
110
  it 'should serve bundles' do
115
- get '/javascripts/bundles/test.js'
116
111
  # Bogus stamp
117
112
  get '/javascripts/bundles/test/987654.js'
118
113
  last_response.should be_ok
119
- last_response.headers['Content-Type'].should == 'text/javascript;charset=utf-8'
114
+ last_response.headers['Content-Type'].should == 'application/javascript;charset=utf-8'
120
115
  end
121
116
 
122
117
  it 'should concat files in order with newlines including one at the end' do
@@ -130,7 +125,7 @@ describe 'sinatra-bundles' do
130
125
  last_response.should be_ok
131
126
  last_response.headers['Vary'].should == 'Accept-Encoding'
132
127
  last_response.headers['Cache-Control'].should == 'public, must-revalidate, max-age=31536000'
133
- last_response.headers['Etag'].should == '"4f647cfd3ab71800da1b0d0b127e2cd4"'
128
+ last_response.headers['Etag'].should == '"02e4d9bd148e31bb3dc4fdc1c1d7037e"'
134
129
  end
135
130
 
136
131
  it 'should not shrink vars on javascript files that use eval' do
@@ -146,7 +141,7 @@ describe 'sinatra-bundles' do
146
141
  get '/javascripts/bundles/test2.js'
147
142
  last_response.should be_ok
148
143
  last_response.body.include?('eval').should be_false
149
- last_response.body.should == @scripts.reject { |s| s.match(/eval|splat/) }.sort.map { |path| File.read(path) }.join("\n") + "\n"
144
+ last_response.body.should == @scripts.reject { |s| s.match(/eval|splat/) }.map { |path| File.read(path) }.join("\n") + "\n"
150
145
  end
151
146
 
152
147
  it 'should handle the all scripts wildcard' do
@@ -193,11 +188,9 @@ describe 'sinatra-bundles' do
193
188
  end
194
189
 
195
190
  it 'should return a path' do
196
- app.new.instance_eval do
197
- @app.instance_eval do
198
- settings.disable(:stamp_bundles)
199
- settings.javascript_bundles[:test].to_path
200
- end
191
+ get_base_app(app.new).instance_eval do
192
+ settings.disable(:stamp_bundles)
193
+ settings.javascript_bundles[:test].to_path
201
194
  end.should == '/javascripts/bundles/test.js'
202
195
  end
203
196
 
@@ -237,44 +230,34 @@ describe 'sinatra-bundles' do
237
230
  end
238
231
 
239
232
  it 'should create a tag without a stamp if stamps are disabled' do
240
- app.new.instance_eval do
241
- @app.instance_eval do
242
- settings.disable(:stamp_bundles)
243
- stylesheet_bundle_link_tag(:test)
244
- end
233
+ get_base_app(app.new).instance_eval do
234
+ settings.disable(:stamp_bundles)
235
+ stylesheet_bundle_link_tag(:test)
245
236
  end.should == "<link type='text/css' href='/stylesheets/bundles/test.css' rel='stylesheet' media='all' />"
246
237
  end
247
238
 
248
239
  it 'should create a tag without a stamp if stamps are disabled CUSTOM' do
249
- app(:custom).new.instance_eval do
250
- @app.instance_eval do
251
- settings.disable(:stamp_bundles)
252
- stylesheet_bundle_link_tag(:test)
253
- end
240
+ get_base_app(app(:custom).new).instance_eval do
241
+ settings.disable(:stamp_bundles)
242
+ stylesheet_bundle_link_tag(:test)
254
243
  end.should == "<link type='text/css' href='/s/css/bundles/test.css' rel='stylesheet' media='all' />"
255
244
  end
256
245
 
257
246
  it 'should stamp bundles with the timestamp of the newest file in the bundle' do
258
- app.new.instance_eval do
259
- @app.instance_eval do
260
- stylesheet_bundle_link_tag(:test)
261
- end
247
+ get_base_app(app.new).instance_eval do
248
+ stylesheet_bundle_link_tag(:test)
262
249
  end.should == "<link type='text/css' href='/stylesheets/bundles/test/#{css_stamp(%w(test1 test2))}.css' rel='stylesheet' media='all' />"
263
250
  end
264
251
 
265
252
  it 'should create a tag with default media attribute set to all' do
266
- app.new.instance_eval do
267
- @app.instance_eval do
268
- stylesheet_bundle_link_tag(:test)
269
- end
253
+ get_base_app(app.new).instance_eval do
254
+ stylesheet_bundle_link_tag(:test)
270
255
  end.include?("media='all'").should be_true
271
256
  end
272
257
 
273
258
  it 'should create a tag with specified media attributes' do
274
- app.new.instance_eval do
275
- @app.instance_eval do
276
- stylesheet_bundle_link_tag(:test, [:screen, :print])
277
- end
259
+ get_base_app(app.new).instance_eval do
260
+ stylesheet_bundle_link_tag(:test, [:screen, :print])
278
261
  end.include?("media='screen, print'").should be_true
279
262
  end
280
263
 
@@ -335,11 +318,9 @@ describe 'sinatra-bundles' do
335
318
  end
336
319
 
337
320
  it 'should return a path' do
338
- app.new.instance_eval do
339
- @app.instance_eval do
340
- settings.disable(:stamp_bundles)
341
- settings.stylesheet_bundles[:test].to_path
342
- end
321
+ get_base_app(app.new).instance_eval do
322
+ settings.disable(:stamp_bundles)
323
+ settings.stylesheet_bundles[:test].to_path
343
324
  end.should == '/stylesheets/bundles/test.css'
344
325
  end
345
326
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-bundles
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 2
10
- version: 0.5.2
9
+ - 3
10
+ version: 0.5.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Huckstep
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-18 00:00:00 -06:00
18
+ date: 2011-10-30 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -72,11 +72,11 @@ dependencies:
72
72
  requirements:
73
73
  - - ~>
74
74
  - !ruby/object:Gem::Version
75
- hash: 15
75
+ hash: 11
76
76
  segments:
77
77
  - 1
78
- - 0
79
- version: "1.0"
78
+ - 2
79
+ version: "1.2"
80
80
  type: :runtime
81
81
  version_requirements: *id004
82
82
  - !ruby/object:Gem::Dependency
@@ -87,11 +87,12 @@ dependencies:
87
87
  requirements:
88
88
  - - ~>
89
89
  - !ruby/object:Gem::Version
90
- hash: 15
90
+ hash: 23
91
91
  segments:
92
92
  - 2
93
93
  - 6
94
- version: "2.6"
94
+ - 0
95
+ version: 2.6.0
95
96
  type: :development
96
97
  version_requirements: *id005
97
98
  - !ruby/object:Gem::Dependency
@@ -100,14 +101,14 @@ dependencies:
100
101
  requirement: &id006 !ruby/object:Gem::Requirement
101
102
  none: false
102
103
  requirements:
103
- - - ">="
104
+ - - ~>
104
105
  - !ruby/object:Gem::Version
105
- hash: 13
106
+ hash: 7
106
107
  segments:
107
108
  - 0
108
- - 5
109
- - 3
110
- version: 0.5.3
109
+ - 6
110
+ - 0
111
+ version: 0.6.0
111
112
  type: :development
112
113
  version_requirements: *id006
113
114
  - !ruby/object:Gem::Dependency
@@ -139,7 +140,7 @@ dependencies:
139
140
  type: :development
140
141
  version_requirements: *id008
141
142
  - !ruby/object:Gem::Dependency
142
- name: ruby-debug
143
+ name: require_relative
143
144
  prerelease: false
144
145
  requirement: &id009 !ruby/object:Gem::Requirement
145
146
  none: false
@@ -152,20 +153,6 @@ dependencies:
152
153
  version: "0"
153
154
  type: :development
154
155
  version_requirements: *id009
155
- - !ruby/object:Gem::Dependency
156
- name: require_relative
157
- prerelease: false
158
- requirement: &id010 !ruby/object:Gem::Requirement
159
- none: false
160
- requirements:
161
- - - ">="
162
- - !ruby/object:Gem::Version
163
- hash: 3
164
- segments:
165
- - 0
166
- version: "0"
167
- type: :development
168
- version_requirements: *id010
169
156
  description: Bundle CSS and Javascript assets to a single file, compress, and cache them for snappier web experiences.
170
157
  email: darkhelmet@darkhelmetlive.com
171
158
  executables: []
@@ -176,6 +163,8 @@ extra_rdoc_files: []
176
163
 
177
164
  files:
178
165
  - Gemfile
166
+ - Gemfile.1.2
167
+ - Gemfile.1.3
179
168
  - Gemfile.lock
180
169
  - LICENSE
181
170
  - README.md