css_sprite 1.4.6 → 1.4.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -10,6 +10,9 @@ I have written posts "css sprite best practices" to introduce the idea that the
10
10
  "english version":http://www.huangzhimin.com/entries/190-css-sprite-best-practices
11
11
  "chinese version":http://www.huangzhimin.com/entries/189-css-sprite-best-practices
12
12
 
13
+ otaviofcs wrote a brazilian version to introduce the css_sprite gem, check it here: "http://blog.riopro.com.br/2010/04/22/acabaram-as-desculpas-para-nao-usar-css-sprite-na-sua-aplicacao/":http://blog.riopro.com.br/2010/04/22/acabaram-as-desculpas-para-nao-usar-css-sprite-na-sua-aplicacao/
14
+ and he also build a demo, "http://github.com/riopro/css_sprite_demo":http://github.com/riopro/css_sprite_demo
15
+
13
16
  **************************************************************************
14
17
 
15
18
  h2. What css_sprite does?
@@ -145,6 +148,18 @@ suffix:
145
148
  The customization above means if your image filename is button suffixed (e.g. post_button.png), the corresponding class .post_button has the additional style with (outline: 0; border: 0; and so on),
146
149
  if your image filename is icon suffixed (e.g. twitter_icon.png), the correspondiing class .twitter_icon has the additional style with (text-indent: -9999px; cursor: pointer)
147
150
 
151
+ h3. Customization directories
152
+
153
+ css_sprite follows the conventions that images are under <code>public/images</code> directory and css files are under <code>public/stylesheets</code>, but you can change them.
154
+
155
+ <pre><code>
156
+ image_path: app/images
157
+ stylesheet_path: app/stylesheets
158
+ </code></pre>
159
+
160
+ By default, image_path is public/images and stylesheet_path is public/stylesheets.
161
+
162
+
148
163
  **************************************************************************
149
164
 
150
165
  Copyright (c) 2009 [Richard Huang (flyerhzm@gmail.com)], released under the MIT license
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.6
1
+ 1.4.7
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.4.6"
8
+ s.version = "1.4.7"
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-19}
12
+ s.date = %q{2010-04-27}
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 = [
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  "lib/automatic.rb",
25
25
  "lib/css_sprite.rb",
26
26
  "lib/css_sprite/sprite.rb",
27
+ "spec/app/stylesheets/css_sprite.css",
27
28
  "spec/css_sprite/sprite_spec.rb",
28
29
  "spec/public/images/another_css_sprite/no_image",
29
30
  "spec/public/images/css_sprite/gmail_logo.png",
@@ -44,7 +45,7 @@ Gem::Specification.new do |s|
44
45
  s.homepage = %q{http://github.com/flyerhzm/css_sprite}
45
46
  s.rdoc_options = ["--charset=UTF-8"]
46
47
  s.require_paths = ["lib"]
47
- s.rubygems_version = %q{1.3.6}
48
+ s.rubygems_version = %q{1.3.5}
48
49
  s.summary = %q{css_sprite is a rails plugin/gem to generate css sprite image automatically.}
49
50
  s.test_files = [
50
51
  "spec/css_sprite/sprite_spec.rb",
@@ -6,14 +6,14 @@ require 'enumerator'
6
6
  class Sprite
7
7
 
8
8
  def initialize(options={})
9
- @image_path = File.expand_path(File.join(Rails.root, 'public/images'))
10
- @stylesheet_path = File.expand_path(File.join(Rails.root, 'public/stylesheets'))
11
-
12
9
  if File.exist?(File.join(Rails.root, 'config/css_sprite.yml'))
13
10
  @config = YAML::load_file(File.join(Rails.root, 'config/css_sprite.yml'))
14
11
  else
15
12
  @config = options
16
13
  end
14
+
15
+ @image_path = File.expand_path(File.join(Rails.root, @config['image_path'] || 'public/images'))
16
+ @stylesheet_path = File.expand_path(File.join(Rails.root, @config['stylesheet_path'] || 'public/stylesheets'))
17
17
  end
18
18
 
19
19
  # execute the css sprite operation
@@ -0,0 +1,14 @@
1
+ .logos:hover .gmail_logo, .logos .gmail_logo.active, .logos .gmail_logo, .icons .twitter_icon:hover, .icons .twitter_icon,
2
+ .icons .facebook_icon:hover, .icons .facebook_icon, .hotmail_logo, .gmail_logo.active, .gmail_logo {
3
+ background: url('/images/css_sprite.png?1272247421') no-repeat;
4
+ }
5
+ .logos:hover .gmail_logo { background-position: 0px 0px; }
6
+ .logos .gmail_logo.active { background-position: 0px -41px; width: 52px; height: 18px; }
7
+ .logos .gmail_logo { background-position: 0px -64px; width: 103px; height: 36px; }
8
+ .icons .twitter_icon:hover { background-position: 0px -105px; }
9
+ .icons .twitter_icon { background-position: 0px -124px; width: 14px; height: 14px; }
10
+ .icons .facebook_icon:hover { background-position: 0px -143px; width: 21px; height: 21px; }
11
+ .icons .facebook_icon { background-position: 0px -169px; width: 14px; height: 14px; }
12
+ .hotmail_logo { background-position: 0px -188px; width: 103px; height: 36px; }
13
+ .gmail_logo.active { background-position: 0px -229px; }
14
+ .gmail_logo { background-position: 0px -270px; width: 103px; height: 36px; }
@@ -30,6 +30,11 @@ describe Sprite do
30
30
  Sprite.any_instance.expects(:system).with("optipng -o 1 #{IMAGE_PATH}/css_sprite.png").returns(true)
31
31
  Sprite.new('optimization' => "optipng -o 1").build
32
32
  end
33
+
34
+ it "should output css to customized stylesheet_path" do
35
+ Sprite.any_instance.expects(:system).with("optipng -quiet #{IMAGE_PATH}/css_sprite.png").returns(true)
36
+ Sprite.new('stylesheet_path' => 'app/stylesheets').build
37
+ end
33
38
  end
34
39
 
35
40
  describe "css_sprite_directories" do
@@ -19,7 +19,7 @@ namespace :css_sprite do
19
19
  else
20
20
  file_path = "#{Rails.root}/tmp/pids/css_sprite.pid"
21
21
  if File.exists?(file_path)
22
- puts "css_sprite server is started. I haven't done anything."
22
+ puts "css_sprite server is started. I haven't done anything. Please use rake css_sprite:restart instead."
23
23
  else
24
24
  pid = fork do
25
25
  exec "ruby #{automatic_script}"
@@ -42,8 +42,11 @@ namespace :css_sprite do
42
42
  if File.exists?(file_path)
43
43
  fork do
44
44
  File.open(file_path, "r") do |f|
45
- pid = f.readline
46
- Process.kill('TERM', pid.to_i)
45
+ pid = f.readline
46
+ begin
47
+ Process.kill('TERM', pid.to_i)
48
+ rescue Errno::ESRCH
49
+ end
47
50
  end
48
51
  end
49
52
 
metadata CHANGED
@@ -1,12 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: css_sprite
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 4
8
- - 6
9
- version: 1.4.6
4
+ version: 1.4.7
10
5
  platform: ruby
11
6
  authors:
12
7
  - Richard Huang
@@ -14,21 +9,19 @@ autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
11
 
17
- date: 2010-04-19 00:00:00 +08:00
12
+ date: 2010-04-27 00:00:00 -06:00
18
13
  default_executable:
19
14
  dependencies:
20
15
  - !ruby/object:Gem::Dependency
21
16
  name: rmagick
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
24
20
  requirements:
25
21
  - - ">="
26
22
  - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
23
  version: "0"
30
- type: :runtime
31
- version_requirements: *id001
24
+ version:
32
25
  description: css_sprite is a rails plugin/gem to generate css sprite image automatically.
33
26
  email: flyerhzm@gmail.com
34
27
  executables: []
@@ -46,6 +39,7 @@ files:
46
39
  - lib/automatic.rb
47
40
  - lib/css_sprite.rb
48
41
  - lib/css_sprite/sprite.rb
42
+ - spec/app/stylesheets/css_sprite.css
49
43
  - spec/css_sprite/sprite_spec.rb
50
44
  - spec/public/images/another_css_sprite/no_image
51
45
  - spec/public/images/css_sprite/gmail_logo.png
@@ -75,20 +69,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
69
  requirements:
76
70
  - - ">="
77
71
  - !ruby/object:Gem::Version
78
- segments:
79
- - 0
80
72
  version: "0"
73
+ version:
81
74
  required_rubygems_version: !ruby/object:Gem::Requirement
82
75
  requirements:
83
76
  - - ">="
84
77
  - !ruby/object:Gem::Version
85
- segments:
86
- - 0
87
78
  version: "0"
79
+ version:
88
80
  requirements: []
89
81
 
90
82
  rubyforge_project:
91
- rubygems_version: 1.3.6
83
+ rubygems_version: 1.3.5
92
84
  signing_key:
93
85
  specification_version: 3
94
86
  summary: css_sprite is a rails plugin/gem to generate css sprite image automatically.