css_sprite 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +13 -31
- data/VERSION +1 -1
- data/css_sprite.gemspec +3 -2
- data/lib/css_sprite/sprite.rb +2 -0
- data/spec/css_sprite/sprite_spec.rb +5 -1
- data/spec/public/images/another_css_sprite/no_image +0 -0
- data/tasks/css_sprite_tasks.rake +7 -9
- metadata +4 -3
data/README.textile
CHANGED
@@ -12,16 +12,15 @@ I have rewritten the plugin. Please check out the gem version >= 1.3.0
|
|
12
12
|
|
13
13
|
h2. Install
|
14
14
|
|
15
|
-
css_sprite is dependent on the
|
15
|
+
css_sprite is dependent on the <code>rmagick</code> gem, please install it first.
|
16
16
|
|
17
17
|
|
18
|
-
install
|
19
|
-
|
18
|
+
install css_sprite as a gem:
|
20
19
|
<pre><code>
|
21
20
|
sudo gem install css_sprite
|
22
21
|
</code></pre>
|
23
22
|
|
24
|
-
or install
|
23
|
+
or install css_sprite as a plugin:
|
25
24
|
<pre><code>
|
26
25
|
script/plugin install git://github.com/flyerhzm/css_sprite.git
|
27
26
|
</code></pre>
|
@@ -30,12 +29,13 @@ script/plugin install git://github.com/flyerhzm/css_sprite.git
|
|
30
29
|
|
31
30
|
h2. Configuration
|
32
31
|
|
33
|
-
There is no need to create
|
32
|
+
There is no need to create any configuration if you do not use sass and you do not want any customization.
|
34
33
|
|
34
|
+
But you can create <code>config/css_sprite.yml</code> to define the customization.
|
35
35
|
|
36
|
-
|
36
|
+
h3. Examples
|
37
37
|
|
38
|
-
For css
|
38
|
+
* For css
|
39
39
|
<pre><code>
|
40
40
|
suffix:
|
41
41
|
button: |
|
@@ -52,7 +52,7 @@ suffix:
|
|
52
52
|
cursor: pointer;
|
53
53
|
</code></pre>
|
54
54
|
|
55
|
-
For sass
|
55
|
+
* For sass
|
56
56
|
<pre><code>
|
57
57
|
engine: sass
|
58
58
|
suffix:
|
@@ -72,14 +72,14 @@ suffix:
|
|
72
72
|
|
73
73
|
<code>engine</code> defines css (default) or sass to generate.
|
74
74
|
<code>suffix</code> defines the customization styles for specified images.
|
75
|
-
The customization above means if your image
|
76
|
-
if your image
|
75
|
+
The customization above means if suffix of your image filename is button (e.g. post_button.png), it contains the additional style with (outline: 0; border: 0; and so on),
|
76
|
+
if suffix of your image filename is icon (e.g. twitter_icon.png), it contains the additional style with (text-indent: -9999px; cursor: pointer)
|
77
77
|
|
78
78
|
**************************************************************************
|
79
79
|
|
80
80
|
h2. Usage
|
81
81
|
|
82
|
-
1. create a <code>css_sprite</code> directory or css_sprite suffixed directory (e.g. widget_css_sprite) under <code>public/images
|
82
|
+
1. create a <code>css_sprite</code> directory or css_sprite suffixed directory (e.g. widget_css_sprite) under <code>public/images/</code>
|
83
83
|
|
84
84
|
2. define <code>config/css_sprite.yml</code> or not
|
85
85
|
|
@@ -89,27 +89,9 @@ h2. Usage
|
|
89
89
|
|
90
90
|
5. then css_sprite image will be automatically generated and css_sprite.css or css_sprite.sass are generated too.
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
h2. Task
|
95
|
-
|
96
|
-
<pre><code>
|
97
|
-
require 'css_sprite'
|
98
|
-
</code></pre>
|
99
|
-
if you use it as a plugin, ignore the step above.
|
100
|
-
|
101
|
-
then just run rake task:
|
102
|
-
<code>rake css_sprite:start</code>, start css_sprite server
|
103
|
-
<code>rake css_sprite:stop</code>, stop css_sprite server
|
104
|
-
<code>rake css_sprite:build</code>, build css_sprite once
|
105
|
-
|
106
|
-
|
107
|
-
**************************************************************************
|
108
|
-
|
109
|
-
h2. Contributor
|
92
|
+
You can stop top the css_sprite server by <code>rake css_sprite:stop</code>
|
110
93
|
|
111
|
-
|
112
|
-
Santino - fix transparent images and make the generated css file more graceful
|
94
|
+
Or you just want to do css sprite manually <code>rake css_sprite:build</code>
|
113
95
|
|
114
96
|
**************************************************************************
|
115
97
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.1
|
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.3.
|
8
|
+
s.version = "1.3.1"
|
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-04-
|
12
|
+
s.date = %q{2010-04-02}
|
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 = [
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
"lib/css_sprite.rb",
|
26
26
|
"lib/css_sprite/sprite.rb",
|
27
27
|
"spec/css_sprite/sprite_spec.rb",
|
28
|
+
"spec/public/images/another_css_sprite/no_image",
|
28
29
|
"spec/public/images/css_sprite/.DS_Store",
|
29
30
|
"spec/public/images/css_sprite/gmail_logo.png",
|
30
31
|
"spec/public/images/css_sprite/hotmail_logo.png",
|
data/lib/css_sprite/sprite.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'find'
|
2
2
|
require 'RMagick'
|
3
3
|
require 'yaml'
|
4
|
+
require 'enumerator'
|
4
5
|
|
5
6
|
class Sprite
|
6
7
|
|
@@ -75,6 +76,7 @@ class Sprite
|
|
75
76
|
results << image_properties(source_image).merge(:x => x, :y => y)
|
76
77
|
dest_image = composite_images(dest_image, source_image, x, y)
|
77
78
|
end
|
79
|
+
dest_image.image_type = Magick::PaletteMatteType
|
78
80
|
dest_image.write(dest_image_path)
|
79
81
|
end
|
80
82
|
@todo[directory] = results
|
@@ -35,7 +35,11 @@ describe Sprite do
|
|
35
35
|
File.join(IMAGE_PATH, 'css_sprite/icons/facebook_icon.png'),
|
36
36
|
File.join(IMAGE_PATH, 'css_sprite/hotmail_logo.png'),
|
37
37
|
File.join(IMAGE_PATH, 'css_sprite/gmail_logo.png')]
|
38
|
-
@sprite.all_images(File.join(IMAGE_PATH, 'css_sprite'))
|
38
|
+
actual_images = @sprite.all_images(File.join(IMAGE_PATH, 'css_sprite'))
|
39
|
+
actual_images.size.should == expected_images.size
|
40
|
+
expected_images.each do |expected_image|
|
41
|
+
actual_images.should be_include(expected_image)
|
42
|
+
end
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
File without changes
|
data/tasks/css_sprite_tasks.rake
CHANGED
@@ -7,17 +7,16 @@ namespace :css_sprite do
|
|
7
7
|
|
8
8
|
desc "start css sprite server"
|
9
9
|
task :start do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
puts "
|
10
|
+
automatic_script = File.join(File.dirname(__FILE__), '..', 'lib', 'automatic.rb')
|
11
|
+
if RUBY_PLATFORM =~ /win|w32/
|
12
|
+
exec "start \"css_sprite\" ruby.exe #{automatic_script}"
|
13
|
+
puts "css_sprite server started sucessfully."
|
14
14
|
else
|
15
15
|
file_path = "#{Rails.root}/tmp/pids/css_sprite.pid"
|
16
16
|
if File.exists?(file_path)
|
17
17
|
puts "css_sprite server is started. I haven't done anything."
|
18
18
|
else
|
19
19
|
pid = fork do
|
20
|
-
automatic_script = File.join(File.dirname(__FILE__), '..', 'lib', 'automatic.rb')
|
21
20
|
exec "ruby #{automatic_script}"
|
22
21
|
end
|
23
22
|
|
@@ -30,10 +29,9 @@ namespace :css_sprite do
|
|
30
29
|
|
31
30
|
desc "stop css sprite server"
|
32
31
|
task :stop do
|
33
|
-
if RUBY_PLATFORM
|
34
|
-
|
35
|
-
|
36
|
-
puts "not support windows yet."
|
32
|
+
if RUBY_PLATFORM =~ /win|w32/
|
33
|
+
exec "taskkill /im ruby.exe /fi \"Windowtitle eq css_sprite\""
|
34
|
+
puts "css_sprite server shutdown sucessfully."
|
37
35
|
else
|
38
36
|
file_path = "#{Rails.root}/tmp/pids/css_sprite.pid"
|
39
37
|
if File.exists?(file_path)
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 1.3.
|
8
|
+
- 1
|
9
|
+
version: 1.3.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Richard Huang
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-02 00:00:00 +08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- lib/css_sprite.rb
|
48
48
|
- lib/css_sprite/sprite.rb
|
49
49
|
- spec/css_sprite/sprite_spec.rb
|
50
|
+
- spec/public/images/another_css_sprite/no_image
|
50
51
|
- spec/public/images/css_sprite/.DS_Store
|
51
52
|
- spec/public/images/css_sprite/gmail_logo.png
|
52
53
|
- spec/public/images/css_sprite/hotmail_logo.png
|