roger_sassc 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/roger_sassc/middleware.rb +43 -18
- data/lib/roger_sassc/sassc/asset_functions.rb +1 -1
- data/lib/roger_sassc/version.rb +1 -1
- data/roger_sassc.gemspec +1 -1
- data/test/fixtures/errors/syntax.css +3 -3
- data/test/fixtures/output.css.map +10 -0
- data/test/fixtures/output_with_map.css +4 -0
- data/test/middleware_test.rb +28 -6
- metadata +32 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5a3a241d0b52af346178cb0c34a601b43447388
|
4
|
+
data.tar.gz: 42613afcc506b5d318759ddcca4f354be8cf516b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 266f120b1e519b5858da86f0f3051abb2f6d50604d3b6fb764b67bdae6c29268447ab2fe2d31d93280f8b5af0d90aae8006b447b7f78375eb588a0b8fdaa8ce1
|
7
|
+
data.tar.gz: 2234ca0a4beac1472867d0939bd597743e1fdb09fc84b6ddb1bb1827ca5008ec35a59dd8a5be258dfa791dfcaee3c72c247cd817e6cd648f107fc8c063b0713b
|
data/CHANGELOG.md
ADDED
@@ -16,7 +16,9 @@ module RogerSassc
|
|
16
16
|
@app = app
|
17
17
|
|
18
18
|
defaults = {
|
19
|
-
load_paths: RogerSassc.load_paths
|
19
|
+
load_paths: RogerSassc.load_paths,
|
20
|
+
source_map: true,
|
21
|
+
source_map_embed: true
|
20
22
|
}
|
21
23
|
|
22
24
|
@options = defaults.update(options)
|
@@ -27,28 +29,34 @@ module RogerSassc
|
|
27
29
|
@options[:roger_html_path] = @project.html_path
|
28
30
|
|
29
31
|
url = ::Rack::Utils.unescape(env["PATH_INFO"].to_s).sub(%r{^/}, "")
|
32
|
+
unless url.end_with?(".css") || url.end_with?(".css.map")
|
33
|
+
return @app.call(env)
|
34
|
+
end
|
30
35
|
|
31
36
|
# Convert the url to an absolute path,
|
32
37
|
# which is used to retrieve compile the scss
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
38
|
+
scss_path = resolve_url(url)
|
39
|
+
|
40
|
+
return @app.call(env) unless scss_path
|
41
|
+
|
42
|
+
env["rack.errors"].puts "Invoking ruby-sassc for #{scss_path}"
|
43
|
+
engine = create_scss_engine(scss_path)
|
44
|
+
|
45
|
+
begin
|
46
|
+
respond(engine, url.end_with?(".css.map"))
|
47
|
+
rescue ::SassC::SyntaxError,
|
48
|
+
::SassC::NotRenderedError,
|
49
|
+
::SassC::InvalidStyleError => sassc_error
|
50
|
+
respond_with_error(sassc_error)
|
46
51
|
end
|
47
52
|
end
|
48
53
|
|
49
54
|
private
|
50
55
|
|
51
56
|
def resolve_url(url)
|
57
|
+
# Make sure we strip off .map
|
58
|
+
url = url.gsub(/.map\Z/, "")
|
59
|
+
|
52
60
|
# A .css file is requested in the browser
|
53
61
|
url = url[0..-4] + "scss"
|
54
62
|
|
@@ -57,11 +65,16 @@ module RogerSassc
|
|
57
65
|
resolver.url_to_path url, exact_match: true
|
58
66
|
end
|
59
67
|
|
60
|
-
def
|
68
|
+
def create_scss_engine(scss_path)
|
61
69
|
# Supply the filename for load path resolving
|
62
70
|
@options[:filename] = scss_path.to_s
|
71
|
+
if @options[:source_map] || @options[:source_map_embed]
|
72
|
+
@options[:source_map_file] = scss_path.to_s + ".map"
|
73
|
+
|
74
|
+
@options[:source_map] = true
|
75
|
+
end
|
63
76
|
|
64
|
-
::SassC::Engine.new(File.read(scss_path), @options)
|
77
|
+
::SassC::Engine.new(File.read(scss_path), @options)
|
65
78
|
end
|
66
79
|
|
67
80
|
def debug_css(sassc_error)
|
@@ -87,12 +100,24 @@ module RogerSassc
|
|
87
100
|
@resolver ||= Roger::Resolver.new(@project.html_path)
|
88
101
|
end
|
89
102
|
|
90
|
-
def
|
103
|
+
def respond_with_error(err)
|
104
|
+
resp = ::Rack::Response.new do |res|
|
105
|
+
res.status = 200
|
106
|
+
res.headers["Content-Type"] = "text/css"
|
107
|
+
# last modified header
|
108
|
+
res.write debug_css(err)
|
109
|
+
end
|
110
|
+
resp.finish
|
111
|
+
end
|
112
|
+
|
113
|
+
def respond(engine, map = false)
|
114
|
+
css = engine.render
|
115
|
+
|
91
116
|
resp = ::Rack::Response.new do |res|
|
92
117
|
res.status = 200
|
93
118
|
res.headers["Content-Type"] = "text/css"
|
94
119
|
# last modified header
|
95
|
-
res.write css
|
120
|
+
res.write map ? engine.source_map : css
|
96
121
|
end
|
97
122
|
resp.finish
|
98
123
|
end
|
data/lib/roger_sassc/version.rb
CHANGED
data/roger_sassc.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_dependency "sassc", "~> 1.
|
20
|
+
spec.add_dependency "sassc", "~> 1.10.0"
|
21
21
|
spec.add_dependency "roger", "~> 1.0"
|
22
22
|
spec.add_dependency "rack"
|
23
23
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
/*
|
2
|
-
Error:
|
2
|
+
Error: Invalid CSS after "...ckground: #fff;": expected "}", was ""
|
3
3
|
on line 2 of test/fixtures/errors/syntax.scss
|
4
4
|
>> background: #fff;
|
5
|
-
|
5
|
+
--------------------^
|
6
6
|
|
7
7
|
|
8
8
|
Load paths:
|
@@ -12,4 +12,4 @@ Load paths:
|
|
12
12
|
body:before {
|
13
13
|
white-space: pre;
|
14
14
|
font-family: monospace;
|
15
|
-
content: 'Error:
|
15
|
+
content: 'Error: Invalid CSS after "...ckground: #fff;": expected "}", was ""\A on line 2 of test/fixtures/errors/syntax.scss\A>> background: #fff;\A --------------------^\A'; }
|
@@ -0,0 +1,4 @@
|
|
1
|
+
.selector .baby-selector {
|
2
|
+
color: #000; }
|
3
|
+
|
4
|
+
/*# sourceMappingURL=data:application/json;base64,ewoJInZlcnNpb24iOiAzLAoJImZpbGUiOiAiZ2VuZXJhbC5jc3MiLAoJInNvdXJjZXMiOiBbCgkJImdlbmVyYWwuc2NzcyIsCgkJInNyYy9fdmFyaWFibGVzLnNjc3MiCgldLAoJIm1hcHBpbmdzIjogIkFBRUEsQUFDRSxTQURPLENBQ1AsY0FBYyxDQUFDO0VBQ2IsS0FBSyxFQ0pELElBQUksR0RLVCIsCgkibmFtZXMiOiBbXQp9 */
|
data/test/middleware_test.rb
CHANGED
@@ -10,8 +10,16 @@ module RogerSassc
|
|
10
10
|
include FixtureHelper
|
11
11
|
|
12
12
|
def setup
|
13
|
+
setup_app(source_map: false, source_map_embed: false)
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
@middleware.project.destroy
|
18
|
+
end
|
19
|
+
|
20
|
+
def setup_app(options = {})
|
13
21
|
@app = proc { [200, {}, ["YAM"]] } # Yet another middleware
|
14
|
-
@middleware = Middleware.new @app
|
22
|
+
@middleware = Middleware.new @app, options
|
15
23
|
|
16
24
|
# Inject mock project
|
17
25
|
@middleware.project = Roger::Testing::MockProject.new
|
@@ -22,10 +30,6 @@ module RogerSassc
|
|
22
30
|
@request = Rack::MockRequest.new(@middleware)
|
23
31
|
end
|
24
32
|
|
25
|
-
def teardown
|
26
|
-
@middleware.project.destroy
|
27
|
-
end
|
28
|
-
|
29
33
|
def test_middleware_can_be_called
|
30
34
|
assert(@middleware.respond_to?(:call))
|
31
35
|
end
|
@@ -43,7 +47,25 @@ module RogerSassc
|
|
43
47
|
path = fixture_path "general.scss"
|
44
48
|
expected_css = fixture "output.css"
|
45
49
|
@middleware.resolver = mock_resolver("test/fixtures/general.scss", path)
|
46
|
-
assert_equal @request.get("/test/fixtures/general.css").body
|
50
|
+
assert_equal expected_css, @request.get("/test/fixtures/general.css").body
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_response_with_source_map
|
54
|
+
setup_app(source_map: true)
|
55
|
+
|
56
|
+
path = fixture_path "general.scss"
|
57
|
+
expected_css = fixture "output.css.map"
|
58
|
+
@middleware.resolver = mock_resolver("test/fixtures/general.scss", path)
|
59
|
+
assert_equal expected_css, @request.get("/test/fixtures/general.css.map").body
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_inline_source_map
|
63
|
+
setup_app(source_map: true)
|
64
|
+
|
65
|
+
path = fixture_path "general.scss"
|
66
|
+
expected_css = fixture "output_with_map.css"
|
67
|
+
@middleware.resolver = mock_resolver("test/fixtures/general.scss", path)
|
68
|
+
assert_equal expected_css, @request.get("/test/fixtures/general.css").body
|
47
69
|
end
|
48
70
|
|
49
71
|
def test_debug_syntax_error
|
metadata
CHANGED
@@ -1,125 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roger_sassc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edwin van der Graaf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sassc
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.10.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.10.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: roger
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rack
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '10.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '10.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mocha
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 1.1.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 1.1.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: test-unit
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 3.1.2
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 3.1.2
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: simplecov
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 0.10.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.10.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rubocop
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - ~>
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: 0.31.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - ~>
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 0.31.0
|
125
125
|
description:
|
@@ -129,10 +129,11 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
-
- .gitignore
|
133
|
-
- .hound.yml
|
134
|
-
- .rubocop.yml
|
135
|
-
- .travis.yml
|
132
|
+
- ".gitignore"
|
133
|
+
- ".hound.yml"
|
134
|
+
- ".rubocop.yml"
|
135
|
+
- ".travis.yml"
|
136
|
+
- CHANGELOG.md
|
136
137
|
- Gemfile
|
137
138
|
- LICENSE.txt
|
138
139
|
- README.md
|
@@ -154,6 +155,8 @@ files:
|
|
154
155
|
- test/fixtures/general.scss
|
155
156
|
- test/fixtures/images/logo.svg
|
156
157
|
- test/fixtures/output.css
|
158
|
+
- test/fixtures/output.css.map
|
159
|
+
- test/fixtures/output_with_map.css
|
157
160
|
- test/fixtures/raise.scss
|
158
161
|
- test/fixtures/src/_variables.scss
|
159
162
|
- test/helpers/fixture_helper.rb
|
@@ -171,17 +174,17 @@ require_paths:
|
|
171
174
|
- lib
|
172
175
|
required_ruby_version: !ruby/object:Gem::Requirement
|
173
176
|
requirements:
|
174
|
-
- -
|
177
|
+
- - ">="
|
175
178
|
- !ruby/object:Gem::Version
|
176
179
|
version: '0'
|
177
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
181
|
requirements:
|
179
|
-
- -
|
182
|
+
- - ">="
|
180
183
|
- !ruby/object:Gem::Version
|
181
184
|
version: '0'
|
182
185
|
requirements: []
|
183
186
|
rubyforge_project:
|
184
|
-
rubygems_version: 2.
|
187
|
+
rubygems_version: 2.5.1
|
185
188
|
signing_key:
|
186
189
|
specification_version: 4
|
187
190
|
summary: Sass plugin for Roger based on libsass
|
@@ -197,6 +200,8 @@ test_files:
|
|
197
200
|
- test/fixtures/general.scss
|
198
201
|
- test/fixtures/images/logo.svg
|
199
202
|
- test/fixtures/output.css
|
203
|
+
- test/fixtures/output.css.map
|
204
|
+
- test/fixtures/output_with_map.css
|
200
205
|
- test/fixtures/raise.scss
|
201
206
|
- test/fixtures/src/_variables.scss
|
202
207
|
- test/helpers/fixture_helper.rb
|