css_sprite 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +3 -0
- data/VERSION +1 -1
- data/css_sprite.gemspec +4 -4
- data/lib/css_sprite/sprite.rb +7 -7
- metadata +3 -3
data/README.textile
CHANGED
@@ -47,12 +47,14 @@ forum_icon_vertical.gif: # destination image file
|
|
47
47
|
- sticky_topic.gif
|
48
48
|
orient: vertical # composite gravity, vertical or horizontal
|
49
49
|
span: 5 # span of space between two images
|
50
|
+
prefix: "s-" # css class prefix
|
50
51
|
</code></pre>
|
51
52
|
|
52
53
|
first line defines the destination image filename.
|
53
54
|
<code>sources</code> is a list of source image filenames what want to composite. They are parsed by <code>Dir.glob</code>.
|
54
55
|
<code>orient</code> defines the composite gravity type, horizontal or vertical. Default is 'vertical'.
|
55
56
|
<code>span</code> defines the span between two images. Default is 0.
|
57
|
+
<code>prefix</code> defines a prefix for the generated css classes, to avoid conflicts with your own css classes.
|
56
58
|
|
57
59
|
you can define any number of destination image files.
|
58
60
|
|
@@ -100,6 +102,7 @@ the result css is generated at <code>public/stylesheets/css_sprite.css</code>
|
|
100
102
|
h2. Contributor
|
101
103
|
|
102
104
|
josedelcorral - fix the style of generated css
|
105
|
+
Santino - fix transparent images
|
103
106
|
|
104
107
|
**************************************************************************
|
105
108
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.3
|
data/css_sprite.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{css_sprite}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Richard Huang"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-02-04}
|
13
13
|
s.description = %q{css_sprite is a rails plugin/gem to generate css sprite image automatically.}
|
14
14
|
s.email = %q{flyerhzm@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -36,8 +36,8 @@ Gem::Specification.new do |s|
|
|
36
36
|
s.rubygems_version = %q{1.3.5}
|
37
37
|
s.summary = %q{css_sprite is a rails plugin/gem to generate css sprite image automatically.}
|
38
38
|
s.test_files = [
|
39
|
-
"spec/
|
40
|
-
"spec/
|
39
|
+
"spec/css_sprite/sprite_spec.rb",
|
40
|
+
"spec/spec_helper.rb"
|
41
41
|
]
|
42
42
|
|
43
43
|
if s.respond_to? :specification_version then
|
data/lib/css_sprite/sprite.rb
CHANGED
@@ -13,9 +13,9 @@ class Sprite
|
|
13
13
|
sprite_config = File.open(CONFIG_PATH + 'css_sprite.yml') {|f| YAML::load(f)}
|
14
14
|
sprite_config.each do |dest, configs|
|
15
15
|
output_image(dest, configs)
|
16
|
-
end
|
17
|
-
|
16
|
+
end
|
18
17
|
output_css
|
18
|
+
|
19
19
|
end
|
20
20
|
|
21
21
|
def output_image(dest, configs)
|
@@ -35,7 +35,7 @@ class Sprite
|
|
35
35
|
x = 0
|
36
36
|
y = dest_image.rows + span
|
37
37
|
end
|
38
|
-
results << image_properties(source_image).merge(:x => x, :y => y)
|
38
|
+
results << image_properties(source_image).merge(:x => x, :y => y, :prefix => configs['prefix'])
|
39
39
|
dest_image = composite_images(dest_image, source_image, x, y)
|
40
40
|
end
|
41
41
|
@output[dest] = results
|
@@ -46,7 +46,7 @@ class Sprite
|
|
46
46
|
File.open(PUBLIC_PATH + 'css_sprite.css', 'w') do |f|
|
47
47
|
@output.each do |dest, results|
|
48
48
|
results.each do |result|
|
49
|
-
f.puts ".#{result[:name]} \{ "
|
49
|
+
f.puts ".#{result[:prefix]}#{result[:name]} \{ "
|
50
50
|
f.puts "\tbackground: url('/images/#{dest}') no-repeat #{result[:x]}px #{result[:y]}px;"
|
51
51
|
f.puts "\twidth: #{result[:width]}px;"
|
52
52
|
f.puts "\theight: #{result[:height]}px;"
|
@@ -59,9 +59,9 @@ class Sprite
|
|
59
59
|
def composite_images(dest_image, src_image, x, y)
|
60
60
|
width = [src_image.columns + x, dest_image.columns].max
|
61
61
|
height = [src_image.rows + y, dest_image.rows].max
|
62
|
-
image = Magick::Image.new(width, height)
|
63
|
-
image.composite!(dest_image, 0, 0, Magick::
|
64
|
-
image.composite!(src_image, x, y, Magick::
|
62
|
+
image = Magick::Image.new(width, height) {self.background_color = 'none'}
|
63
|
+
image.composite!(dest_image, 0, 0, Magick::CopyCompositeOp)
|
64
|
+
image.composite!(src_image, x, y, Magick::CopyCompositeOp)
|
65
65
|
image
|
66
66
|
end
|
67
67
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: css_sprite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-02-04 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -64,5 +64,5 @@ signing_key:
|
|
64
64
|
specification_version: 3
|
65
65
|
summary: css_sprite is a rails plugin/gem to generate css sprite image automatically.
|
66
66
|
test_files:
|
67
|
-
- spec/spec_helper.rb
|
68
67
|
- spec/css_sprite/sprite_spec.rb
|
68
|
+
- spec/spec_helper.rb
|