sinatra-assetpack 0.2.8 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d663bf9909c651baf667925dc70d3e434e3df7d5
4
- data.tar.gz: 44e7f4b6b69d7ef2de0405d38b64a0d75fc95416
3
+ metadata.gz: 4e728d4e113b8fc40c01e5116725739d612086de
4
+ data.tar.gz: 4283e6dd55cc00cf441ce2aeb373003d252d1b2e
5
5
  SHA512:
6
- metadata.gz: 661a0a911bc4f8deb66185be8ea943d025efb80f26b85a337873830989d4113a7b6e66bbc44b19be9ac1734dae684d9841022f82c2aabbff940449785906ef4f
7
- data.tar.gz: 9c4cca3b82255e195c06044604afda72582e5ba09d85081b3ec8230460b9141ef39a4e49c87f760b114cd816e5d795c35b10d2e95cec862e7ca7df544be1e3ae
6
+ metadata.gz: f220be3e7b56b19ee7d9ba7d309394dc1f2312fcfa43bb51cdfee6ef67ea739b2214e778d195c8e6bf625f74b75a4434e1fc2accadff1eafc392fcd44d4c9277
7
+ data.tar.gz: 891c2420167550c074d6773142f543694645e49f9e89b8a34ebf55f6236bf3c270cb222609a3efc1b7089884f3ed89a54b676a9a06fa21c83026744862cbf745
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,15 @@
1
+ ## v0.3.0 - July 30, 2013
2
+
3
+ ### Changes
4
+ * Remove automatic image tag width/height (#121)
5
+
6
+ ### Fixed
7
+ * Tilt issue #206 workaround (#125)
8
+
9
+ ### Improvements
10
+ * Improve DSL error reporting (#124)
11
+ * Add filename option to templates render. (#126)
12
+
1
13
  ## v0.2.8 - June 25, 2013
2
14
 
3
15
  ### Fixed
data/README.md CHANGED
@@ -34,6 +34,8 @@ class App < Sinatra::Base
34
34
 
35
35
  # The second parameter defines where the compressed version will be served.
36
36
  # (Note: that parameter is optional, AssetPack will figure it out.)
37
+ # The final parameter is an array of glob patterns defining the contents
38
+ # of the package (as matched on the public URIs, not the filesystem)
37
39
  js :app, '/js/app.js', [
38
40
  '/js/vendor/**/*.js',
39
41
  '/js/lib/**/*.js'
@@ -257,6 +259,9 @@ URL.
257
259
  APP_FILE = 'app.rb'
258
260
  APP_CLASS = 'App'
259
261
 
262
+ # For Padrino users, do not forget to add your application namspace
263
+ # APP_CLASS = '<Project>::App'
264
+
260
265
  require 'sinatra/assetpack/rake'
261
266
  ```
262
267
 
@@ -17,6 +17,9 @@ module Sinatra
17
17
  @formats ||= begin
18
18
  hash = Hash.new
19
19
  Tilt.mappings.each do |format, (engine, _)|
20
+ # @todo Remove when fix is merged in tilt
21
+ # https://github.com/rtomayko/tilt/pull/206
22
+ next if engine.nil?
20
23
  case engine.default_mime_type
21
24
  when 'text/css' then hash[format] = 'css'
22
25
  when 'application/javascript' then hash[format] = 'js'
@@ -87,7 +87,7 @@ module Sinatra
87
87
 
88
88
  @template_cache.fetch(fn) {
89
89
  settings.assets.fetch_dynamic_asset(fn) {
90
- out = render format.to_sym, File.read(fn)
90
+ out = render format.to_sym, File.read(fn), :filename => fn
91
91
  out = asset_filter_css(out) if fmt == 'css'
92
92
  out
93
93
  }
@@ -10,19 +10,8 @@ module Sinatra
10
10
  end
11
11
 
12
12
  def img(src, options={})
13
- attrs = { :src => src }.merge(options)
14
-
15
- local = settings.assets.local_file_for src
16
- if local
17
- i = Image[local]
18
-
19
- attrs[:src] = HtmlHelpers.get_file_uri(src, settings.assets)
20
-
21
- if i.dimensions?
22
- attrs[:width] ||= i.width
23
- attrs[:height] ||= i.height
24
- end
25
- end
13
+ attrs = { :src => HtmlHelpers.get_file_uri(src, settings.assets) }
14
+ .merge!(options)
26
15
 
27
16
  "<img#{HtmlHelpers.kv attrs} />"
28
17
  end
@@ -66,9 +66,9 @@ module Sinatra
66
66
  reset!
67
67
 
68
68
  # Defaults!
69
- serve '/css', :from => 'app/css'
70
- serve '/js', :from => 'app/js'
71
- serve '/images', :from => 'app/images'
69
+ serve '/css', :from => 'app/css' rescue Errno::ENOTDIR
70
+ serve '/js', :from => 'app/js' rescue Errno::ENOTDIR
71
+ serve '/images', :from => 'app/images' rescue Errno::ENOTDIR
72
72
 
73
73
  ignore '.*'
74
74
  ignore '_*'
@@ -80,13 +80,17 @@ module Sinatra
80
80
  # DSL methods
81
81
 
82
82
  def serve(path, options={})
83
- raise Error unless options[:from]
83
+ unless from = options[:from]
84
+ raise ArgumentError, "Parameter :from is required"
85
+ end
86
+
87
+ expanded = expand_from(from)
84
88
 
85
- full_path = options[:from]
86
- full_path = File.join(app.root, full_path) unless File.directory?(full_path)
87
- return unless File.directory?(full_path)
89
+ unless File.directory? expanded
90
+ raise Errno::ENOTDIR, expanded
91
+ end
88
92
 
89
- @served[path] = options[:from]
93
+ @served[path] = from
90
94
  @reload_files_cache = true
91
95
  end
92
96
 
@@ -1,6 +1,6 @@
1
1
  module Sinatra
2
2
  module AssetPack
3
- VERSION = "0.2.8"
3
+ VERSION = "0.3.0"
4
4
 
5
5
  # @deprecated Please use AssetPack::VERSION instead
6
6
  def self.version
@@ -17,8 +17,6 @@ class HelpersTest < UnitTest
17
17
  get '/helper/email'
18
18
 
19
19
  assert body =~ %r{src='/images/email.png'}
20
- assert body =~ %r{width='16'}
21
- assert body =~ %r{height='16'}
22
20
  end
23
21
 
24
22
  test "img existing (production)" do
@@ -26,8 +24,6 @@ class HelpersTest < UnitTest
26
24
  get '/helper/email'
27
25
 
28
26
  assert body =~ %r{src='/images/email.[a-f0-9]{32}.png'}
29
- assert body =~ %r{width='16'}
30
- assert body =~ %r{height='16'}
31
27
  end
32
28
 
33
29
  test "css" do
@@ -16,4 +16,19 @@ class OptionsTest < UnitTest
16
16
  assert App.assets.js_compression == :closure
17
17
  assert App.assets.packages['application.css'].path == "/assets/application.css"
18
18
  end
19
+
20
+ test "serve requires :from parameter" do
21
+ err = assert_raise ArgumentError do
22
+ App.assets.serve "/foo"
23
+ end
24
+ assert_equal "Parameter :from is required", err.message
25
+ end
26
+
27
+ test "serve requires :from to be directory" do
28
+ e = assert_raise Errno::ENOTDIR do
29
+ App.assets.serve "/foo", :from => "/does/not/exist"
30
+ end
31
+ end
32
+
33
+
19
34
  end
@@ -2,6 +2,12 @@ require File.expand_path('../test_helper', __FILE__)
2
2
 
3
3
  class OptionsTest < UnitTest
4
4
  test "tilt mappings" do
5
+ # @todo Remove when fix is merged in tilt
6
+ # https://github.com/rtomayko/tilt/pull/206
7
+ # trigger Tilt issue 206 then reset formats
8
+ assert_nil Tilt["hello.world"]
9
+ Sinatra::AssetPack.instance_variable_set :@formats, nil
10
+ # extract formats
5
11
  @formats = Sinatra::AssetPack.tilt_formats
6
12
  assert @formats['sass'] == 'css'
7
13
  assert @formats['scss'] == 'css'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-assetpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rico Sta. Cruz
@@ -30,7 +30,7 @@ cert_chain:
30
30
  kzgF4O2OL+8O23we4E1LvfRn5gV77Dij6s9V4HHzMBuLwnNb8T+6lOnUWbtiIddD
31
31
  e8c8i7PlrzhVJ/8sXUJsCkyE8d2MyRyjlxM=
32
32
  -----END CERTIFICATE-----
33
- date: 2013-06-26 00:00:00.000000000 Z
33
+ date: 2013-07-30 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: jsmin
metadata.gz.sig CHANGED
Binary file