auto_sprite 0.0.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,84 @@
1
+
2
+ =AutoSprite
3
+
4
+
5
+ An easy, automated CSS image sprite creator.
6
+
7
+
8
+ =Why do I care?
9
+
10
+ Suppose you have 10 images on your homepage. Rather than downloading 10 seperate images one at a time, 1 image is downloaded and we use CSS to show different parts of that image when we need to. This speeds up your page load time. It can be hard to manage this manually since you need to keep appending images to a sprite file and updating your css file with the correct offsets, etc. Auto Sprite lets you get back to more important things.
11
+
12
+
13
+ =Install
14
+
15
+ 1. Install auto_sprite and RMagick.
16
+
17
+ gem install RMagick auto_sprite
18
+
19
+ 2. Edit your environement.rb add config.gem "auto_sprite"
20
+
21
+ =Usage
22
+ 1. Include the stylesheet in your layout:
23
+
24
+ <%= stylesheet_link_tag "auto_sprite" %>
25
+
26
+ 2. Create a directory called sprites in your images directory (e.g. RAILS_ROOT/public/images/sprites)
27
+
28
+ 3. Put the images you want to link to in your public/images/sprites directory.
29
+
30
+ 4. Use your images like you normally would:
31
+
32
+ <%= image_tag 'sprites/logo.png' %>
33
+ <%= image_tag 'sprites/icon1.jpg' %>
34
+
35
+ 5. Reload after adding any new images to sprites/ and enjoy your now faster rendering website.
36
+
37
+
38
+ You'll notice that should auto_sprite be removed, your application will still work!
39
+
40
+
41
+ =Notes
42
+ - Animated images are not supported.
43
+ - Any image format supported by RMagick should work.
44
+ - Images of mixed sizes are not a problem.
45
+
46
+ =Details
47
+
48
+ Whenever rails reloads, it will automatically generate two files:
49
+
50
+ RAILS_ROOT/public/stylesheets/auto_sprite.css
51
+ RAILS_ROOT/public/images/auto_sprite.png
52
+
53
+
54
+ The image tag will automatically generate a div tag for any images located in the sprite directory.
55
+
56
+ <div class="_as_logo_png"></div> instead of <img src="/images/sprites/logo.png" />
57
+
58
+
59
+ Here is an exmplmple of the stylehseet that would be generated if you had two files face3.png and face4.png
60
+
61
+ ._as_face3_png {
62
+ background-position:0 0px;
63
+ height:16px;
64
+ width:16px;
65
+ }
66
+
67
+ ._as_face4_png{
68
+ background-position:0 -16px;
69
+ height:16px;
70
+ width:16px;
71
+ }
72
+
73
+ ._as_face3_png,
74
+ ._as_face3_png {
75
+ display:inline-block;
76
+ background-image:url('/images/auto_sprite.png');
77
+ background-repeat:no-repeat;
78
+ }
79
+
80
+ =Contact
81
+ sblackstone@gmail.com
82
+ http://fargle.org/auto_sprite
83
+
84
+ Copyright (c) 2010 Stephen Blackstone, released under the MIT license
data/auto_sprite.gemspec CHANGED
@@ -1,16 +1,16 @@
1
1
  spec = Gem::Specification.new do |s|
2
+
2
3
  require 'fileutils'
3
4
  s.name = "auto_sprite"
4
- s.version = "0.0.3"
5
+ s.version = "1.0.0"
5
6
  s.author = "Stephen Blackstone"
6
7
  s.email = "sblackstone@gmail.com"
7
- s.homepage = "http://gemcutter.org/gems/auto_sprite"
8
+ s.homepage = "http://fargle.org/auto_sprite"
8
9
  s.platform = Gem::Platform::RUBY
9
10
  s.summary = "A fully-Automagic Sprite Builder"
10
11
  s.description = "CSS Sprites can get you down, don't let them. This gem automatically creates the CSS, Sprite and HTML tags so you don't have to"
11
- s.files = ["./README", "./auto_sprite.gemspec", "./MIT-LICENSE", "./rails", "./rails/init.rb", "./lib", "./lib/auto_sprite.rb"]
12
+ s.files = ["./README.rdoc", "./auto_sprite.gemspec", "./MIT-LICENSE", "./rails", "./rails/init.rb", "./lib", "./lib/auto_sprite.rb"]
12
13
  s.require_path = "lib"
13
14
  s.has_rdoc = false
14
- s.extra_rdoc_files = ["README"]
15
15
  end
16
16
 
data/lib/auto_sprite.rb CHANGED
@@ -2,9 +2,9 @@ require 'RMagick'
2
2
  require 'fileutils'
3
3
 
4
4
  module AutoSprite
5
- SPRITE_ASSETS_PATH = File.join(RAILS_ROOT, 'public', 'images', 'sprites')
6
- CSS_FILE_PATH = File.join(RAILS_ROOT, 'public', 'stylesheets','auto_sprite.css')
7
- SPRITE_IMG_PATH = File.join(RAILS_ROOT, 'public', 'images', 'auto_sprite.png')
5
+ SPRITE_ASSETS_PATH = File.join(RAILS_ROOT, 'public', 'images', 'sprites')
6
+ CSS_FILE_PATH = File.join(RAILS_ROOT, 'public', 'stylesheets', 'auto_sprite.css')
7
+ SPRITE_IMG_PATH = File.join(RAILS_ROOT, 'public', 'images', 'auto_sprite.png')
8
8
  SPRITE_IMG_URL = '/images/auto_sprite.png'
9
9
 
10
10
  class << self
@@ -40,7 +40,7 @@ module AutoSprite
40
40
  File.open(CSS_FILE_PATH, "w") do |f|
41
41
  image_list.each do |img|
42
42
  css_class = generate_css_name(img.filename)
43
- f << ".#{css_class}{background-position:0 #{pos* -1}px;height:#{img.rows}px;width:#{img.columns}px;}"
43
+ f << ".#{css_class}{background-position:0 #{pos * -1}px;height:#{img.rows}px;width:#{img.columns}px;}"
44
44
  pos = pos + img.rows;
45
45
  end
46
46
  f << all_class_names.join(",")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_sprite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Blackstone
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-09 00:00:00 -05:00
12
+ date: 2010-01-10 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -19,17 +19,16 @@ executables: []
19
19
 
20
20
  extensions: []
21
21
 
22
- extra_rdoc_files:
23
- - README
22
+ extra_rdoc_files: []
23
+
24
24
  files:
25
- - ./README
25
+ - ./README.rdoc
26
26
  - ./auto_sprite.gemspec
27
27
  - ./MIT-LICENSE
28
28
  - ./rails/init.rb
29
29
  - ./lib/auto_sprite.rb
30
- - README
31
30
  has_rdoc: true
32
- homepage: http://gemcutter.org/gems/auto_sprite
31
+ homepage: http://fargle.org/auto_sprite
33
32
  licenses: []
34
33
 
35
34
  post_install_message:
data/README DELETED
@@ -1,70 +0,0 @@
1
- AutoSprite
2
- ==========
3
-
4
- An easy, automated CSS image sprite creator.
5
-
6
- Install
7
- ==========
8
-
9
- 1. Install auto_sprite and RMagick.
10
-
11
- gem install RMagick
12
- gem install auto_sprite
13
-
14
- 2. Edit your environement.rb add config.gem "auto_sprite"
15
-
16
- Usage
17
- ==========
18
- 1. Include the stylesheet in your layout:
19
-
20
- <%= stylesheet_link_tag "auto_sprite" %>
21
-
22
- 2. Create a directory called sprites in your images directory (e.g. RAILS_ROOT/public/images/sprites)
23
-
24
- 3. Put the images you want to link to in your public/images/sprites directory.
25
-
26
- 3. Use your images like you normally would:
27
-
28
- <%= image_tag 'sprites/logo.png' %>
29
- <%= image_tag 'sprites/icon1.jpg' %> ... etc
30
-
31
- 4. Enjoy your now faster website.
32
-
33
-
34
- Details
35
- ==========
36
-
37
- Whenever rails reloads, it will automatically generate two files:
38
-
39
- RAILS_ROOT/public/stylesheets/auto_sprite.css
40
- RAILS_ROOT/public/images/auto_sprite.png
41
-
42
-
43
- The image tag will automatically generate a div tag for any images located in the sprite directory.
44
-
45
- <div class="_as_logo_png"></div> instead of <img src="/images/sprites/logo.png" />
46
-
47
-
48
- Here is an exmplmple of the stylehseet that would be generated if you had two files face3.png and face4.png
49
-
50
- ._as_face3_png {
51
- background-position:0 0px;
52
- height:16px;
53
- width:16px;
54
- }
55
-
56
- ._as_face4_png{
57
- background-position:0 -16px;
58
- height:16px;
59
- width:16px;
60
- }
61
-
62
- ._as_face3_png,
63
- ._as_face3_png {
64
- display:inline-block;
65
- background-image:url('/images/auto_sprite.png');
66
- background-repeat:no-repeat;
67
- }
68
-
69
-
70
- Copyright (c) 2010 Stephen Blackstone, released under the MIT license