amikula-sprite 0.1.8 → 0.1.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/sprite/sass_extensions.rb +24 -3
  3. metadata +13 -5
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8
1
+ 0.1.8.1
@@ -35,13 +35,34 @@ module Sprite
35
35
  "url('#{sprite_image(group)}')"
36
36
  end
37
37
 
38
+ ##
39
+ # Return a sprite offset for the given image. When the optional x and y values are passed,
40
+ # numeric values are treated as additional offsets to the sprite image offset. Any string
41
+ # values are treated as replacement offsets.
42
+ #
43
+ # Examples:
44
+ # * sprite_offset("common", "icon", "100%", 5) => offset is "100% x+5" where x is the x offset in the sprite
45
+ # * sprite_offset("common", "icon", "top", "right") => offset is "top right"
38
46
  def sprite_offset(group, image, x=nil, y=nil)
39
- x ||= sprite_x_offset(group, image)
40
- y ||= sprite_y_offset(group, image)
41
- "#{x} #{y}"
47
+ xoff = compute_offset(group, image, :x, x)
48
+ yoff = compute_offset(group, image, :y, y)
49
+ "#{xoff} #{yoff}"
42
50
  end
43
51
 
44
52
  protected
53
+ def compute_offset(group, image, axis, offset)
54
+ if offset
55
+ val = offset.value
56
+ if val.is_a? Fixnum
57
+ (sprite_attr(axis, group, image).to_i + val).to_s + 'px'
58
+ else
59
+ val
60
+ end
61
+ else
62
+ sprite_attr(axis, group, image)
63
+ end
64
+ end
65
+
45
66
  def sprite_attr(attr, group, image)
46
67
  sprite = sprite_data(group, image)
47
68
  if sprite
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amikula-sprite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 8
9
+ - 1
10
+ version: 0.1.8.1
5
11
  platform: ruby
6
12
  authors:
7
13
  - Jacques Crocker
@@ -10,7 +16,7 @@ autorequire:
10
16
  bindir: bin
11
17
  cert_chain: []
12
18
 
13
- date: 2010-03-14 00:00:00 -08:00
19
+ date: 2010-03-15 00:00:00 -07:00
14
20
  default_executable: sprite
15
21
  dependencies: []
16
22
 
@@ -59,18 +65,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
59
65
  requirements:
60
66
  - - ">="
61
67
  - !ruby/object:Gem::Version
68
+ segments:
69
+ - 0
62
70
  version: "0"
63
- version:
64
71
  required_rubygems_version: !ruby/object:Gem::Requirement
65
72
  requirements:
66
73
  - - ">="
67
74
  - !ruby/object:Gem::Version
75
+ segments:
76
+ - 0
68
77
  version: "0"
69
- version:
70
78
  requirements: []
71
79
 
72
80
  rubyforge_project:
73
- rubygems_version: 1.3.5
81
+ rubygems_version: 1.3.6
74
82
  signing_key:
75
83
  specification_version: 3
76
84
  summary: generate your css sprites automagically