sass-rails 3.1.2 → 3.1.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/CHANGELOG.md +14 -0
- data/lib/sass/rails/helpers.rb +23 -10
- data/lib/sass/rails/railtie.rb +14 -14
- data/lib/sass/rails/template_handlers.rb +21 -1
- data/lib/sass/rails/version.rb +1 -1
- data/test/fixtures/scss_project/app/assets/stylesheets/application.css.scss +11 -0
- data/test/sass_rails_test.rb +11 -0
- metadata +41 -4
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
CHANGELOG
|
2
|
+
=========
|
3
|
+
|
4
|
+
3.1.2 (Sept 15, 2011)
|
5
|
+
---------------------
|
6
|
+
|
7
|
+
* Add asset-data-url helper for base-64 encoding of assets within stylesheets.
|
8
|
+
* Add explicit dependency on sprockets.
|
9
|
+
|
10
|
+
3.1.1 (Sept 13, 2011)
|
11
|
+
---------------------
|
12
|
+
|
13
|
+
* Add explicit version dependency on tilt.
|
14
|
+
* Add MIT License.
|
data/lib/sass/rails/helpers.rb
CHANGED
@@ -15,25 +15,38 @@ module Sass
|
|
15
15
|
Sass::Script::String.new(%Q{url(#{public_path(asset.value, kind.value)})})
|
16
16
|
end
|
17
17
|
|
18
|
-
[:image, :
|
18
|
+
[:image, :video, :audio, :javascript, :stylesheet].each do |asset_class|
|
19
19
|
class_eval %Q{
|
20
20
|
def #{asset_class}_path(asset)
|
21
|
-
|
21
|
+
Sass::Script::String.new(resolver.#{asset_class}_path(asset.value), true)
|
22
22
|
end
|
23
23
|
def #{asset_class}_url(asset)
|
24
|
-
|
24
|
+
Sass::Script::String.new("url(" + resolver.#{asset_class}_path(asset.value) + ")")
|
25
25
|
end
|
26
26
|
}, __FILE__, __LINE__ - 6
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
options[:custom][:resolver].public_path(asset, kind.pluralize)
|
29
|
+
def font_path(asset)
|
30
|
+
asset_path(asset, Sass::Script::String.new("font"))
|
32
31
|
end
|
33
|
-
|
34
|
-
def
|
35
|
-
|
32
|
+
|
33
|
+
def font_url(asset)
|
34
|
+
asset_url(asset, Sass::Script::String.new("font"))
|
36
35
|
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
def resolver
|
40
|
+
options[:custom][:resolver]
|
41
|
+
end
|
42
|
+
|
43
|
+
def public_path(asset, kind)
|
44
|
+
resolver.public_path(asset, kind.pluralize)
|
45
|
+
end
|
46
|
+
|
47
|
+
def context_asset_data_uri(path)
|
48
|
+
resolver.context.asset_data_uri(path)
|
49
|
+
end
|
37
50
|
end
|
38
51
|
end
|
39
52
|
end
|
@@ -44,4 +57,4 @@ module Sass
|
|
44
57
|
include Sass::Rails::Helpers
|
45
58
|
end
|
46
59
|
end
|
47
|
-
end
|
60
|
+
end
|
data/lib/sass/rails/railtie.rb
CHANGED
@@ -5,7 +5,9 @@ module Sass::Rails
|
|
5
5
|
module SassContext
|
6
6
|
attr_accessor :sass_config
|
7
7
|
end
|
8
|
+
|
8
9
|
config.sass = ActiveSupport::OrderedOptions.new
|
10
|
+
|
9
11
|
# Establish static configuration defaults
|
10
12
|
# Emit scss files during stylesheet generation of scaffold
|
11
13
|
config.sass.preferred_syntax = :scss
|
@@ -28,18 +30,18 @@ module Sass::Rails
|
|
28
30
|
# to the rails generate command
|
29
31
|
config.app_generators.stylesheet_engine config.sass.preferred_syntax
|
30
32
|
|
31
|
-
config.before_initialize do
|
32
|
-
unless app.config.assets && app.config.assets.enabled
|
33
|
-
raise "The sass-rails plugin requires the asset pipeline to be enabled."
|
34
|
-
end
|
35
|
-
|
33
|
+
config.before_initialize do
|
36
34
|
require 'sass'
|
37
|
-
|
38
|
-
|
39
|
-
Sprockets
|
35
|
+
|
36
|
+
# Assume dependency on sprockets, not on app.config.assets enabled.
|
37
|
+
if defined?(Sprockets::Engines)
|
38
|
+
Sprockets::Engines #force autoloading
|
39
|
+
Sprockets.register_engine '.sass', Sass::Rails::SassTemplate
|
40
|
+
Sprockets.register_engine '.scss', Sass::Rails::ScssTemplate
|
41
|
+
end
|
40
42
|
end
|
41
43
|
|
42
|
-
initializer :setup_sass do |app|
|
44
|
+
initializer :setup_sass, :group => :assets do |app|
|
43
45
|
# Only emit one kind of syntax because though we have registered two kinds of generators
|
44
46
|
syntax = app.config.sass.preferred_syntax.to_sym
|
45
47
|
alt_syntax = syntax == :sass ? "scss" : "sass"
|
@@ -58,17 +60,15 @@ module Sass::Rails
|
|
58
60
|
end
|
59
61
|
app.assets.context_class.extend(SassContext)
|
60
62
|
app.assets.context_class.sass_config = app.config.sass
|
63
|
+
|
64
|
+
Sass.logger = app.config.sass.logger
|
61
65
|
end
|
62
66
|
|
63
|
-
initializer :setup_compression do |app|
|
67
|
+
initializer :setup_compression, :group => :assets do |app|
|
64
68
|
if app.config.assets.compress
|
65
69
|
# Use sass's css_compressor
|
66
70
|
app.config.assets.css_compressor = CssCompressor.new
|
67
71
|
end
|
68
72
|
end
|
69
|
-
|
70
|
-
config.after_initialize do |app|
|
71
|
-
Sass::logger = app.config.sass.logger
|
72
|
-
end
|
73
73
|
end
|
74
74
|
end
|
@@ -20,12 +20,32 @@ module Sass::Rails
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def public_path(path, scope)
|
23
|
-
context.asset_paths.compute_public_path(path,
|
23
|
+
context.asset_paths.compute_public_path(path, ::Rails.application.config.assets.prefix)
|
24
24
|
end
|
25
25
|
|
26
26
|
def process(path)
|
27
27
|
context.environment[path].to_s
|
28
28
|
end
|
29
|
+
|
30
|
+
def image_path(img)
|
31
|
+
context.image_path(img)
|
32
|
+
end
|
33
|
+
|
34
|
+
def video_path(video)
|
35
|
+
context.video_path(video)
|
36
|
+
end
|
37
|
+
|
38
|
+
def audio_path(audio)
|
39
|
+
context.audio_path(audio)
|
40
|
+
end
|
41
|
+
|
42
|
+
def javascript_path(javascript)
|
43
|
+
context.javascript_path(javascript)
|
44
|
+
end
|
45
|
+
|
46
|
+
def stylesheet_path(stylesheet)
|
47
|
+
context.stylesheet_path(stylesheet)
|
48
|
+
end
|
29
49
|
end
|
30
50
|
|
31
51
|
class SassTemplate < Tilt::SassTemplate
|
data/lib/sass/rails/version.rb
CHANGED
@@ -13,7 +13,18 @@
|
|
13
13
|
.rails {
|
14
14
|
asset-path: asset-path("rails.png", image);
|
15
15
|
asset-url: asset-url("rails.png", image);
|
16
|
+
image-path: image-path("rails.png");
|
16
17
|
image-url: image-url("rails.png");
|
18
|
+
video-path: video-path("rails.mp4");
|
19
|
+
video-url: video-url("rails.mp4");
|
20
|
+
audio-path: audio-path("rails.mp3");
|
21
|
+
audio-url: audio-url("rails.mp3");
|
22
|
+
font-path: font-path("rails.ttf");
|
23
|
+
font-url: font-url("rails.ttf");
|
24
|
+
javascript-path: javascript-path("rails.js");
|
25
|
+
javascript-url: javascript-url("rails.js");
|
26
|
+
stylesheet-path: stylesheet-path("rails.css");
|
27
|
+
stylesheet-url: stylesheet-url("rails.css");
|
17
28
|
asset-data-url: asset-data-url("1x1.png");
|
18
29
|
}
|
19
30
|
|
data/test/sass_rails_test.rb
CHANGED
@@ -76,7 +76,18 @@ class SassRailsTest < Sass::Rails::TestCase
|
|
76
76
|
css_output = sprockets_render("scss_project", "application.css.scss")
|
77
77
|
assert_match css_output, %r{asset-path:\s*"/assets/rails.png"}, 'asset-path:\s*"/assets/rails.png"'
|
78
78
|
assert_match css_output, %r{asset-url:\s*url\(/assets/rails.png\)}, 'asset-url:\s*url\(/assets/rails.png\)'
|
79
|
+
assert_match css_output, %r{image-path:\s*"/assets/rails.png"}, 'image-path:\s*"/assets/rails.png"'
|
79
80
|
assert_match css_output, %r{image-url:\s*url\(/assets/rails.png\)}, 'image-url:\s*url\(/assets/rails.png\)'
|
81
|
+
assert_match css_output, %r{video-path:\s*"/videos/rails.mp4"}, 'video-path:\s*"/videos/rails.mp4"'
|
82
|
+
assert_match css_output, %r{video-url:\s*url\(/videos/rails.mp4\)}, 'video-url:\s*url\(/videos/rails.mp4\)'
|
83
|
+
assert_match css_output, %r{audio-path:\s*"/audios/rails.mp3"}, 'audio-path:\s*"/audios/rails.mp3"'
|
84
|
+
assert_match css_output, %r{audio-url:\s*url\(/audios/rails.mp3\)}, 'audio-url:\s*url\(/audios/rails.mp3\)'
|
85
|
+
assert_match css_output, %r{font-path:\s*"/assets/rails.ttf"}, 'font-path:\s*"/assets/rails.ttf"'
|
86
|
+
assert_match css_output, %r{font-url:\s*url\(/assets/rails.ttf\)}, 'font-url:\s*url\(/assets/rails.ttf\)'
|
87
|
+
assert_match css_output, %r{javascript-path:\s*"/assets/rails.js"}, 'javascript-path:\s*"/assets/rails.js"'
|
88
|
+
assert_match css_output, %r{javascript-url:\s*url\(/assets/rails.js\)}, 'javascript-url:\s*url\(/assets/rails.js\)'
|
89
|
+
assert_match css_output, %r{stylesheet-path:\s*"/assets/rails.css"}, 'stylesheet-path:\s*"/assets/rails.css"'
|
90
|
+
assert_match css_output, %r{stylesheet-url:\s*url\(/assets/rails.css\)}, 'stylesheet-url:\s*url\(/assets/rails.css\)'
|
80
91
|
|
81
92
|
asset_data_url_regexp = %r{asset-data-url:\s*url\((.*?)\)}
|
82
93
|
assert_match css_output, asset_data_url_regexp, 'asset-data-url:\s*url\((.*?)\)'
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
hash: 5
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 3
|
8
|
+
- 1
|
9
|
+
- 3
|
10
|
+
version: 3.1.3
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- wycats
|
@@ -11,7 +16,7 @@ autorequire:
|
|
11
16
|
bindir: bin
|
12
17
|
cert_chain: []
|
13
18
|
|
14
|
-
date: 2011-09-
|
19
|
+
date: 2011-09-28 00:00:00 -03:00
|
15
20
|
default_executable:
|
16
21
|
dependencies:
|
17
22
|
- !ruby/object:Gem::Dependency
|
@@ -22,6 +27,11 @@ dependencies:
|
|
22
27
|
requirements:
|
23
28
|
- - ">="
|
24
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 11
|
31
|
+
segments:
|
32
|
+
- 3
|
33
|
+
- 1
|
34
|
+
- 4
|
25
35
|
version: 3.1.4
|
26
36
|
type: :runtime
|
27
37
|
version_requirements: *id001
|
@@ -33,6 +43,11 @@ dependencies:
|
|
33
43
|
requirements:
|
34
44
|
- - ~>
|
35
45
|
- !ruby/object:Gem::Version
|
46
|
+
hash: 3
|
47
|
+
segments:
|
48
|
+
- 3
|
49
|
+
- 1
|
50
|
+
- 0
|
36
51
|
version: 3.1.0
|
37
52
|
type: :runtime
|
38
53
|
version_requirements: *id002
|
@@ -44,6 +59,11 @@ dependencies:
|
|
44
59
|
requirements:
|
45
60
|
- - ~>
|
46
61
|
- !ruby/object:Gem::Version
|
62
|
+
hash: 3
|
63
|
+
segments:
|
64
|
+
- 3
|
65
|
+
- 1
|
66
|
+
- 0
|
47
67
|
version: 3.1.0
|
48
68
|
type: :runtime
|
49
69
|
version_requirements: *id003
|
@@ -55,6 +75,11 @@ dependencies:
|
|
55
75
|
requirements:
|
56
76
|
- - ~>
|
57
77
|
- !ruby/object:Gem::Version
|
78
|
+
hash: 31
|
79
|
+
segments:
|
80
|
+
- 1
|
81
|
+
- 3
|
82
|
+
- 2
|
58
83
|
version: 1.3.2
|
59
84
|
type: :runtime
|
60
85
|
version_requirements: *id004
|
@@ -66,6 +91,11 @@ dependencies:
|
|
66
91
|
requirements:
|
67
92
|
- - ~>
|
68
93
|
- !ruby/object:Gem::Version
|
94
|
+
hash: 15
|
95
|
+
segments:
|
96
|
+
- 2
|
97
|
+
- 0
|
98
|
+
- 0
|
69
99
|
version: 2.0.0
|
70
100
|
type: :runtime
|
71
101
|
version_requirements: *id005
|
@@ -81,6 +111,7 @@ extra_rdoc_files: []
|
|
81
111
|
|
82
112
|
files:
|
83
113
|
- .gitignore
|
114
|
+
- CHANGELOG.md
|
84
115
|
- Gemfile
|
85
116
|
- MIT-LICENSE
|
86
117
|
- README.markdown
|
@@ -263,17 +294,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
263
294
|
requirements:
|
264
295
|
- - ">="
|
265
296
|
- !ruby/object:Gem::Version
|
297
|
+
hash: 3
|
298
|
+
segments:
|
299
|
+
- 0
|
266
300
|
version: "0"
|
267
301
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
268
302
|
none: false
|
269
303
|
requirements:
|
270
304
|
- - ">="
|
271
305
|
- !ruby/object:Gem::Version
|
306
|
+
hash: 3
|
307
|
+
segments:
|
308
|
+
- 0
|
272
309
|
version: "0"
|
273
310
|
requirements: []
|
274
311
|
|
275
312
|
rubyforge_project: sass-rails
|
276
|
-
rubygems_version: 1.
|
313
|
+
rubygems_version: 1.3.7
|
277
314
|
signing_key:
|
278
315
|
specification_version: 3
|
279
316
|
summary: Sass adapter for the Rails asset pipeline.
|