sinatra-asset-snack 0.1.4 → 0.1.5

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
- NzY2NGVjNTU1NDAxOGY5N2FlYTllZmE2YWEwY2JiMzEyOTYxZTA3NA==
4
+ YzMxNmMwNWNjMzAwMTIwODk5NmMyZTJlMzdiZWFhYjNmM2MzZDU1YQ==
5
5
  data.tar.gz: !binary |-
6
- NjI2ZjExZTdmMTRlYjlhMDQ2YmJkY2VkYzU0Mjc0ZTNiZTVkZGM4Mw==
6
+ MGU2ZGI1NWI4ZTdiNGUwNTg2MjE3NzE4ZTYzMGNlNDgzZDU4YzliNQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MDJiNTNmOGE4NzI1NmM1NTEwNGU4ODA4MmZlMTA2NGIwNWUwOWNjYzI0NmRm
10
- Y2M0MWU4Yjc0NmFlNThiZTg4MDZjZTQzNDA3MjQ1MTVjN2JjNDJjYWViMWNm
11
- ODJkOWI2NDBiYTA3NzRjYTkxNWVhY2QzN2UwN2I1N2ExNTFkMWQ=
9
+ ZGVhNDVjZjY0MjEwMzM1NzY3NTViYjNiZTk3NmE0OTBlZjQ0Y2I2NWY4YjZl
10
+ ODkwYjZjM2Q0Zjk5ODM4ZmU1ZTc1OGUwN2ZiMjM2YTRiOTE5ZGFhYTU4MDM3
11
+ ZDQyNGFiNjdmM2RiYzU3YjQ4MDJmMDkyOGZiMzc5MDJiNWJhZTM=
12
12
  data.tar.gz: !binary |-
13
- ZDc3MjMzZWFkYzVjODY2NjM4NzRiNDg3MmU0N2JiMmUzN2M5ODdhZDIwNTU3
14
- NGEzZTFmNTlmZjgwNDcxODFkNDRjOTQ5ZDE0ODgzYjFhMzhhNWE1YWVlMzE2
15
- NmYzM2Y5NWEyNmUyOGEyNWZhY2VlMjM2NWI1Mzc3NDk1YTM1MDA=
13
+ NTM5MzhjZjJlMjgyZGUzNTJjMzY5MjBjNDMzMDgxY2FlZWM4OGNjM2FmYzli
14
+ MWViN2ZmNzk4MDFlNTQ4MDExMTFiNzUzOWYyNWNhYzUwOTk0NTZmMjlkOTE0
15
+ YTVhMmU3N2QwYmMxNWRlZjNlNjc2MDgzNjNmMjYwMWRiYmE0ODc=
data/Gemfile.lock CHANGED
@@ -3,6 +3,7 @@ PATH
3
3
  specs:
4
4
  sinatra-asset-snack (0.1.4)
5
5
  coffee-script
6
+ mime-types
6
7
  sass
7
8
  sinatra
8
9
 
@@ -19,6 +20,7 @@ GEM
19
20
  multi_json (~> 1.0)
20
21
  hashie (2.0.3)
21
22
  metaclass (0.0.1)
23
+ mime-types (1.21)
22
24
  minitest (4.7.0)
23
25
  minitest-reporters (0.14.11)
24
26
  ansi
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # AssetSnack for Sinatra
2
2
 
3
+ [![Build Status](https://travis-ci.org/benkitzelman/sinatra-asset-snack.png?branch=master)](https://travis-ci.org/benkitzelman/sinatra-asset-snack)
4
+ [![Gem Version](https://badge.fury.io/rb/sinatra-asset-snack.png)](http://badge.fury.io/rb/sinatra-asset-snack)
5
+
3
6
  A lean asset compiler for Sinatra developed specifically for Coffeescript and SASS.
4
7
  It stitches all assets for a route into a single file, no uglification, no minification (configure your server to use Gzip),
5
8
  just lean, fast compilation.
6
9
 
7
- [![Build Status](https://travis-ci.org/benkitzelman/sinatra-asset-snack.png?branch=master)](https://travis-ci.org/benkitzelman/sinatra-asset-snack)
8
- [![Gem Version](https://badge.fury.io/rb/sinatra-asset-snack.png)](http://badge.fury.io/rb/sinatra-asset-snack)
9
-
10
10
  ## Installation
11
11
  ### Bundler users
12
12
 
@@ -16,10 +16,9 @@ If you use Bundler, add it to your *Gemfile.*
16
16
  gem install sinatra-asset-snack
17
17
  ```
18
18
 
19
-
20
19
  ## Setup
21
20
 
22
- Install the plugin configure your routes.
21
+ Require and register the gem then configure your routes.
23
22
 
24
23
  ``` ruby
25
24
  require 'sinatra/asset_snack'
@@ -48,14 +47,15 @@ If you want - use the helpers to add cache busting
48
47
  Configuration options may be passed into each compiler. For example
49
48
 
50
49
  ``` ruby
51
- Sinatra::AssetSnack.configure do |config|
52
- config.compilers[:coffee_script] = {bare: true}
53
- config.compilers[:sass] = {syntax: :scss}
54
- end
50
+ Sinatra::AssetSnack.configuration.compilers[:coffee_script] = {bare: true}
51
+ Sinatra::AssetSnack.configuration.compilers[:sass] = {syntax: :scss}
55
52
  ```
56
53
 
57
54
  See each compiler's repo for the list of configuration options
58
55
 
59
- [sinatra]: http://sinatrarb.com
60
- [coffee-script]: http://github.com/josh/ruby-coffee-script
61
- [sass]: http://sass-lang.com/
56
+
57
+ [sinatra](http://sinatrarb.com)
58
+
59
+ [coffee-script](http://github.com/josh/ruby-coffee-script)
60
+
61
+ [sass](http://sass-lang.com/)
@@ -1,3 +1,4 @@
1
+ require 'mime/types'
1
2
  require 'sass'
2
3
  require 'coffee-script'
3
4
 
@@ -48,7 +48,8 @@ module Sinatra
48
48
  compiled = compiler.compile_file(path)
49
49
  content_type = compiler.compiled_mime_type
50
50
  else
51
- compiled = File.read(path)
51
+ compiled = File.read path
52
+ content_type = MIME::Types.type_for(path).first.to_s
52
53
  end
53
54
 
54
55
  {
@@ -3,7 +3,7 @@ module Sinatra
3
3
  module Compilers
4
4
  class CoffeeScriptCompiler < AssetCompiler
5
5
  handle_extensions :coffee
6
- mime_type 'text/js'
6
+ mime_type 'application/javascript'
7
7
 
8
8
  def compile(coffee_script, file_path = nil)
9
9
  CoffeeScript.compile(coffee_script, self.class.configuration)
@@ -1,7 +1,7 @@
1
1
  module Sinatra
2
2
  module AssetSnack
3
3
  def self.version
4
- '0.1.4'
4
+ '0.1.5'
5
5
  end
6
6
  end # AssetSnack
7
7
  end # Sinatra
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.add_dependency 'sinatra'
14
14
  s.add_dependency 'coffee-script'
15
15
  s.add_dependency 'sass'
16
+ s.add_dependency 'mime-types'
16
17
 
17
18
  s.add_development_dependency "minitest"
18
19
  s.add_development_dependency "minitest-reporters"
@@ -17,7 +17,12 @@ module Sinatra
17
17
 
18
18
  it 'should return the compilers mime type as a header' do
19
19
  get '/javascript/application.js'
20
- last_response.headers['Content-Type'].must_equal 'text/js'
20
+ last_response.headers['Content-Type'].must_equal 'application/javascript'
21
+ end
22
+
23
+ it 'should return file mime_type for uncompiled assets' do
24
+ get '/javascript/application_js_only.js'
25
+ last_response.headers['Content-Type'].must_equal 'application/javascript'
21
26
  end
22
27
 
23
28
  it 'should allow compiler configuration' do
@@ -36,7 +36,7 @@ module Sinatra
36
36
  end
37
37
 
38
38
  it 'should compile to text/js' do
39
- subject.class.compiled_mime_type.must_equal 'text/js'
39
+ subject.class.compiled_mime_type.must_equal 'application/javascript'
40
40
  end
41
41
 
42
42
  it 'should register itself with the AssetCompiler' do
@@ -0,0 +1 @@
1
+ function() { var x = 'test'; }
data/test/test_helper.rb CHANGED
@@ -12,5 +12,6 @@ class App < Sinatra::Base
12
12
  register Sinatra::AssetSnack
13
13
 
14
14
  asset_map '/javascript/application.js', ['test/fixtures/**/*.coffee']
15
+ asset_map '/javascript/application_js_only.js', ['test/fixtures/**/*.js']
15
16
  asset_map '/stylesheets/application.css', ['test/fixtures/**/*.scss']
16
17
  end
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
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Kitzelman
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mime-types
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: minitest
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -151,6 +165,7 @@ files:
151
165
  - test/compilers/sass_compiler_test.rb
152
166
  - test/configuration_test.rb
153
167
  - test/fixtures/test.coffee
168
+ - test/fixtures/test.js
154
169
  - test/fixtures/test.sass
155
170
  - test/fixtures/test.scss
156
171
  - test/fixtures/test_two.coffee