active_assets 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "active_assets"
4
- s.version = '0.2.7'
4
+ s.version = '0.2.8'
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ["Sam Woodard"]
7
7
  s.email = ["sam@wildfireapp.com"]
@@ -24,7 +24,8 @@ module ActiveAssets
24
24
 
25
25
  def asset(path, options = {})
26
26
  options = HashWithIndifferentAccess.new(options)
27
- options.assert_valid_keys(*Asset.members)
27
+ # map is for 1.9.2; HashWithIndifferentAccess bug?
28
+ options.assert_valid_keys(*Asset.members.map(&:to_s))
28
29
 
29
30
  inferred_type, extension = inferred_type(path)
30
31
 
@@ -104,6 +104,10 @@ module ActiveAssets
104
104
  path.split('?').first
105
105
  end
106
106
 
107
+ def sprite_url(sprite, sprite_path)
108
+ sprite.url.present? ? sprite.url : ::Rack::Mount::Utils.normalize_path(sprite_path)
109
+ end
110
+
107
111
  end
108
112
  end
109
113
  end
@@ -15,7 +15,7 @@ module ActiveAssets
15
15
  sprite_piece_path = image_computed_full_path(sp.path)
16
16
  sp_image = ChunkyPNG::Image.from_file(sprite_piece_path)
17
17
  sp.details = SpritePiece::Details.new(
18
- sprite.url.present? ? sprite.url : sprite_path,
18
+ sprite_url(sprite, sprite_path),
19
19
  orientation == Sprite::Orientation::VERTICAL ? 0 : width,
20
20
  orientation == Sprite::Orientation::VERTICAL ? height : 0,
21
21
  sp_image.width,
@@ -3,12 +3,6 @@ require 'mini_magick'
3
3
  module ActiveAssets
4
4
  module ActiveSprites
5
5
  class MiniMagickRunner < AbstractRunner
6
- class ImageTempfile < Tempfile
7
- def make_tmpname(ext, n)
8
- 'mini_magick%d-%d%s' % [$$, n, ext ? ".#{ext}" : '']
9
- end
10
- end
11
-
12
6
  private
13
7
  def set_sprite_details_and_return_image_list(sprite, sprite_path, sprite_pieces, orientation)
14
8
  offset = 0
@@ -17,7 +11,7 @@ module ActiveAssets
17
11
  sp_path = image_computed_full_path(sp.path)
18
12
  image = MiniMagick::Image.open(sp_path)
19
13
  sp.details = SpritePiece::Details.new(
20
- sprite.url.present? ? sprite.url : sprite_path,
14
+ sprite_url(sprite, sprite_path),
21
15
  orientation == Sprite::Orientation::VERTICAL ? 0 : offset,
22
16
  orientation == Sprite::Orientation::VERTICAL ? offset : 0,
23
17
  image["width"],
@@ -32,7 +26,7 @@ module ActiveAssets
32
26
 
33
27
  def create_sprite(sprite, sprite_path, sprite_pieces, image_list, width, height, orientation, verbose)
34
28
  begin
35
- tempfile = ImageTempfile.new(File.extname(sprite_path)[1..-1])
29
+ tempfile = Tempfile.new(File.extname(sprite_path)[1..-1])
36
30
  tempfile.binmode
37
31
  ensure
38
32
  tempfile.close
@@ -18,7 +18,7 @@ module ActiveAssets
18
18
 
19
19
  image_list.each_with_index do |image, i|
20
20
  sprite_pieces[i].details = SpritePiece::Details.new(
21
- sprite.url.present? ? sprite.url : sprite_path,
21
+ sprite_url(sprite, sprite_path),
22
22
  orientation == Sprite::Orientation::VERTICAL ? 0 : offset,
23
23
  orientation == Sprite::Orientation::VERTICAL ? offset : 0,
24
24
  image.columns,
@@ -36,12 +36,13 @@ module ActiveAssets
36
36
 
37
37
  def to_css
38
38
  return '' if details.nil?
39
+
39
40
  <<-CSS
40
41
  #{css_selector}
41
42
  {
42
43
  width:#{width || "#{details.width}px"};
43
44
  height:#{height || "#{details.height}px"};
44
- background:url('#{::Rack::Mount::Utils.normalize_path(details.sprite_path)}') no-repeat #{x || "#{-details.x}px"} #{y || "#{-details.y}px"};
45
+ background:url('#{details.sprite_path}') no-repeat #{x || "#{-details.x}px"} #{y || "#{-details.y}px"};
45
46
  display:block;
46
47
  }
47
48
  CSS
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_assets
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 7
10
- version: 0.2.7
9
+ - 8
10
+ version: 0.2.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sam Woodard
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-03 00:00:00 -08:00
18
+ date: 2011-02-12 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency