sinatra-assetpack 0.2.7 → 0.2.8

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: 188c63c21768ada8ce6b04d78d71cc57a0910379
4
- data.tar.gz: 54d64ece5af1de3334eafa6cc35caae866b7ce3c
3
+ metadata.gz: d663bf9909c651baf667925dc70d3e434e3df7d5
4
+ data.tar.gz: 44e7f4b6b69d7ef2de0405d38b64a0d75fc95416
5
5
  SHA512:
6
- metadata.gz: eb6d31246a8b947ca3fcc032b3d98638ca913c1cfffc9cbb567e7649286999bc0d112137382bd43023b32c4e926f67a301ae8ab7335f03fa518d4c2903be9768
7
- data.tar.gz: 033400d94121789374c1a5b770a22362d6a50fe4706056a54535d033c347bf560a854411cc489c4490c9c21ae59aaa9d2f01b110d14f9ee860eb6234c63a8dee
6
+ metadata.gz: 661a0a911bc4f8deb66185be8ea943d025efb80f26b85a337873830989d4113a7b6e66bbc44b19be9ac1734dae684d9841022f82c2aabbff940449785906ef4f
7
+ data.tar.gz: 9c4cca3b82255e195c06044604afda72582e5ba09d85081b3ec8230460b9141ef39a4e49c87f760b114cd816e5d795c35b10d2e95cec862e7ca7df544be1e3ae
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- ���R{54x����x �.s�Y^ �� b�QA�#��G��� ��e���a[PK2"Kw���6M��.�Qq!pl@�e����I'f��1�X�
2
- �ʬ6 �ߛ#=���F���R@2��I�\Ի�2�$����sX�C�'�v�7�����0�Z�{�0+��pz�k��J�5���v�9�/�z7wK���*=�pJ��꓏�_��9�nWA�tD��؟�ϖ���3�fsc�Z�Jȕ��Y
1
+ $����$ܯ���P ��~��W!7�բ�W�@�`�Z7��<����j3�#7/�O2�`�8E_ar$q��} ʲ�2,A¹����x]����9A��Jݹ���Y�Λc��+f�ӂ1׎��M�����)<_��D�^ȏ��\QD8�=��X��̰�%v��=����JAak1���:����gv����,G�^Rƙnlq���{C�r��<<����]Ll�$Z��LJ�;��ֹ���sdO�� sF@�
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.2.8 - June 25, 2013
2
+
3
+ ### Fixed
4
+ * CSS preprocessing should not rewriting external url or not served assets. (#116)
5
+
1
6
  ## v0.2.7 - June 22, 2013
2
7
 
3
8
  ### Fixed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sinatra-assetpack (0.2.7)
4
+ sinatra-assetpack (0.2.8)
5
5
  jsmin
6
6
  rack-test
7
7
  sinatra
@@ -18,7 +18,7 @@ GEM
18
18
  coffee-script (2.2.0)
19
19
  coffee-script-source
20
20
  execjs
21
- coffee-script-source (1.6.1)
21
+ coffee-script-source (1.6.2)
22
22
  columnize (0.3.6)
23
23
  commonjs (0.2.6)
24
24
  contest (0.1.3)
@@ -31,33 +31,33 @@ GEM
31
31
  execjs (1.4.0)
32
32
  multi_json (~> 1.0)
33
33
  gem-release (0.6.0)
34
- haml (4.0.0)
34
+ haml (4.0.3)
35
35
  tilt
36
36
  jsmin (1.0.1)
37
- less (2.3.1)
37
+ less (2.3.2)
38
38
  commonjs (~> 0.2.6)
39
39
  metaclass (0.0.1)
40
- mocha (0.13.3)
40
+ mocha (0.14.0)
41
41
  metaclass (~> 0.0.1)
42
- multi_json (1.7.0)
42
+ multi_json (1.7.7)
43
43
  open4 (1.3.0)
44
44
  rack (1.5.2)
45
45
  rack-protection (1.5.0)
46
46
  rack
47
47
  rack-test (0.6.2)
48
48
  rack (>= 1.0)
49
- rake (10.0.3)
50
- sass (3.2.7)
49
+ rake (10.1.0)
50
+ sass (3.2.9)
51
51
  sinatra (1.4.3)
52
52
  rack (~> 1.4)
53
53
  rack-protection (~> 1.4)
54
54
  tilt (~> 1.3, >= 1.3.4)
55
- stylus (0.7.1)
55
+ stylus (0.7.2)
56
56
  execjs
57
57
  stylus-source
58
58
  stylus-source (0.31.0)
59
- tilt (1.3.5)
60
- uglifier (1.3.0)
59
+ tilt (1.4.1)
60
+ uglifier (2.1.1)
61
61
  execjs (>= 0.3.0)
62
62
  multi_json (~> 1.0, >= 1.0.2)
63
63
  yui-compressor (0.9.6)
@@ -3,32 +3,34 @@ require 'uri'
3
3
  module Sinatra
4
4
  module AssetPack
5
5
  module Css
6
- def self.preproc(str, assets)
7
- str.gsub(/url\((["']?)(?!["']?data:)(.*?)(["']?)\)/) { |url|
8
- css_url = URI.parse($2)
9
- file = css_url.path
10
- options = css_url.query
11
- local = assets.local_file_for file
12
-
13
- url = if local
14
- if options.to_s.include?('embed')
15
- to_data_uri(local)
16
- else
17
- url = HtmlHelpers.get_file_uri(file, assets)
18
- serve = URI(url)
19
- serve.query = css_url.query
20
- serve.fragment = css_url.fragment
21
- serve.to_s
22
- end
23
- else
24
- $2
25
- end
26
-
27
- "url(#{$1}#{url}#{$3})"
28
- }
6
+ def self.preproc(source, assets)
7
+ source.gsub(/url\((["']?)(.*?)(["']?)\)/) do |match|
8
+ uri = URI.parse($2)
9
+
10
+ # Not a valid complete url
11
+ next match if uri.path.nil?
12
+
13
+ # Not found in served assets
14
+ local = assets.local_file_for(uri.path)
15
+ next match if local.nil?
16
+
17
+ asset_url = build_url(assets, local, uri)
18
+ "url(#{$1}#{asset_url}#{$3})"
19
+ end
20
+ end
21
+
22
+ def self.build_url(assets, local, uri)
23
+ if uri.query && uri.query.include?('embed')
24
+ build_data_uri(local)
25
+ else
26
+ serve = URI(HtmlHelpers.get_file_uri(uri.path, assets))
27
+ serve.query = uri.query
28
+ serve.fragment = uri.fragment
29
+ serve.to_s
30
+ end
29
31
  end
30
32
 
31
- def self.to_data_uri(file)
33
+ def self.build_data_uri(file)
32
34
  require 'base64'
33
35
 
34
36
  data = File.read(file)
@@ -218,7 +218,9 @@ module Sinatra
218
218
  return if !from
219
219
 
220
220
  path = File.join(expand_from(from), request.sub(serve_path, ''))
221
- path if File.exist?(path)
221
+ return if !File.file?(path)
222
+
223
+ path
222
224
  end
223
225
 
224
226
  # Returns the local file for a given URI path. (for dynamic files)
@@ -1,6 +1,6 @@
1
1
  module Sinatra
2
2
  module AssetPack
3
- VERSION = "0.2.7"
3
+ VERSION = "0.2.8"
4
4
 
5
5
  # @deprecated Please use AssetPack::VERSION instead
6
6
  def self.version
data/test/app/app.rb CHANGED
@@ -3,6 +3,8 @@ $:.unshift File.expand_path('../../../lib', __FILE__)
3
3
  require 'sinatra/base'
4
4
  require 'sinatra/assetpack'
5
5
  require 'coffee-script'
6
+ require 'sass'
7
+ require 'haml'
6
8
 
7
9
  class Main < Sinatra::Base
8
10
  set :root, File.dirname(__FILE__)
@@ -1,3 +1,4 @@
1
1
  div { color: red; }
2
2
  body { background: url(/images/background.jpg); }
3
3
  #nonexistent { background: url(/images/404.png); }
4
+ @import url('//fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700');
@@ -54,8 +54,7 @@ class AssetHostTest < UnitTest
54
54
  app.stubs(:development?).returns(false)
55
55
  get '/css/style.css'
56
56
  assert body =~ /background: url\(\/\/cdn-[0|1].example.org\/images\/background.[a-f0-9]{32}.jpg\)/
57
-
58
- # does not alter non-existing files (design or flaw???)
57
+ # Does not alter not served assets
59
58
  assert body.include?('background: url(/images/404.png)')
60
59
  end
61
60
 
data/test/preproc_test.rb CHANGED
@@ -15,12 +15,18 @@ class PreprocTest < UnitTest
15
15
  assert body =~ %r{background.[a-f0-9]{32}.jpg}
16
16
  end
17
17
 
18
- test "no cache-busting number for non-existent images" do
18
+ test "no cache-busting hash for non-existent images" do
19
19
  app.stubs(:development?).returns(false)
20
20
  get '/css/style.css'
21
21
  assert body.include?('background: url(/images/404.png)')
22
22
  end
23
23
 
24
+ test "no cache-busting hash for non-existent images" do
25
+ app.stubs(:development?).returns(false)
26
+ get '/css/style.css'
27
+ assert body.include?("@import url('//fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700');")
28
+ end
29
+
24
30
  test "preproc on minify" do
25
31
  app.stubs(:clear_cache).returns(true)
26
32
  app.stubs(:development?).returns(false)
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.7
4
+ version: 0.2.8
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-22 00:00:00.000000000 Z
33
+ date: 2013-06-26 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: jsmin
metadata.gz.sig CHANGED
Binary file