classy_assets 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0bb5c045b40c7a18eedbfa6a32e7a9a71c8ae9ed
4
- data.tar.gz: 4b20a1d196309da05e7edae4cdef3761c00dc3ed
3
+ metadata.gz: 5b2a4669a0892222ca15c7eb900fdb362d9e7d71
4
+ data.tar.gz: 7c3994fcfa62f5a9097337c9b1dd294654805da2
5
5
  SHA512:
6
- metadata.gz: 69ab2b9dd844a9ab983e60511ab054659c8200eacba3ce408a02006da957e5b100c82052ed6f3074f12cfa33e3fff24c191136f328bc92c61b686f5dcf3dbc56
7
- data.tar.gz: 63f2076784e5705129de6061bc7477944b2f6bdd9846fe1270364bc4931244c6d4ef0dd0e41a55bc5c6dd1bc972694c0169e10d0e917f81d8a2059345cd57624
6
+ metadata.gz: 66d0e7c3e2bebe79615c8a126fa17d98481b552e0b1e239ddba67b9a6fd85df1d2d82fbd980421b2e2f4cf785a79d95dee8b1cb1efef010c3968955d20402116
7
+ data.tar.gz: 7d04b3eb7ba3f67d766b7bff6328c5ffac2fe6684bb476d0cbab75ffffb86f0e841a8ed480f9a5f985a6c4637ae8ec2f51b64762e69ca568a885a4a3e178caa4
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,3 +1,3 @@
1
1
  module ClassyAssets
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -5,52 +5,52 @@ require 'classy_assets'
5
5
  module Rack
6
6
  class ClassyAssets < Sinatra::Base
7
7
  def initialize(app)
8
- super(app)
8
+ super(app)
9
+ @sprockets = ::ClassyAssets::Configuration.sprockets
9
10
  end
10
11
 
11
- set :sprockets, ::ClassyAssets::Configuration.sprockets
12
12
  set :asset_prefix, ::ClassyAssets::Configuration.asset_prefix
13
13
 
14
- get "/#{settings.asset_prefix}/*/:script.js" do |path, script|
14
+ get "/#{settings.asset_prefix}/*.js" do |script|
15
15
  content_type("application/javascript")
16
- settings.sprockets["#{path}/#{script}.js"]
16
+ @sprockets["#{script}.js"] || halt(404)
17
17
  end
18
18
 
19
- get "/#{settings.asset_prefix}/*/:stylesheet.css" do |path, stylesheet|
19
+ get "/#{settings.asset_prefix}/*.css" do |stylesheet|
20
20
  content_type("text/css")
21
- settings.sprockets["#{stylesheet}.css"]
21
+ @sprockets["#{stylesheet}.css"] || halt(404)
22
22
  end
23
23
 
24
24
  %w(jpeg jpg png gif webp).each do |format|
25
- get "/#{settings.asset_prefix}/*/:image.#{format}" do |path, image|
25
+ get "/#{settings.asset_prefix}/*.#{format}" do |image|
26
26
  content_type("image/#{(format == 'jpg') ? 'jpeg' : format}")
27
- settings.sprockets["#{image}.#{format}"]
27
+ @sprockets["#{image}.#{format}"] || halt(404)
28
28
  end
29
29
  end
30
30
 
31
- get "/#{settings.asset_prefix}/*/:font.ttf" do |path, font|
31
+ get "/#{settings.asset_prefix}/*.ttf" do |font|
32
32
  content_type('application/x-font-truetype')
33
- settings.sprockets["#{font}.ttf"]
33
+ @sprockets["#{font}.ttf"] || halt(404)
34
34
  end
35
35
 
36
- get "/#{settings.asset_prefix}/*/:font.eot" do |path, font|
36
+ get "/#{settings.asset_prefix}/*.eot" do |font|
37
37
  content_type('application/vnd.ms-fontobject')
38
- settings.sprockets["#{font}.eot"]
38
+ @sprockets["#{font}.eot"] || halt(404)
39
39
  end
40
40
 
41
- get "/#{settings.asset_prefix}/*/:font.svg" do |path, font|
41
+ get "/#{settings.asset_prefix}/*.svg" do |font|
42
42
  content_type('image/svg+xml')
43
- settings.sprockets["#{font}.svg"]
43
+ @sprockets["#{font}.svg"] || halt(404)
44
44
  end
45
45
 
46
- get "/#{settings.asset_prefix}/*/:font.woff" do |path, font|
46
+ get "/#{settings.asset_prefix}/*.woff" do |font|
47
47
  content_type('application/x-font-woff')
48
- settings.sprockets["#{font}.woff"]
48
+ @sprockets["#{font}.woff"] || halt(404)
49
49
  end
50
50
 
51
- get "/#{settings.asset_prefix}/*/:font.otf" do |path, font|
51
+ get "/#{settings.asset_prefix}/*.otf" do |font|
52
52
  content_type('application/x-font-opentype')
53
- settings.sprockets["#{font}.otf"]
53
+ @sprockets["#{font}.otf"] || halt(404)
54
54
  end
55
55
  end
56
56
  end
@@ -6,6 +6,8 @@ require 'classy_assets'
6
6
  describe ClassyAssets::Configuration do
7
7
  subject { ClassyAssets::Configuration }
8
8
  after do
9
+ ClassyAssets::Configuration.root_path = nil
10
+ ClassyAssets::Configuration.public_path = nil
9
11
  ClassyAssets::Configuration.sprockets.clear_paths
10
12
  end
11
13
 
@@ -40,11 +42,11 @@ describe ClassyAssets::Configuration do
40
42
  end
41
43
 
42
44
  it "returns the path to the public folder" do
43
- subject.public_path.must_equal File.expand_path('../support/public', __FILE__)
45
+ subject.public_path.must_equal './public'
44
46
  end
45
47
 
46
48
  it "returns the path to the root folder" do
47
- subject.root_path.must_equal File.expand_path('../support', __FILE__)
49
+ subject.root_path.must_equal '.'
48
50
  end
49
51
 
50
52
  it "returns the sprockets environment" do
@@ -52,7 +54,7 @@ describe ClassyAssets::Configuration do
52
54
  end
53
55
 
54
56
  it "returns the correct asset paths" do
55
- subject.sprockets.paths.must_equal subject.asset_paths
57
+ subject.sprockets.paths.must_equal subject.asset_paths.map {|p| File.expand_path(p) }
56
58
  end
57
59
 
58
60
  describe "configure" do
@@ -7,27 +7,26 @@ class MiddlewareApp < Sinatra::Base
7
7
  use Rack::ClassyAssets
8
8
  end
9
9
 
10
- describe Rack::ClassyAssets do
11
- include Rack::Test::Methods
12
- def app
13
- MiddlewareApp.new
14
- end
10
+ def app
11
+ MiddlewareApp.new
12
+ end
15
13
 
14
+ describe Rack::ClassyAssets do
16
15
  after do
17
16
  ClassyAssets::Configuration.sprockets.clear_paths
18
17
  end
19
18
 
20
19
  describe "stylesheets" do
21
20
  describe "css" do
22
- it "will respond sucessfully" do
23
- get '/assets/spec/support/stylesheet.css'
21
+ it "will respond sucessfully" do
22
+ get '/assets/stylesheet.css'
24
23
  last_response.status.must_equal 200
25
24
  end
26
25
  end
27
26
 
28
27
  describe "sass" do
29
28
  it "will respond sucessfully" do
30
- get '/assets/spec/support/application.css'
29
+ get '/assets/application.css'
31
30
  last_response.status.must_equal 200
32
31
  end
33
32
  end
@@ -36,14 +35,14 @@ describe Rack::ClassyAssets do
36
35
  describe "javascripts" do
37
36
  describe "js" do
38
37
  it "will respond sucessfully" do
39
- get '/assets/spec/support/javascript.js'
38
+ get '/assets/javascript.js'
40
39
  last_response.status.must_equal 200
41
40
  end
42
41
  end
43
42
 
44
43
  describe "coffeescript" do
45
44
  it "will respond sucessfully" do
46
- get '/assets/spec/support/application.js'
45
+ get '/assets/application.js'
47
46
  last_response.status.must_equal 200
48
47
  end
49
48
  end
@@ -52,21 +51,21 @@ describe Rack::ClassyAssets do
52
51
  describe "images" do
53
52
  describe "gif" do
54
53
  it "will respond sucessfully" do
55
- get '/assets/spec/support/image.gif'
54
+ get '/assets/image.gif'
56
55
  last_response.status.must_equal 200
57
56
  end
58
57
  end
59
58
 
60
59
  describe "jpg" do
61
60
  it "will respond sucessfully" do
62
- get '/assets/spec/support/image.jpg'
61
+ get '/assets/image.jpg'
63
62
  last_response.status.must_equal 200
64
63
  end
65
64
  end
66
65
 
67
66
  describe "png" do
68
67
  it "will respond sucessfully" do
69
- get '/assets/spec/support/image.png'
68
+ get '/assets/image.png'
70
69
  last_response.status.must_equal 200
71
70
  end
72
71
  end
@@ -75,35 +74,35 @@ describe Rack::ClassyAssets do
75
74
  describe "fonts" do
76
75
  describe "eot" do
77
76
  it "will respond sucessfully" do
78
- get '/assets/spec/support/font.eot'
77
+ get '/assets/font.eot'
79
78
  last_response.status.must_equal 200
80
79
  end
81
80
  end
82
81
 
83
82
  describe "otf" do
84
83
  it "will respond sucessfully" do
85
- get '/assets/spec/support/font.otf'
84
+ get '/assets/font.otf'
86
85
  last_response.status.must_equal 200
87
86
  end
88
87
  end
89
88
 
90
89
  describe "svg" do
91
90
  it "will respond sucessfully" do
92
- get '/assets/spec/support/font.svg'
91
+ get '/assets/font.svg'
93
92
  last_response.status.must_equal 200
94
93
  end
95
94
  end
96
95
 
97
96
  describe "ttf" do
98
97
  it "will respond sucessfully" do
99
- get '/assets/spec/support/font.ttf'
98
+ get '/assets/font.ttf'
100
99
  last_response.status.must_equal 200
101
100
  end
102
101
  end
103
102
 
104
103
  describe "woff" do
105
104
  it "will respond sucessfully" do
106
- get '/assets/spec/support/font.woff'
105
+ get '/assets/font.woff'
107
106
  last_response.status.must_equal 200
108
107
  end
109
108
  end
@@ -4,7 +4,6 @@ require 'spec_helper'
4
4
  require 'sinatra/classy_assets'
5
5
 
6
6
  class ExtensionApp < Sinatra::Base
7
- set :root, File.expand_path('../../support', __FILE__)
8
7
  register Sinatra::ClassyAssets
9
8
  end
10
9
 
@@ -20,14 +19,14 @@ describe Rack::ClassyAssets do
20
19
  describe "stylesheets" do
21
20
  describe "css" do
22
21
  it "will respond sucessfully" do
23
- get '/assets/spec/support/stylesheet.css'
22
+ get '/assets/stylesheet.css'
24
23
  last_response.status.must_equal 200
25
24
  end
26
25
  end
27
26
 
28
27
  describe "sass" do
29
28
  it "will respond sucessfully" do
30
- get '/assets/spec/support/application.css'
29
+ get '/assets/application.css'
31
30
  last_response.status.must_equal 200
32
31
  end
33
32
  end
@@ -36,14 +35,14 @@ describe Rack::ClassyAssets do
36
35
  describe "javascripts" do
37
36
  describe "js" do
38
37
  it "will respond sucessfully" do
39
- get '/assets/spec/support/javascript.js'
38
+ get '/assets/javascript.js'
40
39
  last_response.status.must_equal 200
41
40
  end
42
41
  end
43
42
 
44
43
  describe "coffeescript" do
45
44
  it "will respond sucessfully" do
46
- get '/assets/spec/support/application.js'
45
+ get '/assets/application.js'
47
46
  last_response.status.must_equal 200
48
47
  end
49
48
  end
@@ -52,21 +51,21 @@ describe Rack::ClassyAssets do
52
51
  describe "images" do
53
52
  describe "gif" do
54
53
  it "will respond sucessfully" do
55
- get '/assets/spec/support/image.gif'
54
+ get '/assets/image.gif'
56
55
  last_response.status.must_equal 200
57
56
  end
58
57
  end
59
58
 
60
59
  describe "jpg" do
61
60
  it "will respond sucessfully" do
62
- get '/assets/spec/support/image.jpg'
61
+ get '/assets/image.jpg'
63
62
  last_response.status.must_equal 200
64
63
  end
65
64
  end
66
65
 
67
66
  describe "png" do
68
67
  it "will respond sucessfully" do
69
- get '/assets/spec/support/image.png'
68
+ get '/assets/image.png'
70
69
  last_response.status.must_equal 200
71
70
  end
72
71
  end
@@ -75,35 +74,35 @@ describe Rack::ClassyAssets do
75
74
  describe "fonts" do
76
75
  describe "eot" do
77
76
  it "will respond sucessfully" do
78
- get '/assets/spec/support/font.eot'
77
+ get '/assets/font.eot'
79
78
  last_response.status.must_equal 200
80
79
  end
81
80
  end
82
81
 
83
82
  describe "otf" do
84
83
  it "will respond sucessfully" do
85
- get '/assets/spec/support/font.otf'
84
+ get '/assets/font.otf'
86
85
  last_response.status.must_equal 200
87
86
  end
88
87
  end
89
88
 
90
89
  describe "svg" do
91
90
  it "will respond sucessfully" do
92
- get '/assets/spec/support/font.svg'
91
+ get '/assets/font.svg'
93
92
  last_response.status.must_equal 200
94
93
  end
95
94
  end
96
95
 
97
96
  describe "ttf" do
98
97
  it "will respond sucessfully" do
99
- get '/assets/spec/support/font.ttf'
98
+ get '/assets/font.ttf'
100
99
  last_response.status.must_equal 200
101
100
  end
102
101
  end
103
102
 
104
103
  describe "woff" do
105
104
  it "will respond sucessfully" do
106
- get '/assets/spec/support/font.woff'
105
+ get '/assets/font.woff'
107
106
  last_response.status.must_equal 200
108
107
  end
109
108
  end
data/spec/spec_helper.rb CHANGED
@@ -11,9 +11,3 @@ require 'minitest/reporters'
11
11
  MiniTest::Reporters.use! MiniTest::Reporters::SpecReporter.new
12
12
 
13
13
  include Rack::Test::Methods
14
-
15
- ClassyAssets::Configuration.configure do |config|
16
- config.root_path = File.expand_path('../support', __FILE__)
17
- config.public_path = File.expand_path('../support/public', __FILE__)
18
- end
19
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: classy_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - StyleSeek Engineering
@@ -234,6 +234,18 @@ files:
234
234
  - LICENSE.txt
235
235
  - README.md
236
236
  - Rakefile
237
+ - assets/fonts/font.eot
238
+ - assets/fonts/font.otf
239
+ - assets/fonts/font.svg
240
+ - assets/fonts/font.ttf
241
+ - assets/fonts/font.woff
242
+ - assets/images/image.gif
243
+ - assets/images/image.jpg
244
+ - assets/images/image.png
245
+ - assets/javascripts/application.coffee
246
+ - assets/javascripts/javascript.js
247
+ - assets/stylesheets/application.scss
248
+ - assets/stylesheets/stylesheet.css
237
249
  - bin/.files/pre-commit.hook
238
250
  - bin/classy_assets
239
251
  - classy_assets.gemspec
@@ -248,18 +260,6 @@ files:
248
260
  - spec/rack/classy_assets_spec.rb
249
261
  - spec/sinatra/classy_assets_spec.rb
250
262
  - spec/spec_helper.rb
251
- - spec/support/assets/fonts/font.eot
252
- - spec/support/assets/fonts/font.otf
253
- - spec/support/assets/fonts/font.svg
254
- - spec/support/assets/fonts/font.ttf
255
- - spec/support/assets/fonts/font.woff
256
- - spec/support/assets/images/image.gif
257
- - spec/support/assets/images/image.jpg
258
- - spec/support/assets/images/image.png
259
- - spec/support/assets/javascripts/application.coffee
260
- - spec/support/assets/javascripts/javascript.js
261
- - spec/support/assets/stylesheets/application.scss
262
- - spec/support/assets/stylesheets/stylesheet.css
263
263
  homepage: https://github.com/styleseek/classy_assets
264
264
  licenses:
265
265
  - MIT
@@ -289,15 +289,3 @@ test_files:
289
289
  - spec/rack/classy_assets_spec.rb
290
290
  - spec/sinatra/classy_assets_spec.rb
291
291
  - spec/spec_helper.rb
292
- - spec/support/assets/fonts/font.eot
293
- - spec/support/assets/fonts/font.otf
294
- - spec/support/assets/fonts/font.svg
295
- - spec/support/assets/fonts/font.ttf
296
- - spec/support/assets/fonts/font.woff
297
- - spec/support/assets/images/image.gif
298
- - spec/support/assets/images/image.jpg
299
- - spec/support/assets/images/image.png
300
- - spec/support/assets/javascripts/application.coffee
301
- - spec/support/assets/javascripts/javascript.js
302
- - spec/support/assets/stylesheets/application.scss
303
- - spec/support/assets/stylesheets/stylesheet.css