sinatra-asset-snack 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGMyNDljMmRiZDJkMDFhODIzNDFjMWEyMzNjMzc5YTE5YmYxN2RmMw==
4
+ ZGFjM2IyOTk1ODQwMTI0MmE0MDJlZGVlNmZhZjYwNTcwMTY3ODg2MA==
5
5
  data.tar.gz: !binary |-
6
- OTY5N2VlZjA2OTM3ZGNmNTdkYmViMjI5YWQzNGE3MDBkMTVkMTgyZA==
6
+ MTQ0ZWJkMWJiYWRiNDgyNDk4MThhNDM0NDFmYWQ5YTg5NTE2MDM2Zg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NDM2NGFmNzU1NDFkOTNiZDk2MzdlNjg5NGRlMjI3MmZhNTQwYjAyZGNhOTQ1
10
- MDA1NTZjYWEzOWNmMzAwZWNlYjM2ZjA0NGExZjNkZmEyMTYzNDNiMDkwZDhk
11
- MmU4M2JmMjViYWQzYWYzNzFiYmIyZjFiNDYyNjY0ZWQyYTQ3YjU=
9
+ MWYzMjlmOTBiODc2Yjg3NjBjM2M4MTM4NDJjODViYWI1M2YyMWIzYzIwYjkw
10
+ MGE2NzYyY2VmZTUyZWQzMDEyNDhkMTI3OTNjZTFlYjBjOTVkZmUyMzM2YWE4
11
+ NDgwMjYyYmE2NTZiMGRkYTU1NTIzNWRiM2EzNzZkMDIxMWZhOGU=
12
12
  data.tar.gz: !binary |-
13
- OTcyNGMwMDdiZTVjM2VjYzg3MTBlZWM1NTc3ZDA3Y2M3ZTE2ZTFkNjFjMjkw
14
- MjEyYzk3YzBjMjlmYjkzYTI3OTQ4NzNiNDhlYTUyMjBmNjM1YzJiMTMyNjkw
15
- M2NiZTQ4YjM4NWQ4OTU1YzY3NjQwMGU4NTg5ZmRjYzcxNTk3MGQ=
13
+ NzQ3YTk2NzFkOTg5Y2E1MGYwYTA1Y2FhMjViMDNhNjU5YjczMDdlMTYyYWJh
14
+ YTM1ZDZjM2Q4MDQ1MzRlYWQ0M2E4MTdmMDhkNTAyMjRmNTM0NTdlMzUzNzQ3
15
+ YWRiNTA3ZGRhMjBjNmMwNGUzYWU5YmQ3NDYxNzVhYmRlMmRiOTI=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sinatra-asset-snack (0.1.0)
4
+ sinatra-asset-snack (0.1.1)
5
5
  coffee-script
6
6
  sass
7
7
  sinatra
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 = File.extname(file_path).downcase[1..-1]
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
@@ -5,7 +5,7 @@ module Sinatra
5
5
  handle_extensions :coffee
6
6
  mime_type 'text/js'
7
7
 
8
- def compile(coffee_script)
8
+ def compile(coffee_script, file_path = nil)
9
9
  CoffeeScript.compile(coffee_script, self.class.configuration)
10
10
  end
11
11
  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 compile(sass_script)
9
- Sass.compile(sass_script, self.class.configuration)
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
@@ -1,7 +1,7 @@
1
1
  module Sinatra
2
2
  module AssetSnack
3
3
  def self.version
4
- '0.1.1'
4
+ '0.1.2'
5
5
  end
6
6
  end # AssetSnack
7
7
  end # Sinatra
@@ -26,7 +26,6 @@ module Sinatra
26
26
  end
27
27
 
28
28
  get '/javascript/application.js'
29
- puts last_response.body
30
29
  last_response.body.wont_include ').call(this);'
31
30
  end
32
31
  end
@@ -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(:source) {
8
- <<-EOS
9
- .test{
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
- .test .one {
20
- color: red; }
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(file_path).must_equal compiled
23
+ subject.class.compile_file(sass_file_path).must_equal compiled
26
24
  end
27
25
 
28
- it 'must compile sass' do
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
@@ -0,0 +1,11 @@
1
+ $blue: #3bbfce
2
+ $margin: 16px
3
+
4
+ .content-navigation
5
+ border-color: $blue
6
+ color: darken($blue, 9%)
7
+
8
+ .border
9
+ padding: $margin / 2
10
+ margin: $margin / 2
11
+ border-color: $blue
@@ -1,5 +1,14 @@
1
- .test{
2
- .one {
3
- color: red;
4
- }
1
+ $blue: #3bbfce;
2
+ $margin: 16px;
3
+
4
+ .content-navigation {
5
+ border-color: $blue;
6
+ color:
7
+ darken($blue, 9%);
8
+ }
9
+
10
+ .border {
11
+ padding: $margin / 2;
12
+ margin: $margin / 2;
13
+ border-color: $blue;
5
14
  }
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.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