sprockets-sass 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -2
- data/lib/sprockets/sass/functions.rb +21 -9
- data/lib/sprockets/sass/version.rb +1 -1
- data/spec/fixtures/image.jpg +0 -0
- data/spec/sprockets-sass_spec.rb +7 -0
- metadata +25 -63
data/README.md
CHANGED
@@ -168,8 +168,14 @@ background: asset-url("logo.jpg"); // background: url("/assets/logo.jpg");
|
|
168
168
|
The API of the functions mimics the helpers provided by sprockets-helpers, using Sass keyword arguments as options:
|
169
169
|
|
170
170
|
``` scss
|
171
|
-
background: asset-url("logo.jpg", $digest: true); // background: url("
|
172
|
-
background: asset-url("logo", $prefix: "/themes", $ext: "jpg"); // background: url("
|
171
|
+
background: asset-url("logo.jpg", $digest: true); // background: url("/assets/logo-27a8f1f96afd8d4c67a59eb9447f45bd.jpg");
|
172
|
+
background: asset-url("logo", $prefix: "/themes", $ext: "jpg"); // background: url("/themes/logo.jpg");
|
173
|
+
```
|
174
|
+
|
175
|
+
As of version 0.6.0, `#asset_data_uri` has been added, which creates a data URI for the given asset:
|
176
|
+
|
177
|
+
``` scss
|
178
|
+
background: asset-data-uri("image.jpg"); // background: url(data:image/jpeg;base64,...);
|
173
179
|
```
|
174
180
|
|
175
181
|
|
@@ -79,6 +79,17 @@ module Sprockets
|
|
79
79
|
::Sass::Script::String.new "url(#{image_path(source, options)})"
|
80
80
|
end
|
81
81
|
|
82
|
+
# Using Sprockets::Context#asset_data_uri return a Base64-encoded `data:`
|
83
|
+
# URI with the contents of the asset at the specified path.
|
84
|
+
#
|
85
|
+
# === Examples
|
86
|
+
#
|
87
|
+
# background: asset-data-uri("image.jpg"); // background: url(data:image/jpeg;base64,...);
|
88
|
+
#
|
89
|
+
def asset_data_uri(source)
|
90
|
+
::Sass::Script::String.new "url(#{context.asset_data_uri(source.value)})"
|
91
|
+
end
|
92
|
+
|
82
93
|
protected
|
83
94
|
|
84
95
|
# Returns a reference to the Sprocket's context through
|
@@ -103,16 +114,17 @@ module Sass::Script::Functions
|
|
103
114
|
|
104
115
|
# Hack to ensure previous API declarations (by Compass or whatever)
|
105
116
|
# don't take precedence.
|
106
|
-
[:asset_path, :asset_url, :image_path, :image_url].each do |method|
|
117
|
+
[:asset_path, :asset_url, :image_path, :image_url, :asset_data_uri].each do |method|
|
107
118
|
defined?(@signatures) && @signatures.delete(method)
|
108
119
|
end
|
109
120
|
|
110
|
-
declare :asset_path,
|
111
|
-
declare :asset_path,
|
112
|
-
declare :asset_url,
|
113
|
-
declare :asset_url,
|
114
|
-
declare :image_path,
|
115
|
-
declare :image_url,
|
116
|
-
declare :image_url,
|
117
|
-
declare :image_url,
|
121
|
+
declare :asset_path, [:source], :var_kwargs => true
|
122
|
+
declare :asset_path, [:source, :kind]
|
123
|
+
declare :asset_url, [:source], :var_kwargs => true
|
124
|
+
declare :asset_url, [:source, :kind]
|
125
|
+
declare :image_path, [:source], :var_kwargs => true
|
126
|
+
declare :image_url, [:source], :var_kwargs => true
|
127
|
+
declare :image_url, [:source, :only_path]
|
128
|
+
declare :image_url, [:source, :only_path, :cache_buster]
|
129
|
+
declare :asset_data_uri, [:source]
|
118
130
|
end
|
Binary file
|
data/spec/sprockets-sass_spec.rb
CHANGED
@@ -207,6 +207,13 @@ describe Sprockets::Sass do
|
|
207
207
|
@env["image_url_options.css"].to_s.should =~ %r(body \{\n background: url\("/themes/image-[0-9a-f]+.jpg"\); \}\n)
|
208
208
|
end
|
209
209
|
|
210
|
+
it "adds the #asset_data_uri helper" do
|
211
|
+
@assets.file "asset_data_uri.css.scss", %(body { background: asset-data-uri("image.jpg"); })
|
212
|
+
@assets.file "image.jpg", File.read("spec/fixtures/image.jpg")
|
213
|
+
|
214
|
+
@env["asset_data_uri.css"].to_s.should == %(body {\n background: url(data:image/jpeg;base64,%2F9j%2F4AAQSkZJRgABAgAAZABkAAD%2F7AARRHVja3kAAQAEAAAAPAAA%2F%2B4ADkFkb2JlAGTAAAAAAf%2FbAIQABgQEBAUEBgUFBgkGBQYJCwgGBggLDAoKCwoKDBAMDAwMDAwQDA4PEA8ODBMTFBQTExwbGxscHx8fHx8fHx8fHwEHBwcNDA0YEBAYGhURFRofHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8f%2F8AAEQgAAQABAwERAAIRAQMRAf%2FEAEoAAQAAAAAAAAAAAAAAAAAAAAgBAQAAAAAAAAAAAAAAAAAAAAAQAQAAAAAAAAAAAAAAAAAAAAARAQAAAAAAAAAAAAAAAAAAAAD%2F2gAMAwEAAhEDEQA%2FACoD%2F9k%3D); }\n)
|
215
|
+
end
|
216
|
+
|
210
217
|
it "mirrors Compass's #image_url helper" do
|
211
218
|
@assets.file "image_path.css.scss", %(body { background: url(image-url("image.jpg", true)); })
|
212
219
|
@assets.file "image_url.css.scss", %(body { background: image-url("image.jpg", false); })
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-sass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 9
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 0
|
8
|
-
- 5
|
9
|
-
- 1
|
10
|
-
version: 0.5.1
|
5
|
+
version: 0.6.0
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Pete Browne
|
@@ -15,141 +10,106 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-12-
|
13
|
+
date: 2011-12-10 00:00:00 Z
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
16
|
+
name: sprockets
|
22
17
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
18
|
none: false
|
24
19
|
requirements:
|
25
20
|
- - ~>
|
26
21
|
- !ruby/object:Gem::Version
|
27
|
-
hash: 3
|
28
|
-
segments:
|
29
|
-
- 2
|
30
|
-
- 0
|
31
22
|
version: "2.0"
|
23
|
+
type: :runtime
|
32
24
|
prerelease: false
|
33
|
-
name: sprockets
|
34
25
|
version_requirements: *id001
|
35
26
|
- !ruby/object:Gem::Dependency
|
36
|
-
|
27
|
+
name: tilt
|
37
28
|
requirement: &id002 !ruby/object:Gem::Requirement
|
38
29
|
none: false
|
39
30
|
requirements:
|
40
31
|
- - ~>
|
41
32
|
- !ruby/object:Gem::Version
|
42
|
-
hash: 13
|
43
|
-
segments:
|
44
|
-
- 1
|
45
|
-
- 1
|
46
33
|
version: "1.1"
|
34
|
+
type: :runtime
|
47
35
|
prerelease: false
|
48
|
-
name: tilt
|
49
36
|
version_requirements: *id002
|
50
37
|
- !ruby/object:Gem::Dependency
|
51
|
-
|
38
|
+
name: appraisal
|
52
39
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
40
|
none: false
|
54
41
|
requirements:
|
55
42
|
- - ~>
|
56
43
|
- !ruby/object:Gem::Version
|
57
|
-
hash: 3
|
58
|
-
segments:
|
59
|
-
- 0
|
60
|
-
- 4
|
61
44
|
version: "0.4"
|
45
|
+
type: :development
|
62
46
|
prerelease: false
|
63
|
-
name: appraisal
|
64
47
|
version_requirements: *id003
|
65
48
|
- !ruby/object:Gem::Dependency
|
66
|
-
|
49
|
+
name: rspec
|
67
50
|
requirement: &id004 !ruby/object:Gem::Requirement
|
68
51
|
none: false
|
69
52
|
requirements:
|
70
53
|
- - ~>
|
71
54
|
- !ruby/object:Gem::Version
|
72
|
-
hash: 15
|
73
|
-
segments:
|
74
|
-
- 2
|
75
|
-
- 6
|
76
55
|
version: "2.6"
|
56
|
+
type: :development
|
77
57
|
prerelease: false
|
78
|
-
name: rspec
|
79
58
|
version_requirements: *id004
|
80
59
|
- !ruby/object:Gem::Dependency
|
81
|
-
|
60
|
+
name: test-construct
|
82
61
|
requirement: &id005 !ruby/object:Gem::Requirement
|
83
62
|
none: false
|
84
63
|
requirements:
|
85
64
|
- - ~>
|
86
65
|
- !ruby/object:Gem::Version
|
87
|
-
hash: 11
|
88
|
-
segments:
|
89
|
-
- 1
|
90
|
-
- 2
|
91
66
|
version: "1.2"
|
67
|
+
type: :development
|
92
68
|
prerelease: false
|
93
|
-
name: test-construct
|
94
69
|
version_requirements: *id005
|
95
70
|
- !ruby/object:Gem::Dependency
|
96
|
-
|
71
|
+
name: sprockets-helpers
|
97
72
|
requirement: &id006 !ruby/object:Gem::Requirement
|
98
73
|
none: false
|
99
74
|
requirements:
|
100
75
|
- - ~>
|
101
76
|
- !ruby/object:Gem::Version
|
102
|
-
hash: 15
|
103
|
-
segments:
|
104
|
-
- 0
|
105
|
-
- 2
|
106
77
|
version: "0.2"
|
78
|
+
type: :development
|
107
79
|
prerelease: false
|
108
|
-
name: sprockets-helpers
|
109
80
|
version_requirements: *id006
|
110
81
|
- !ruby/object:Gem::Dependency
|
111
|
-
|
82
|
+
name: sass
|
112
83
|
requirement: &id007 !ruby/object:Gem::Requirement
|
113
84
|
none: false
|
114
85
|
requirements:
|
115
86
|
- - ~>
|
116
87
|
- !ruby/object:Gem::Version
|
117
|
-
hash: 5
|
118
|
-
segments:
|
119
|
-
- 3
|
120
|
-
- 1
|
121
88
|
version: "3.1"
|
89
|
+
type: :development
|
122
90
|
prerelease: false
|
123
|
-
name: sass
|
124
91
|
version_requirements: *id007
|
125
92
|
- !ruby/object:Gem::Dependency
|
126
|
-
|
93
|
+
name: compass
|
127
94
|
requirement: &id008 !ruby/object:Gem::Requirement
|
128
95
|
none: false
|
129
96
|
requirements:
|
130
97
|
- - ~>
|
131
98
|
- !ruby/object:Gem::Version
|
132
|
-
hash: 29
|
133
|
-
segments:
|
134
|
-
- 0
|
135
|
-
- 11
|
136
99
|
version: "0.11"
|
100
|
+
type: :development
|
137
101
|
prerelease: false
|
138
|
-
name: compass
|
139
102
|
version_requirements: *id008
|
140
103
|
- !ruby/object:Gem::Dependency
|
141
|
-
|
104
|
+
name: rake
|
142
105
|
requirement: &id009 !ruby/object:Gem::Requirement
|
143
106
|
none: false
|
144
107
|
requirements:
|
145
108
|
- - ">="
|
146
109
|
- !ruby/object:Gem::Version
|
147
|
-
hash: 3
|
148
|
-
segments:
|
149
|
-
- 0
|
150
110
|
version: "0"
|
111
|
+
type: :development
|
151
112
|
prerelease: false
|
152
|
-
name: rake
|
153
113
|
version_requirements: *id009
|
154
114
|
description: When using Sprockets 2.0 with Sass you will eventually run into a pretty big issue. `//= require` directives will not allow Sass mixins, variables, etc. to be shared between files. So you'll try to use `@import`, and that'll also blow up in your face. `sprockets-sass` fixes all of this by creating a Sass::Importer that is Sprockets aware.
|
155
115
|
email:
|
@@ -178,6 +138,7 @@ files:
|
|
178
138
|
- lib/sprockets/sass/sass_template.rb
|
179
139
|
- lib/sprockets/sass/scss_template.rb
|
180
140
|
- lib/sprockets/sass/version.rb
|
141
|
+
- spec/fixtures/image.jpg
|
181
142
|
- spec/spec_helper.rb
|
182
143
|
- spec/sprockets-sass_spec.rb
|
183
144
|
- spec/support/be_fresh_matcher.rb
|
@@ -195,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
195
156
|
requirements:
|
196
157
|
- - ">="
|
197
158
|
- !ruby/object:Gem::Version
|
198
|
-
hash:
|
159
|
+
hash: 3715300180308166136
|
199
160
|
segments:
|
200
161
|
- 0
|
201
162
|
version: "0"
|
@@ -204,18 +165,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
165
|
requirements:
|
205
166
|
- - ">="
|
206
167
|
- !ruby/object:Gem::Version
|
207
|
-
hash:
|
168
|
+
hash: 3715300180308166136
|
208
169
|
segments:
|
209
170
|
- 0
|
210
171
|
version: "0"
|
211
172
|
requirements: []
|
212
173
|
|
213
174
|
rubyforge_project: sprockets-sass
|
214
|
-
rubygems_version: 1.8.
|
175
|
+
rubygems_version: 1.8.8
|
215
176
|
signing_key:
|
216
177
|
specification_version: 3
|
217
178
|
summary: Better Sass integration with Sprockets 2.0
|
218
179
|
test_files:
|
180
|
+
- spec/fixtures/image.jpg
|
219
181
|
- spec/spec_helper.rb
|
220
182
|
- spec/sprockets-sass_spec.rb
|
221
183
|
- spec/support/be_fresh_matcher.rb
|