classy_assets 0.1.4 → 0.2.0
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.
- checksums.yaml +4 -4
- data/lib/classy_assets.rb +10 -10
- data/lib/classy_assets/version.rb +1 -1
- data/lib/rack/classy_assets.rb +22 -20
- data/lib/sinatra/classy_assets.rb +19 -11
- data/spec/classy_assets_spec.rb +4 -6
- data/spec/rack/classy_assets_spec.rb +17 -18
- data/spec/sinatra/classy_assets_spec.rb +19 -20
- data/spec/spec_helper.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bb5c045b40c7a18eedbfa6a32e7a9a71c8ae9ed
|
4
|
+
data.tar.gz: 4b20a1d196309da05e7edae4cdef3761c00dc3ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69ab2b9dd844a9ab983e60511ab054659c8200eacba3ce408a02006da957e5b100c82052ed6f3074f12cfa33e3fff24c191136f328bc92c61b686f5dcf3dbc56
|
7
|
+
data.tar.gz: 63f2076784e5705129de6061bc7477944b2f6bdd9846fe1270364bc4931244c6d4ef0dd0e41a55bc5c6dd1bc972694c0169e10d0e917f81d8a2059345cd57624
|
data/lib/classy_assets.rb
CHANGED
@@ -15,7 +15,7 @@ module ClassyAssets
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.asset_digest
|
18
|
-
@asset_digest
|
18
|
+
@asset_digest.nil? ? false : @asset_digest
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.asset_digest=(digest)
|
@@ -23,7 +23,7 @@ module ClassyAssets
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.asset_paths
|
26
|
-
@asset_paths
|
26
|
+
@asset_paths || build_asset_path(%w(fonts images javascripts stylesheets))
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.asset_paths=(paths)
|
@@ -31,7 +31,7 @@ module ClassyAssets
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def self.asset_host
|
34
|
-
@asset_host
|
34
|
+
@asset_host
|
35
35
|
end
|
36
36
|
|
37
37
|
def self.asset_host=(host)
|
@@ -39,7 +39,7 @@ module ClassyAssets
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def self.asset_prefix
|
42
|
-
@asset_prefix
|
42
|
+
@asset_prefix || 'assets'
|
43
43
|
end
|
44
44
|
|
45
45
|
def self.asset_prefix=(prefix)
|
@@ -47,7 +47,7 @@ module ClassyAssets
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def self.css_compressor
|
50
|
-
@css_compressor
|
50
|
+
@css_compressor || :yui
|
51
51
|
end
|
52
52
|
|
53
53
|
def self.css_compressor=(compressor)
|
@@ -55,7 +55,7 @@ module ClassyAssets
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def self.debug_mode
|
58
|
-
@debug_mode
|
58
|
+
@debug_mode.nil? ? (ENV['RACK_ENV'] == 'development') : @debug_mode
|
59
59
|
end
|
60
60
|
|
61
61
|
def self.debug_mode=(debug)
|
@@ -63,7 +63,7 @@ module ClassyAssets
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def self.js_compressor
|
66
|
-
@js_compressor
|
66
|
+
@js_compressor || :uglifier
|
67
67
|
end
|
68
68
|
|
69
69
|
def self.js_compressor=(compressor)
|
@@ -71,7 +71,7 @@ module ClassyAssets
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def self.public_path
|
74
|
-
@public_path
|
74
|
+
@public_path || File.join(root_path, 'public')
|
75
75
|
end
|
76
76
|
|
77
77
|
def self.public_path=(path)
|
@@ -79,7 +79,7 @@ module ClassyAssets
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def self.root_path
|
82
|
-
@root_path
|
82
|
+
@root_path || '.'
|
83
83
|
end
|
84
84
|
|
85
85
|
def self.root_path=(path)
|
@@ -96,7 +96,7 @@ module ClassyAssets
|
|
96
96
|
def self.sprockets
|
97
97
|
@sprockets ||= ::Sprockets::Environment.new(root_path)
|
98
98
|
asset_paths.each do |asset_path|
|
99
|
-
@sprockets.append_path asset_path unless @sprockets.paths.include?
|
99
|
+
@sprockets.append_path asset_path unless @sprockets.paths.include?(asset_path)
|
100
100
|
end
|
101
101
|
@sprockets
|
102
102
|
end
|
data/lib/rack/classy_assets.rb
CHANGED
@@ -5,50 +5,52 @@ require 'classy_assets'
|
|
5
5
|
module Rack
|
6
6
|
class ClassyAssets < Sinatra::Base
|
7
7
|
def initialize(app)
|
8
|
-
super(app)
|
9
|
-
@sprockets = ::ClassyAssets::Configuration.sprockets
|
8
|
+
super(app)
|
10
9
|
end
|
10
|
+
|
11
|
+
set :sprockets, ::ClassyAssets::Configuration.sprockets
|
12
|
+
set :asset_prefix, ::ClassyAssets::Configuration.asset_prefix
|
11
13
|
|
12
|
-
get "/#{
|
14
|
+
get "/#{settings.asset_prefix}/*/:script.js" do |path, script|
|
13
15
|
content_type("application/javascript")
|
14
|
-
|
16
|
+
settings.sprockets["#{path}/#{script}.js"]
|
15
17
|
end
|
16
18
|
|
17
|
-
get "/#{
|
19
|
+
get "/#{settings.asset_prefix}/*/:stylesheet.css" do |path, stylesheet|
|
18
20
|
content_type("text/css")
|
19
|
-
|
21
|
+
settings.sprockets["#{stylesheet}.css"]
|
20
22
|
end
|
21
23
|
|
22
|
-
%w
|
23
|
-
get "/#{
|
24
|
-
content_type("image/#{format}")
|
25
|
-
|
24
|
+
%w(jpeg jpg png gif webp).each do |format|
|
25
|
+
get "/#{settings.asset_prefix}/*/:image.#{format}" do |path, image|
|
26
|
+
content_type("image/#{(format == 'jpg') ? 'jpeg' : format}")
|
27
|
+
settings.sprockets["#{image}.#{format}"]
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
|
-
get "/#{
|
31
|
+
get "/#{settings.asset_prefix}/*/:font.ttf" do |path, font|
|
30
32
|
content_type('application/x-font-truetype')
|
31
|
-
|
33
|
+
settings.sprockets["#{font}.ttf"]
|
32
34
|
end
|
33
35
|
|
34
|
-
get "/#{
|
36
|
+
get "/#{settings.asset_prefix}/*/:font.eot" do |path, font|
|
35
37
|
content_type('application/vnd.ms-fontobject')
|
36
|
-
|
38
|
+
settings.sprockets["#{font}.eot"]
|
37
39
|
end
|
38
40
|
|
39
|
-
get "/#{
|
41
|
+
get "/#{settings.asset_prefix}/*/:font.svg" do |path, font|
|
40
42
|
content_type('image/svg+xml')
|
41
|
-
|
43
|
+
settings.sprockets["#{font}.svg"]
|
42
44
|
end
|
43
45
|
|
44
|
-
get "/#{
|
46
|
+
get "/#{settings.asset_prefix}/*/:font.woff" do |path, font|
|
45
47
|
content_type('application/x-font-woff')
|
46
|
-
|
48
|
+
settings.sprockets["#{font}.woff"]
|
47
49
|
end
|
48
50
|
|
49
|
-
get "/#{
|
51
|
+
get "/#{settings.asset_prefix}/*/:font.otf" do |path, font|
|
50
52
|
content_type('application/x-font-opentype')
|
51
|
-
|
53
|
+
settings.sprockets["#{font}.otf"]
|
52
54
|
end
|
53
55
|
end
|
54
56
|
end
|
@@ -7,18 +7,26 @@ module Sinatra
|
|
7
7
|
module ClassyAssets
|
8
8
|
def self.registered(app)
|
9
9
|
app.use Rack::ClassyAssets
|
10
|
-
app.register
|
11
|
-
app.
|
12
|
-
|
10
|
+
app.register Sprockets::Helpers
|
11
|
+
app.configure do
|
12
|
+
::Sprockets::Helpers.configure do |config|
|
13
|
+
classy_config = ::ClassyAssets::Configuration
|
14
|
+
manifest_file = ::File.join(config.public_path,
|
15
|
+
classy_config.asset_prefix,
|
16
|
+
'manifset.json')
|
17
|
+
|
18
|
+
config.asset_host = classy_config.asset_host
|
19
|
+
config.debug = classy_config.debug_mode
|
20
|
+
config.digest = classy_config.asset_digest
|
21
|
+
config.environment = classy_config.sprockets
|
22
|
+
config.public_path = classy_config.public_path
|
23
|
+
config.prefix = "/#{classy_config.asset_prefix}"
|
13
24
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
config.prefix = ::ClassyAssets::Configuration.asset_prefix
|
20
|
-
config.public_path = ::ClassyAssets::Configuration.public_path
|
21
|
-
end
|
25
|
+
if ::File.exists? manifest_file
|
26
|
+
config.manifest = ::Sprockets::Manifest.new(config.environment, manifest_file)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
22
30
|
end
|
23
31
|
end
|
24
32
|
register ClassyAssets
|
data/spec/classy_assets_spec.rb
CHANGED
@@ -5,7 +5,10 @@ require 'classy_assets'
|
|
5
5
|
|
6
6
|
describe ClassyAssets::Configuration do
|
7
7
|
subject { ClassyAssets::Configuration }
|
8
|
-
|
8
|
+
after do
|
9
|
+
ClassyAssets::Configuration.sprockets.clear_paths
|
10
|
+
end
|
11
|
+
|
9
12
|
it "returns an array of asset directories" do
|
10
13
|
paths = %w(fonts images javascripts stylesheets)
|
11
14
|
paths.map! { |dir_name| File.join(ClassyAssets::Configuration.root_path, ClassyAssets::Configuration.asset_prefix, dir_name) }
|
@@ -71,9 +74,4 @@ describe ClassyAssets::Configuration do
|
|
71
74
|
ClassyAssets::Configuration.public_path.must_equal @public_path
|
72
75
|
end
|
73
76
|
end
|
74
|
-
|
75
|
-
#after do
|
76
|
-
#ClassyAssets::Configuration.root_path = nil
|
77
|
-
#ClassyAssets::Configuration.public_path = nil
|
78
|
-
#end
|
79
77
|
end
|
@@ -3,13 +3,8 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
require 'rack/classy_assets'
|
5
5
|
|
6
|
-
ClassyAssets::Configuration.configure do |config|
|
7
|
-
config.root_path = File.expand_path('../../support', __FILE__)
|
8
|
-
config.public_path = File.expand_path('../../support/public', __FILE__)
|
9
|
-
end
|
10
|
-
|
11
6
|
class MiddlewareApp < Sinatra::Base
|
12
|
-
use Rack::ClassyAssets
|
7
|
+
use Rack::ClassyAssets
|
13
8
|
end
|
14
9
|
|
15
10
|
describe Rack::ClassyAssets do
|
@@ -18,17 +13,21 @@ describe Rack::ClassyAssets do
|
|
18
13
|
MiddlewareApp.new
|
19
14
|
end
|
20
15
|
|
16
|
+
after do
|
17
|
+
ClassyAssets::Configuration.sprockets.clear_paths
|
18
|
+
end
|
19
|
+
|
21
20
|
describe "stylesheets" do
|
22
21
|
describe "css" do
|
23
22
|
it "will respond sucessfully" do
|
24
|
-
get '/assets/stylesheet.css'
|
23
|
+
get '/assets/spec/support/stylesheet.css'
|
25
24
|
last_response.status.must_equal 200
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
29
28
|
describe "sass" do
|
30
29
|
it "will respond sucessfully" do
|
31
|
-
get '/assets/application.css'
|
30
|
+
get '/assets/spec/support/application.css'
|
32
31
|
last_response.status.must_equal 200
|
33
32
|
end
|
34
33
|
end
|
@@ -37,14 +36,14 @@ describe Rack::ClassyAssets do
|
|
37
36
|
describe "javascripts" do
|
38
37
|
describe "js" do
|
39
38
|
it "will respond sucessfully" do
|
40
|
-
get '/assets/javascript.js'
|
39
|
+
get '/assets/spec/support/javascript.js'
|
41
40
|
last_response.status.must_equal 200
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
44
|
describe "coffeescript" do
|
46
45
|
it "will respond sucessfully" do
|
47
|
-
get '/assets/application.js'
|
46
|
+
get '/assets/spec/support/application.js'
|
48
47
|
last_response.status.must_equal 200
|
49
48
|
end
|
50
49
|
end
|
@@ -53,21 +52,21 @@ describe Rack::ClassyAssets do
|
|
53
52
|
describe "images" do
|
54
53
|
describe "gif" do
|
55
54
|
it "will respond sucessfully" do
|
56
|
-
get '/assets/image.gif'
|
55
|
+
get '/assets/spec/support/image.gif'
|
57
56
|
last_response.status.must_equal 200
|
58
57
|
end
|
59
58
|
end
|
60
59
|
|
61
60
|
describe "jpg" do
|
62
61
|
it "will respond sucessfully" do
|
63
|
-
get '/assets/image.jpg'
|
62
|
+
get '/assets/spec/support/image.jpg'
|
64
63
|
last_response.status.must_equal 200
|
65
64
|
end
|
66
65
|
end
|
67
66
|
|
68
67
|
describe "png" do
|
69
68
|
it "will respond sucessfully" do
|
70
|
-
get '/assets/image.png'
|
69
|
+
get '/assets/spec/support/image.png'
|
71
70
|
last_response.status.must_equal 200
|
72
71
|
end
|
73
72
|
end
|
@@ -76,35 +75,35 @@ describe Rack::ClassyAssets do
|
|
76
75
|
describe "fonts" do
|
77
76
|
describe "eot" do
|
78
77
|
it "will respond sucessfully" do
|
79
|
-
get '/assets/font.eot'
|
78
|
+
get '/assets/spec/support/font.eot'
|
80
79
|
last_response.status.must_equal 200
|
81
80
|
end
|
82
81
|
end
|
83
82
|
|
84
83
|
describe "otf" do
|
85
84
|
it "will respond sucessfully" do
|
86
|
-
get '/assets/font.otf'
|
85
|
+
get '/assets/spec/support/font.otf'
|
87
86
|
last_response.status.must_equal 200
|
88
87
|
end
|
89
88
|
end
|
90
89
|
|
91
90
|
describe "svg" do
|
92
91
|
it "will respond sucessfully" do
|
93
|
-
get '/assets/font.svg'
|
92
|
+
get '/assets/spec/support/font.svg'
|
94
93
|
last_response.status.must_equal 200
|
95
94
|
end
|
96
95
|
end
|
97
96
|
|
98
97
|
describe "ttf" do
|
99
98
|
it "will respond sucessfully" do
|
100
|
-
get '/assets/font.ttf'
|
99
|
+
get '/assets/spec/support/font.ttf'
|
101
100
|
last_response.status.must_equal 200
|
102
101
|
end
|
103
102
|
end
|
104
103
|
|
105
104
|
describe "woff" do
|
106
105
|
it "will respond sucessfully" do
|
107
|
-
get '/assets/font.woff'
|
106
|
+
get '/assets/spec/support/font.woff'
|
108
107
|
last_response.status.must_equal 200
|
109
108
|
end
|
110
109
|
end
|
@@ -3,32 +3,31 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
require 'sinatra/classy_assets'
|
5
5
|
|
6
|
-
ClassyAssets::Configuration.configure do |config|
|
7
|
-
config.root_path = File.expand_path('../../support', __FILE__)
|
8
|
-
config.public_path = File.expand_path('../../support/public', __FILE__)
|
9
|
-
end
|
10
|
-
|
11
6
|
class ExtensionApp < Sinatra::Base
|
7
|
+
set :root, File.expand_path('../../support', __FILE__)
|
12
8
|
register Sinatra::ClassyAssets
|
13
9
|
end
|
14
10
|
|
11
|
+
def app
|
12
|
+
ExtensionApp.new
|
13
|
+
end
|
14
|
+
|
15
15
|
describe Rack::ClassyAssets do
|
16
|
-
|
17
|
-
|
18
|
-
ExtensionApp.new
|
16
|
+
after do
|
17
|
+
ClassyAssets::Configuration.sprockets.clear_paths
|
19
18
|
end
|
20
19
|
|
21
20
|
describe "stylesheets" do
|
22
21
|
describe "css" do
|
23
22
|
it "will respond sucessfully" do
|
24
|
-
get '/assets/stylesheet.css'
|
23
|
+
get '/assets/spec/support/stylesheet.css'
|
25
24
|
last_response.status.must_equal 200
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
29
28
|
describe "sass" do
|
30
29
|
it "will respond sucessfully" do
|
31
|
-
get '/assets/application.css'
|
30
|
+
get '/assets/spec/support/application.css'
|
32
31
|
last_response.status.must_equal 200
|
33
32
|
end
|
34
33
|
end
|
@@ -37,14 +36,14 @@ describe Rack::ClassyAssets do
|
|
37
36
|
describe "javascripts" do
|
38
37
|
describe "js" do
|
39
38
|
it "will respond sucessfully" do
|
40
|
-
get '/assets/javascript.js'
|
39
|
+
get '/assets/spec/support/javascript.js'
|
41
40
|
last_response.status.must_equal 200
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
44
|
describe "coffeescript" do
|
46
45
|
it "will respond sucessfully" do
|
47
|
-
get '/assets/application.js'
|
46
|
+
get '/assets/spec/support/application.js'
|
48
47
|
last_response.status.must_equal 200
|
49
48
|
end
|
50
49
|
end
|
@@ -53,21 +52,21 @@ describe Rack::ClassyAssets do
|
|
53
52
|
describe "images" do
|
54
53
|
describe "gif" do
|
55
54
|
it "will respond sucessfully" do
|
56
|
-
get '/assets/image.gif'
|
55
|
+
get '/assets/spec/support/image.gif'
|
57
56
|
last_response.status.must_equal 200
|
58
57
|
end
|
59
58
|
end
|
60
59
|
|
61
60
|
describe "jpg" do
|
62
61
|
it "will respond sucessfully" do
|
63
|
-
get '/assets/image.jpg'
|
62
|
+
get '/assets/spec/support/image.jpg'
|
64
63
|
last_response.status.must_equal 200
|
65
64
|
end
|
66
65
|
end
|
67
66
|
|
68
67
|
describe "png" do
|
69
68
|
it "will respond sucessfully" do
|
70
|
-
get '/assets/image.png'
|
69
|
+
get '/assets/spec/support/image.png'
|
71
70
|
last_response.status.must_equal 200
|
72
71
|
end
|
73
72
|
end
|
@@ -76,35 +75,35 @@ describe Rack::ClassyAssets do
|
|
76
75
|
describe "fonts" do
|
77
76
|
describe "eot" do
|
78
77
|
it "will respond sucessfully" do
|
79
|
-
get '/assets/font.eot'
|
78
|
+
get '/assets/spec/support/font.eot'
|
80
79
|
last_response.status.must_equal 200
|
81
80
|
end
|
82
81
|
end
|
83
82
|
|
84
83
|
describe "otf" do
|
85
84
|
it "will respond sucessfully" do
|
86
|
-
get '/assets/font.otf'
|
85
|
+
get '/assets/spec/support/font.otf'
|
87
86
|
last_response.status.must_equal 200
|
88
87
|
end
|
89
88
|
end
|
90
89
|
|
91
90
|
describe "svg" do
|
92
91
|
it "will respond sucessfully" do
|
93
|
-
get '/assets/font.svg'
|
92
|
+
get '/assets/spec/support/font.svg'
|
94
93
|
last_response.status.must_equal 200
|
95
94
|
end
|
96
95
|
end
|
97
96
|
|
98
97
|
describe "ttf" do
|
99
98
|
it "will respond sucessfully" do
|
100
|
-
get '/assets/font.ttf'
|
99
|
+
get '/assets/spec/support/font.ttf'
|
101
100
|
last_response.status.must_equal 200
|
102
101
|
end
|
103
102
|
end
|
104
103
|
|
105
104
|
describe "woff" do
|
106
105
|
it "will respond sucessfully" do
|
107
|
-
get '/assets/font.woff'
|
106
|
+
get '/assets/spec/support/font.woff'
|
108
107
|
last_response.status.must_equal 200
|
109
108
|
end
|
110
109
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -9,3 +9,11 @@ require 'classy_assets'
|
|
9
9
|
require 'minitest/autorun'
|
10
10
|
require 'minitest/reporters'
|
11
11
|
MiniTest::Reporters.use! MiniTest::Reporters::SpecReporter.new
|
12
|
+
|
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,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: classy_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- StyleSeek Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coffee-script
|