compass-core 1.1.0.alpha.0 → 1.1.0.alpha.1

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: 37fdc459e4eb96443065947423224cb16de88158
4
- data.tar.gz: 09edd8d021b0ea190429518c8faf7bdfaa0f5bd7
3
+ metadata.gz: 39fe1bff283296d62d1ca7a575267824e215d55d
4
+ data.tar.gz: 481f3e327a3cb8c9546af10492e4df3b462246ba
5
5
  SHA512:
6
- metadata.gz: 80091874627dab8a8dbb53e5fdf472972c0892263d64a629a56a700dd24a3b54fc36b9355d066c3e27f0b93b20488ea57c145b8c47a2d0d70cd651709c945017
7
- data.tar.gz: 2c14c31cbb5dc2da31b517347e76dfa33acfc88ed78f8f7125bd0d9eae7531cbb150cb17b6fb885a1ca358866bb2a59720d54ac7b9d814b606e6b9f2f02c0c64
6
+ metadata.gz: 67949447377bda52e913fd3767bbed88ca4e2ca551fd85324f0e9d4dd565b69a7e6fcbec82f071772d44d32f661740b1ed4d4af1a24f778b84e2ca0e745549b3
7
+ data.tar.gz: d52eacba7f2beaa525c26ae4a569ab8c1836a0254421bb54ea8727b703bb3b34cfbfdc4250068a061cc2c03fa3263773517d81f44199c98def55aa638aa07032
@@ -15,6 +15,23 @@ class Compass::Configuration::AbstractAssetCollection
15
15
  end
16
16
  end
17
17
 
18
+ def globs?(type, glob)
19
+ # Treat root relative urls (without a protocol) like normal if they start with the images path.
20
+ asset_http_path = send(:"http_#{type}s_path")
21
+ if glob.start_with?("#{asset_http_path}/")
22
+ glob = glob[(asset_http_path.size + 1)..-1]
23
+ end
24
+ fs_glob = as_filesystem_path(glob)
25
+ absolute_glob = File.join(send(:"#{type}s_path"), fs_glob)
26
+ resolved_files = Dir.glob(absolute_glob)
27
+ if resolved_files.any?
28
+ [glob, resolved_files]
29
+ else
30
+ nil
31
+ end
32
+
33
+ end
34
+
18
35
  def includes_image?(relative_path)
19
36
  # Treat root relative urls (without a protocol) like normal if they start with the images path.
20
37
  if relative_path.start_with?("#{http_images_path}/")
@@ -133,6 +150,7 @@ class Compass::Configuration::AssetCollection < Compass::Configuration::Abstract
133
150
  def root_path
134
151
  return @root_path if defined?(@root_path)
135
152
  @root_path = @options[:root_path] || File.join(configuration.project_path, @options[:root_dir])
153
+ @root_path = File.expand_path(@root_path)
136
154
  end
137
155
 
138
156
  def http_path
@@ -143,14 +161,14 @@ class Compass::Configuration::AssetCollection < Compass::Configuration::Abstract
143
161
  def sass_path
144
162
  return @sass_path if defined?(@sass_path)
145
163
  @sass_path = if options[:sass_dir]
146
- File.join(root_path, options[:sass_dir])
164
+ File.expand_path File.join(root_path, options[:sass_dir])
147
165
  end
148
166
  end
149
167
 
150
168
  def images_path
151
169
  return @images_path if defined?(@images_path)
152
170
  @images_path = if options[:images_dir]
153
- File.join(root_path, options[:images_dir])
171
+ File.expand_path File.join(root_path, options[:images_dir])
154
172
  end
155
173
  end
156
174
 
@@ -169,7 +187,7 @@ class Compass::Configuration::AssetCollection < Compass::Configuration::Abstract
169
187
  def fonts_path
170
188
  return @fonts_path if defined?(@fonts_path)
171
189
  @fonts_path = if options[:fonts_dir]
172
- File.join(root_path, options[:fonts_dir])
190
+ File.expand_path File.join(root_path, options[:fonts_dir])
173
191
  end
174
192
  end
175
193
 
@@ -213,12 +213,30 @@ module Compass
213
213
  end
214
214
 
215
215
  def url_resolver
216
+ return @url_resolver if @url_resolver
216
217
  if top_level == self
217
218
  @url_resolver = Compass::Core::AssetUrlResolver.new(asset_collections.to_a, self)
218
219
  else
219
220
  top_level.url_resolver
220
221
  end
221
222
  end
223
+
224
+ def sprite_resolver
225
+ return @sprite_resolver if @sprite_resolver
226
+ if top_level == self
227
+ sprite_collections = asset_collections.to_a
228
+ sprite_collections += sprite_load_path.to_a.map do |slp|
229
+ AssetCollection.new(
230
+ :root_path => slp,
231
+ :http_path => http_images_path,
232
+ :images_dir => "."
233
+ )
234
+ end
235
+ @sprite_resolver = Compass::Core::AssetUrlResolver.new(sprite_collections, self)
236
+ else
237
+ top_level.url_resolver
238
+ end
239
+ end
222
240
  end
223
241
  end
224
242
  end
@@ -27,14 +27,7 @@ class Compass::Core::AssetUrlResolver
27
27
  # pass through fully specified urls
28
28
  return relative_path if relative_path.start_with?("http://")
29
29
 
30
- # If the image has an target reference, remove it (Common with SVG)
31
- clean_relative_path, target = relative_path.split("#", 2)
32
-
33
- # If the image has a query, remove it
34
- clean_relative_path, query = clean_relative_path.split("?", 2)
35
-
36
- # Get rid of silliness in the url
37
- clean_relative_path = expand_url_path(clean_relative_path)
30
+ clean_relative_path, query, target = clean_path(relative_path)
38
31
 
39
32
  # Find the asset collection that includes this asset
40
33
  asset_collection, clean_relative_path, real_path = find_collection(type, clean_relative_path)
@@ -70,8 +63,50 @@ class Compass::Core::AssetUrlResolver
70
63
  return url
71
64
  end
72
65
 
66
+ # Find the real path to a relative asset path
67
+ def find_asset(type, relative_path)
68
+ clean_relative_path, _, _ = clean_path(relative_path)
69
+ _, _, real_path = find_collection(type, clean_relative_path)
70
+ return real_path
71
+ end
72
+
73
+ def relative_path(type, absolute_path)
74
+ absolute_path = File.expand_path(absolute_path)
75
+ @asset_collections.find do |ac|
76
+ asset_path = File.expand_path(ac.send(:"#{type}s_path"))
77
+ if absolute_path.start_with?(asset_path+File::SEPARATOR)
78
+ return absolute_path[(asset_path+File::SEPARATOR).size..-1]
79
+ end
80
+ end
81
+ nil
82
+ end
83
+
84
+ def glob(type, glob_expression, options = {})
85
+ match_all = options.fetch(:match_all, false)
86
+ resolved_files = []
87
+ @asset_collections.each do |ac|
88
+ _, some_resolved_files = ac.globs?(type, glob_expression)
89
+ resolved_files += some_resolved_files if some_resolved_files
90
+ return resolved_files if resolved_files.any? and !match_all
91
+ end
92
+ resolved_files
93
+ end
94
+
73
95
  protected
74
96
 
97
+ def clean_path(relative_path)
98
+ # If the image has an target reference, remove it (Common with SVG)
99
+ clean_relative_path, target = relative_path.split("#", 2)
100
+
101
+ # If the image has a query, remove it
102
+ clean_relative_path, query = clean_relative_path.split("?", 2)
103
+
104
+ # Get rid of silliness in the url
105
+ clean_relative_path = expand_url_path(clean_relative_path)
106
+
107
+ [clean_relative_path, query, target]
108
+ end
109
+
75
110
  def find_collection(type, relative_path)
76
111
  asset_collection = nil
77
112
  clean_relative_path = nil
@@ -98,7 +133,6 @@ class Compass::Core::AssetUrlResolver
98
133
  cache_buster = {:query => cache_buster} if cache_buster.is_a?(String)
99
134
  [cache_buster[:path] || path, cache_buster[:query]]
100
135
  end
101
-
102
136
 
103
137
  def compute_cache_buster(asset_collection, path, real_path)
104
138
  file = nil
@@ -126,5 +160,4 @@ class Compass::Core::AssetUrlResolver
126
160
  nil
127
161
  end
128
162
  end
129
-
130
163
  end
@@ -1,5 +1,5 @@
1
1
  module Compass
2
2
  module Core
3
- VERSION = "1.1.0.alpha.0"
3
+ VERSION = "1.1.0.alpha.1"
4
4
  end
5
5
  end
@@ -62,12 +62,7 @@ private
62
62
  end
63
63
 
64
64
  def real_path(image_file)
65
- # Compute the real path to the image on the file stystem if the images_dir is set.
66
- if Compass.configuration.images_path
67
- File.join(Compass.configuration.images_path, image_file)
68
- else
69
- File.join(Compass.configuration.project_path, image_file)
70
- end
65
+ Compass.configuration.url_resolver.find_asset(:image, image_file)
71
66
  end
72
67
 
73
68
  class JPEG
@@ -2,7 +2,7 @@ module Compass::Core::SassExtensions::Functions::InlineImage
2
2
 
3
3
  def inline_image(path, mime_type = nil)
4
4
  path = path.value
5
- real_path = File.join(Compass.configuration.images_path, path)
5
+ real_path = Compass.configuration.url_resolver.find_asset(:image, path)
6
6
  inline_image_string(data(real_path), compute_mime_type(path, mime_type))
7
7
  end
8
8
 
@@ -10,7 +10,7 @@ module Compass::Core::SassExtensions::Functions::InlineImage
10
10
  files = []
11
11
  with_each_font_file(*args) do |path, type|
12
12
  path = path.value
13
- real_path = File.join(Compass.configuration.fonts_path, path)
13
+ real_path = Compass.configuration.url_resolver.find_asset(:font, path)
14
14
  data = inline_image_string(data(real_path), compute_mime_type(path))
15
15
  files << list(data, unquoted_string("format('#{type}')"), :space)
16
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compass-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.alpha.0
4
+ version: 1.1.0.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Eppstein
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-08-26 00:00:00.000000000 Z
14
+ date: 2014-09-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: sass