sinatra-asset-snack 0.1.1 → 0.1.2
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 +8 -8
- data/Gemfile.lock +1 -1
- data/README.md +13 -0
- data/lib/sinatra/asset_snack/compilers/asset_compiler.rb +8 -3
- data/lib/sinatra/asset_snack/compilers/coffee_script_compiler.rb +1 -1
- data/lib/sinatra/asset_snack/compilers/sass_compiler.rb +12 -3
- data/lib/sinatra/asset_snack/version.rb +1 -1
- data/test/asset_snack_test.rb +0 -1
- data/test/compilers/sass_compiler_test.rb +21 -15
- data/test/fixtures/test.sass +11 -0
- data/test/fixtures/test.scss +13 -4
- metadata +2 -2
- data/releases/sinatra-asset-snack-0.1.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGFjM2IyOTk1ODQwMTI0MmE0MDJlZGVlNmZhZjYwNTcwMTY3ODg2MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTQ0ZWJkMWJiYWRiNDgyNDk4MThhNDM0NDFmYWQ5YTg5NTE2MDM2Zg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWYzMjlmOTBiODc2Yjg3NjBjM2M4MTM4NDJjODViYWI1M2YyMWIzYzIwYjkw
|
10
|
+
MGE2NzYyY2VmZTUyZWQzMDEyNDhkMTI3OTNjZTFlYjBjOTVkZmUyMzM2YWE4
|
11
|
+
NDgwMjYyYmE2NTZiMGRkYTU1NTIzNWRiM2EzNzZkMDIxMWZhOGU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzQ3YTk2NzFkOTg5Y2E1MGYwYTA1Y2FhMjViMDNhNjU5YjczMDdlMTYyYWJh
|
14
|
+
YTM1ZDZjM2Q4MDQ1MzRlYWQ0M2E4MTdmMDhkNTAyMjRmNTM0NTdlMzUzNzQ3
|
15
|
+
YWRiNTA3ZGRhMjBjNmMwNGUzYWU5YmQ3NDYxNzVhYmRlMmRiOTI=
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -43,6 +43,19 @@ If you want - use the helpers to add cache busting
|
|
43
43
|
<script src="<%= nocache '/javascript/application.js' %>" type="text/javascript"></script>
|
44
44
|
```
|
45
45
|
|
46
|
+
## Configuring
|
47
|
+
|
48
|
+
Configuration options may be passed into each compiler. For example
|
49
|
+
|
50
|
+
``` ruby
|
51
|
+
Sinatra::AssetSnack.configure do |config|
|
52
|
+
config.compilers[:coffee_script] = {bare: true}
|
53
|
+
config.compilers[:sass] = {syntax: :scss}
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
See each compiler's repo for the list of configuration options
|
58
|
+
|
46
59
|
[sinatra]: http://sinatrarb.com
|
47
60
|
[coffee-script]: http://github.com/josh/ruby-coffee-script
|
48
61
|
[sass]: http://sass-lang.com/
|
@@ -17,12 +17,17 @@ module Sinatra
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
def ext_for(file_path)
|
21
|
+
return if file_path.nil?
|
22
|
+
File.extname(file_path).downcase[1..-1]
|
23
|
+
end
|
24
|
+
|
20
25
|
def compile_file(file_path)
|
21
|
-
ext =
|
26
|
+
ext = ext_for file_path
|
22
27
|
return unless ext && handled_extensions.include?(ext.to_sym)
|
23
28
|
|
24
29
|
file_content = File.read file_path
|
25
|
-
new.compile(file_content)
|
30
|
+
new.compile(file_content, file_path)
|
26
31
|
end
|
27
32
|
|
28
33
|
def handle_extensions(*extensions)
|
@@ -35,7 +40,7 @@ module Sinatra
|
|
35
40
|
end
|
36
41
|
end
|
37
42
|
|
38
|
-
def compile
|
43
|
+
def compile(script, file_path = nil)
|
39
44
|
throw "Not Implemented"
|
40
45
|
end
|
41
46
|
end
|
@@ -2,11 +2,20 @@ module Sinatra
|
|
2
2
|
module AssetSnack
|
3
3
|
module Compilers
|
4
4
|
class SassCompiler < AssetCompiler
|
5
|
-
handle_extensions :scss
|
5
|
+
handle_extensions :scss, :sass
|
6
6
|
mime_type 'text/css'
|
7
7
|
|
8
|
-
def
|
9
|
-
|
8
|
+
def ext_for(file_path)
|
9
|
+
AssetCompiler.ext_for file_path
|
10
|
+
end
|
11
|
+
|
12
|
+
def compile(sass_script, file_path = nil)
|
13
|
+
config = self.class.configuration
|
14
|
+
if file_path && ext_for(file_path) == 'sass'
|
15
|
+
config.merge!(syntax: :sass)
|
16
|
+
end
|
17
|
+
|
18
|
+
Sass.compile(sass_script, config)
|
10
19
|
end
|
11
20
|
end
|
12
21
|
end # Compilers
|
data/test/asset_snack_test.rb
CHANGED
@@ -2,30 +2,32 @@ require './test/test_helper'
|
|
2
2
|
|
3
3
|
module Sinatra
|
4
4
|
describe AssetSnack::Compilers::SassCompiler do
|
5
|
-
let(:file_path) { File.join File.dirname(__FILE__), '../', 'fixtures', 'test.scss' }
|
6
5
|
subject { AssetSnack::Compilers::SassCompiler.new }
|
7
|
-
let(:
|
8
|
-
|
9
|
-
.
|
10
|
-
.one {
|
11
|
-
color: red;
|
12
|
-
}
|
13
|
-
}
|
14
|
-
EOS
|
15
|
-
}
|
16
|
-
|
6
|
+
let(:scss_file_path) { File.join File.dirname(__FILE__), '../', 'fixtures', 'test.scss' }
|
7
|
+
let(:sass_file_path) { File.join File.dirname(__FILE__), '../', 'fixtures', 'test.sass' }
|
8
|
+
let(:source) { File.read scss_file_path }
|
17
9
|
let(:compiled) {
|
18
10
|
<<-EOS
|
19
|
-
.
|
20
|
-
color:
|
11
|
+
.content-navigation {
|
12
|
+
border-color: #3bbfce;
|
13
|
+
color: #2ca2af; }
|
14
|
+
|
15
|
+
.border {
|
16
|
+
padding: 8px;
|
17
|
+
margin: 8px;
|
18
|
+
border-color: #3bbfce; }
|
21
19
|
EOS
|
22
20
|
}
|
23
21
|
|
24
22
|
it 'must compile a sass file' do
|
25
|
-
subject.class.compile_file(
|
23
|
+
subject.class.compile_file(sass_file_path).must_equal compiled
|
26
24
|
end
|
27
25
|
|
28
|
-
it 'must compile
|
26
|
+
it 'must compile a scss file' do
|
27
|
+
subject.class.compile_file(scss_file_path).must_equal compiled
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'must compile scss' do
|
29
31
|
css = subject.compile source
|
30
32
|
css.must_equal compiled
|
31
33
|
end
|
@@ -34,6 +36,10 @@ EOS
|
|
34
36
|
subject.class.handled_extensions.must_include :scss
|
35
37
|
end
|
36
38
|
|
39
|
+
it 'should handle files with extension sass' do
|
40
|
+
subject.class.handled_extensions.must_include :sass
|
41
|
+
end
|
42
|
+
|
37
43
|
it 'should compile to text/css' do
|
38
44
|
subject.class.compiled_mime_type.must_equal 'text/css'
|
39
45
|
end
|
data/test/fixtures/test.scss
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-asset-snack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Kitzelman
|
@@ -145,13 +145,13 @@ files:
|
|
145
145
|
- lib/sinatra/asset_snack/extensions.rb
|
146
146
|
- lib/sinatra/asset_snack/helpers.rb
|
147
147
|
- lib/sinatra/asset_snack/version.rb
|
148
|
-
- releases/sinatra-asset-snack-0.1.0.gem
|
149
148
|
- sinatra-asset-snack.gemspec
|
150
149
|
- test/asset_snack_test.rb
|
151
150
|
- test/compilers/coffee_script_compiler_test.rb
|
152
151
|
- test/compilers/sass_compiler_test.rb
|
153
152
|
- test/configuration_test.rb
|
154
153
|
- test/fixtures/test.coffee
|
154
|
+
- test/fixtures/test.sass
|
155
155
|
- test/fixtures/test.scss
|
156
156
|
- test/fixtures/test_two.coffee
|
157
157
|
- test/helpers_test.rb
|
Binary file
|