lemonade 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +24 -1
- data/README.md +17 -112
- data/lib/lemonade.rb +6 -62
- data/lib/lemonade/version.rb +3 -0
- metadata +16 -83
- data/.document +0 -5
- data/.gitignore +0 -21
- data/Rakefile +0 -47
- data/TODO.md +0 -4
- data/VERSION +0 -1
- data/lemonade.gemspec +0 -73
- data/lib/lemonade/lemonade.rb +0 -19
- data/lib/lemonade/sass_extensions/functions/lemonade.rb +0 -56
- data/spec/images/other_images/more-images/sprites/test.png +0 -0
- data/spec/images/other_images/test.png +0 -0
- data/spec/images/sprites/10x10.png +0 -0
- data/spec/images/sprites/150x10.png +0 -0
- data/spec/images/sprites/20x20.png +0 -0
- data/spec/images/sprites/30x30.png +0 -0
- data/spec/lemonade_spec.rb +0 -119
- data/spec/spec.opts +0 -4
- data/spec/spec_helper.rb +0 -12
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,29 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
1.0.1.deprecated.1, 0.3.5*
|
5
|
+
--------------------------
|
6
|
+
|
7
|
+
* Deprecated everything
|
8
|
+
|
9
|
+
\* just to be sure that the deprication will be installed
|
10
|
+
|
11
|
+
|
12
|
+
1.0.0.beta.1
|
13
|
+
------------
|
14
|
+
|
15
|
+
* Fixed warnings generated by Compass
|
16
|
+
* Now works perfectly, if larger spacing is defined after smaller spacing
|
17
|
+
* Removed Compass dependencies
|
18
|
+
* New Sass functions: `sprite-url()` and `sprite-position()`
|
19
|
+
* Mixins: `sprite-image`, `sizes-sprite-image`, `sprite-folder`, `sized-sprite-folder`
|
20
|
+
* Internal changes:
|
21
|
+
* Switched to Bundler
|
22
|
+
* Rewritten calculation (all Y positions are calculated after CSS is generated by Sass)
|
23
|
+
* Moved integration to `Sass::Tree::RootNode` (works the same for Rails 2.3, 3.0, Compass & Staticmatic)
|
24
|
+
* Added more specs
|
25
|
+
|
26
|
+
|
4
27
|
0.3.4
|
5
28
|
-----
|
6
29
|
|
@@ -47,4 +70,4 @@ Changelog
|
|
47
70
|
0.1.0
|
48
71
|
-----
|
49
72
|
|
50
|
-
* Initial release
|
73
|
+
* Initial release
|
data/README.md
CHANGED
@@ -1,123 +1,28 @@
|
|
1
|
-
Lemonade
|
2
|
-
|
1
|
+
Lemonade is deprecated
|
2
|
+
======================
|
3
3
|
|
4
|
-
|
4
|
+
Lemonade was a [cool way to create sprites](http://www.hagenburger.net/BLOG/Lemonade-CSS-Sprites-for-Sass-Compass.html).
|
5
|
+
Now I [merged Lemonade into Compass](http://chriseppstein.github.com/blog/2010/09/11/compass-merging-with-lemonade/) in [v0.11](https://github.com/chriseppstein/compass/tree/v0.11.0) and redefined the API with [Chris Eppstein](https://twitter.com/chriseppstein). Even better, [Scott Davis](https://twitter.com/jetviper21) made some enhancements.
|
5
6
|
|
7
|
+
So thanks for all the buzz for Lemonade and take a look at our Compass
|
8
|
+
Sprites implementation:
|
6
9
|
|
7
|
-
|
10
|
+
<http://compass-style.org/help/tutorials/spriting/>
|
8
11
|
|
9
|
-
|
10
|
-
background: sprite-image("bottles/fanta.png");
|
11
|
-
}
|
12
|
-
.seven-up {
|
13
|
-
background: sprite-image("bottles/seven-up.png");
|
14
|
-
}
|
15
|
-
.coke {
|
16
|
-
background: sprite-image("cans/coke.png") no-repeat;
|
17
|
-
}
|
12
|
+
Follow @[hagenburger](http://twitter.com/hagenburger) for updates.
|
18
13
|
|
19
|
-
|
14
|
+
Cheers,
|
20
15
|
|
21
|
-
|
22
|
-
background: url('/images/bottles.png');
|
23
|
-
}
|
24
|
-
.seven-up {
|
25
|
-
background: url('/images/bottles.png') 0 -50px;
|
26
|
-
}
|
27
|
-
.coke {
|
28
|
-
background: url('/images/cans.png') no-repeat;
|
29
|
-
}
|
16
|
+
Nico)
|
30
17
|
|
31
18
|
|
32
|
-
|
33
|
-
|
19
|
+
Still need to use Lemonade?
|
20
|
+
---------------------------
|
34
21
|
|
35
|
-
|
36
|
-
* Sets the background position (unless “0 0”)
|
37
|
-
* It uses the `images_dir` defined by Compass (just like `image-url()`)
|
38
|
-
* No Rake task needed
|
39
|
-
* No additional classes
|
40
|
-
* No configuration
|
41
|
-
* No RMagick required (but full support for PNG)
|
22
|
+
Try to use an older implementation of ChunkyPNG if you get empty PNGs:
|
42
23
|
|
24
|
+
# Gemfile
|
25
|
+
gem 'lemonade'
|
26
|
+
gem 'chunky_png', '0.11.1'
|
43
27
|
|
44
|
-
|
45
|
-
------------
|
46
|
-
|
47
|
-
gem install lemonade
|
48
|
-
|
49
|
-
|
50
|
-
Current State
|
51
|
-
-------------
|
52
|
-
|
53
|
-
* Compass standalone finished
|
54
|
-
* Rails Sass integration finished
|
55
|
-
* Staticmatic integration finished
|
56
|
-
* Haml integration (with “:sass” filter): work in progress
|
57
|
-
|
58
|
-
|
59
|
-
Options
|
60
|
-
-------
|
61
|
-
|
62
|
-
You can pass an additional background position.
|
63
|
-
It will be added to the calculated position:
|
64
|
-
|
65
|
-
.seven-up {
|
66
|
-
background: sprite-image("bottles/seven-up.png", 12px, 3px);
|
67
|
-
}
|
68
|
-
|
69
|
-
Output (assuming the calculated position would be “0 -50px” as shown above):
|
70
|
-
|
71
|
-
.seven-up {
|
72
|
-
background: url('/images/bottles.png') 12px -47px;
|
73
|
-
}
|
74
|
-
|
75
|
-
If you need empty space around the current image, this will add 20px transparent space above and below.
|
76
|
-
|
77
|
-
.seven-up {
|
78
|
-
background: sprite-image("bottles/seven-up.png", 0, 0, 20px);
|
79
|
-
}
|
80
|
-
|
81
|
-
This one adds 20px above, 30px below:
|
82
|
-
|
83
|
-
.seven-up {
|
84
|
-
background: sprite-image("bottles/seven-up.png", 0, 0, 20px, 30px);
|
85
|
-
}
|
86
|
-
|
87
|
-
Right aligned images are possible:
|
88
|
-
|
89
|
-
.seven-up {
|
90
|
-
background: sprite-image("bottles/seven-up.png", 100%, 4px);
|
91
|
-
}
|
92
|
-
|
93
|
-
The original image will be placed on the right side of the sprite image.
|
94
|
-
Use this, if you have a link with an arrow on the right side (like Apple).
|
95
|
-
|
96
|
-
|
97
|
-
Note on Patches/Pull Requests
|
98
|
-
-----------------------------
|
99
|
-
|
100
|
-
* Fork the project.
|
101
|
-
* Make your feature addition or bug fix.
|
102
|
-
* Add tests for it. This is important so I don't break it in a
|
103
|
-
future version unintentionally.
|
104
|
-
* Commit, do not mess with rakefile, version, or history.
|
105
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
106
|
-
* Send me a pull request. Bonus points for topic branches.
|
107
|
-
|
108
|
-
|
109
|
-
Rails 3 Troubleshooting
|
110
|
-
-----------------------
|
111
|
-
|
112
|
-
If you want to use Lemonade with Rails 3 Please use this compass and haml versions in your Gemfile
|
113
|
-
|
114
|
-
gem 'compass', '0.10.2'
|
115
|
-
gem 'haml-edge', '3.1.49', :require => 'haml'
|
116
|
-
|
117
|
-
|
118
|
-
Copyright
|
119
|
-
---------
|
120
|
-
|
121
|
-
Copyright (c) 2010 [Nico Hagenburger](http://www.hagenburger.net).
|
122
|
-
See MIT-LICENSE for details.
|
123
|
-
[Follow me](http://twitter.com/hagenburger) on twitter.
|
28
|
+
You can find the old Lemonade code in the [master branch](https://github.com/hagenburger/lemonade/tree/master)
|
data/lib/lemonade.rb
CHANGED
@@ -1,65 +1,9 @@
|
|
1
|
-
|
2
|
-
module SassExtensions
|
3
|
-
module Functions
|
4
|
-
end
|
5
|
-
end
|
6
|
-
end
|
1
|
+
require 'fileutils'
|
7
2
|
|
3
|
+
raise <<-INFO
|
8
4
|
|
5
|
+
Lemonade is deprecated now. You may want to use Compass Sprites from now on. More information:
|
6
|
+
https://github.com/hagenburger/lemonade
|
7
|
+
#{File.dirname(__FILE__)}/README.md
|
9
8
|
|
10
|
-
|
11
|
-
require 'rubygems'
|
12
|
-
require 'compass'
|
13
|
-
|
14
|
-
|
15
|
-
# Rails 3.0.0.beta.2+
|
16
|
-
if defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load)
|
17
|
-
require 'haml/template/options'
|
18
|
-
require 'sass/plugin/configuration'
|
19
|
-
ActiveSupport.on_load(:before_initialize) do
|
20
|
-
require 'sass'
|
21
|
-
require 'sass/plugin'
|
22
|
-
|
23
|
-
module Sass
|
24
|
-
module Plugin
|
25
|
-
alias_method :update_stylesheets_without_lemonade, :update_stylesheets
|
26
|
-
def update_stylesheets
|
27
|
-
if update_stylesheets_without_lemonade
|
28
|
-
Lemonade::generate_sprites
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
require 'chunky_png'
|
37
|
-
require File.dirname(__FILE__) + '/lemonade/sass_extensions/functions/lemonade'
|
38
|
-
require File.dirname(__FILE__) + '/lemonade/lemonade'
|
39
|
-
|
40
|
-
module Sass::Script::Functions
|
41
|
-
include Lemonade::SassExtensions::Functions::Lemonade
|
42
|
-
end
|
43
|
-
|
44
|
-
module Compass
|
45
|
-
class Compiler
|
46
|
-
alias_method :compile_without_lemonade, :compile
|
47
|
-
def compile(sass_filename, css_filename)
|
48
|
-
compile_without_lemonade sass_filename, css_filename
|
49
|
-
Lemonade::generate_sprites
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
module Sass
|
55
|
-
class Engine
|
56
|
-
alias_method :render_without_lemonade, :render
|
57
|
-
def render
|
58
|
-
if result = render_without_lemonade
|
59
|
-
Lemonade::generate_sprites
|
60
|
-
result
|
61
|
-
end
|
62
|
-
end
|
63
|
-
alias_method :to_css, :render
|
64
|
-
end
|
65
|
-
end
|
9
|
+
INFO
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lemonade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
9
|
+
- 5
|
10
|
+
version: 0.3.5
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Nico Hagenburger
|
@@ -14,65 +15,10 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date:
|
18
|
+
date: 2011-05-29 00:00:00 +02:00
|
18
19
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
|
21
|
-
name: haml
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 3
|
29
|
-
- 0
|
30
|
-
- 0
|
31
|
-
version: 3.0.0
|
32
|
-
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: compass
|
36
|
-
prerelease: false
|
37
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
segments:
|
42
|
-
- 0
|
43
|
-
- 10
|
44
|
-
- 0
|
45
|
-
version: 0.10.0
|
46
|
-
type: :runtime
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: chunky_png
|
50
|
-
prerelease: false
|
51
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
segments:
|
56
|
-
- 0
|
57
|
-
- 8
|
58
|
-
- 0
|
59
|
-
version: 0.8.0
|
60
|
-
type: :runtime
|
61
|
-
version_requirements: *id003
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rspec
|
64
|
-
prerelease: false
|
65
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
segments:
|
70
|
-
- 1
|
71
|
-
- 2
|
72
|
-
- 9
|
73
|
-
version: 1.2.9
|
74
|
-
type: :development
|
75
|
-
version_requirements: *id004
|
20
|
+
dependencies: []
|
21
|
+
|
76
22
|
description: "Generates sprites on the fly by using `background: sprite-image(\"sprites/logo.png\")`. No Photoshop, no RMagick, no Rake task, save your time and have a lemonade."
|
77
23
|
email: gems@hagenburger.net
|
78
24
|
executables: []
|
@@ -82,27 +28,11 @@ extensions: []
|
|
82
28
|
extra_rdoc_files:
|
83
29
|
- README.md
|
84
30
|
files:
|
85
|
-
- .
|
86
|
-
- .
|
31
|
+
- lib/lemonade/version.rb
|
32
|
+
- lib/lemonade.rb
|
87
33
|
- CHANGELOG.md
|
88
34
|
- MIT-LICENSE
|
89
35
|
- README.md
|
90
|
-
- Rakefile
|
91
|
-
- TODO.md
|
92
|
-
- VERSION
|
93
|
-
- lemonade.gemspec
|
94
|
-
- lib/lemonade.rb
|
95
|
-
- lib/lemonade/lemonade.rb
|
96
|
-
- lib/lemonade/sass_extensions/functions/lemonade.rb
|
97
|
-
- spec/images/other_images/more-images/sprites/test.png
|
98
|
-
- spec/images/other_images/test.png
|
99
|
-
- spec/images/sprites/10x10.png
|
100
|
-
- spec/images/sprites/150x10.png
|
101
|
-
- spec/images/sprites/20x20.png
|
102
|
-
- spec/images/sprites/30x30.png
|
103
|
-
- spec/lemonade_spec.rb
|
104
|
-
- spec/spec.opts
|
105
|
-
- spec/spec_helper.rb
|
106
36
|
has_rdoc: true
|
107
37
|
homepage: http://github.com/hagenburger/lemonade
|
108
38
|
licenses: []
|
@@ -113,26 +43,29 @@ rdoc_options:
|
|
113
43
|
require_paths:
|
114
44
|
- lib
|
115
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
116
47
|
requirements:
|
117
48
|
- - ">="
|
118
49
|
- !ruby/object:Gem::Version
|
50
|
+
hash: 3
|
119
51
|
segments:
|
120
52
|
- 0
|
121
53
|
version: "0"
|
122
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
123
56
|
requirements:
|
124
57
|
- - ">="
|
125
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
126
60
|
segments:
|
127
61
|
- 0
|
128
62
|
version: "0"
|
129
63
|
requirements: []
|
130
64
|
|
131
65
|
rubyforge_project:
|
132
|
-
rubygems_version: 1.
|
66
|
+
rubygems_version: 1.6.1
|
133
67
|
signing_key:
|
134
68
|
specification_version: 3
|
135
69
|
summary: On the fly sprite generator for Sass/Compass
|
136
|
-
test_files:
|
137
|
-
|
138
|
-
- spec/spec_helper.rb
|
70
|
+
test_files: []
|
71
|
+
|
data/.document
DELETED
data/.gitignore
DELETED
data/Rakefile
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "lemonade"
|
8
|
-
gem.summary = "On the fly sprite generator for Sass/Compass"
|
9
|
-
gem.description = "Generates sprites on the fly by using `background: sprite-image(\"sprites/logo.png\")`. No Photoshop, no RMagick, no Rake task, save your time and have a lemonade."
|
10
|
-
gem.email = "gems@hagenburger.net"
|
11
|
-
gem.homepage = "http://github.com/hagenburger/lemonade"
|
12
|
-
gem.authors = ["Nico Hagenburger"]
|
13
|
-
gem.add_dependency "haml", ">= 3.0.0"
|
14
|
-
gem.add_dependency "compass", ">= 0.10.0"
|
15
|
-
gem.add_dependency "chunky_png", ">= 0.8.0"
|
16
|
-
gem.add_development_dependency "rspec", ">= 1.2.9"
|
17
|
-
end
|
18
|
-
Jeweler::GemcutterTasks.new
|
19
|
-
rescue LoadError
|
20
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
-
end
|
22
|
-
|
23
|
-
require 'spec/rake/spectask'
|
24
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
25
|
-
spec.libs << 'lib' << 'spec'
|
26
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
27
|
-
end
|
28
|
-
|
29
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
30
|
-
spec.libs << 'lib' << 'spec'
|
31
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
32
|
-
spec.rcov = true
|
33
|
-
end
|
34
|
-
|
35
|
-
task :spec => :check_dependencies
|
36
|
-
|
37
|
-
task :default => :spec
|
38
|
-
|
39
|
-
require 'rake/rdoctask'
|
40
|
-
Rake::RDocTask.new do |rdoc|
|
41
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
42
|
-
|
43
|
-
rdoc.rdoc_dir = 'rdoc'
|
44
|
-
rdoc.title = "lemonade #{version}"
|
45
|
-
rdoc.rdoc_files.include('README*')
|
46
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
47
|
-
end
|
data/TODO.md
DELETED
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.3.4
|
data/lemonade.gemspec
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{lemonade}
|
8
|
-
s.version = "0.3.4"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Nico Hagenburger"]
|
12
|
-
s.date = %q{2010-07-04}
|
13
|
-
s.description = %q{Generates sprites on the fly by using `background: sprite-image("sprites/logo.png")`. No Photoshop, no RMagick, no Rake task, save your time and have a lemonade.}
|
14
|
-
s.email = %q{gems@hagenburger.net}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"README.md"
|
17
|
-
]
|
18
|
-
s.files = [
|
19
|
-
".document",
|
20
|
-
".gitignore",
|
21
|
-
"CHANGELOG.md",
|
22
|
-
"MIT-LICENSE",
|
23
|
-
"README.md",
|
24
|
-
"Rakefile",
|
25
|
-
"TODO.md",
|
26
|
-
"VERSION",
|
27
|
-
"lemonade.gemspec",
|
28
|
-
"lib/lemonade.rb",
|
29
|
-
"lib/lemonade/lemonade.rb",
|
30
|
-
"lib/lemonade/sass_extensions/functions/lemonade.rb",
|
31
|
-
"spec/images/other_images/more-images/sprites/test.png",
|
32
|
-
"spec/images/other_images/test.png",
|
33
|
-
"spec/images/sprites/10x10.png",
|
34
|
-
"spec/images/sprites/150x10.png",
|
35
|
-
"spec/images/sprites/20x20.png",
|
36
|
-
"spec/images/sprites/30x30.png",
|
37
|
-
"spec/lemonade_spec.rb",
|
38
|
-
"spec/spec.opts",
|
39
|
-
"spec/spec_helper.rb"
|
40
|
-
]
|
41
|
-
s.homepage = %q{http://github.com/hagenburger/lemonade}
|
42
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
43
|
-
s.require_paths = ["lib"]
|
44
|
-
s.rubygems_version = %q{1.3.6}
|
45
|
-
s.summary = %q{On the fly sprite generator for Sass/Compass}
|
46
|
-
s.test_files = [
|
47
|
-
"spec/lemonade_spec.rb",
|
48
|
-
"spec/spec_helper.rb"
|
49
|
-
]
|
50
|
-
|
51
|
-
if s.respond_to? :specification_version then
|
52
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
53
|
-
s.specification_version = 3
|
54
|
-
|
55
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
56
|
-
s.add_runtime_dependency(%q<haml>, [">= 3.0.0"])
|
57
|
-
s.add_runtime_dependency(%q<compass>, [">= 0.10.0"])
|
58
|
-
s.add_runtime_dependency(%q<chunky_png>, [">= 0.8.0"])
|
59
|
-
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
60
|
-
else
|
61
|
-
s.add_dependency(%q<haml>, [">= 3.0.0"])
|
62
|
-
s.add_dependency(%q<compass>, [">= 0.10.0"])
|
63
|
-
s.add_dependency(%q<chunky_png>, [">= 0.8.0"])
|
64
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
65
|
-
end
|
66
|
-
else
|
67
|
-
s.add_dependency(%q<haml>, [">= 3.0.0"])
|
68
|
-
s.add_dependency(%q<compass>, [">= 0.10.0"])
|
69
|
-
s.add_dependency(%q<chunky_png>, [">= 0.8.0"])
|
70
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
data/lib/lemonade/lemonade.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Lemonade
|
2
|
-
def self.generate_sprites
|
3
|
-
if $lemonade_sprites
|
4
|
-
$lemonade_sprites.each do |sprite_name, sprite|
|
5
|
-
sprite_image = ChunkyPNG::Image.new(sprite[:width], sprite[:height], ChunkyPNG::Color::TRANSPARENT)
|
6
|
-
y = 0
|
7
|
-
sprite[:images].each do |image|
|
8
|
-
file = File.join(Compass.configuration.images_path, image[:file])
|
9
|
-
single_image = ChunkyPNG::Image.from_file(file)
|
10
|
-
x = (sprite[:width] - image[:width]) * image[:x]
|
11
|
-
sprite_image.replace single_image, x, image[:y]
|
12
|
-
end
|
13
|
-
file = File.join(Compass.configuration.images_path, "#{ sprite_name }.png")
|
14
|
-
sprite_image.save file
|
15
|
-
end
|
16
|
-
$lemonade_sprites = nil
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module Lemonade::SassExtensions::Functions::Lemonade
|
2
|
-
|
3
|
-
def sprite_image(file, add_x = nil, add_y = nil, margin_top_or_both = nil, margin_bottom = nil)
|
4
|
-
assert_type file, :String
|
5
|
-
unless (file.to_s =~ %r(^"(.+/)?(.+?)/(.+?)\.(png|gif|jpg)"$)) == 0
|
6
|
-
raise Sass::SyntaxError, 'Please provide a file in a folder: e.g. sprites/button.png'
|
7
|
-
end
|
8
|
-
dir, name, filename = $1, $2, $3
|
9
|
-
filestr = file.to_s.gsub('"', '')
|
10
|
-
|
11
|
-
$lemonade_sprites ||= {}
|
12
|
-
sprite = $lemonade_sprites["#{ dir }/#{ name }"] ||= {
|
13
|
-
:height => 0,
|
14
|
-
:width => 0,
|
15
|
-
:images => [],
|
16
|
-
:margin_bottom => 0
|
17
|
-
}
|
18
|
-
|
19
|
-
if image = sprite[:images].detect{ |image| image[:file] == filestr }
|
20
|
-
y = image[:y]
|
21
|
-
else
|
22
|
-
height = image_height(file).value
|
23
|
-
width = image_width(file).value
|
24
|
-
margin_top = calculate_margin_top(sprite, margin_top_or_both, margin_bottom)
|
25
|
-
x = (add_x and add_x.numerator_units == %w(%)) ? add_x.value / 100 : 0
|
26
|
-
y = sprite[:height] + margin_top
|
27
|
-
sprite[:height] += height + margin_top
|
28
|
-
sprite[:width] = width if width > sprite[:width]
|
29
|
-
sprite[:images] << { :file => filestr, :height => height, :width => width, :x => x, :y => y }
|
30
|
-
end
|
31
|
-
|
32
|
-
position = background_position(0, y, add_x, add_y)
|
33
|
-
output_file = image_url(Sass::Script::String.new("#{ dir }#{ name }.png"))
|
34
|
-
Sass::Script::String.new("#{ output_file }#{ position }")
|
35
|
-
end
|
36
|
-
alias_method :sprite_img, :sprite_image
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def background_position(x, y, add_x, add_y)
|
41
|
-
y = -y
|
42
|
-
x = add_x ? add_x.to_s : 0
|
43
|
-
y += add_y.value if add_y
|
44
|
-
unless (add_x.nil? or add_x.value == 0) and y == 0
|
45
|
-
" #{ x } #{ y }#{ 'px' unless y == 0 }"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def calculate_margin_top(sprite, margin_top_or_both, margin_bottom)
|
50
|
-
margin_top_or_both = margin_top_or_both ? margin_top_or_both.value : 0
|
51
|
-
margin_top = (sprite[:margin_bottom] ||= 0) > margin_top_or_both ? sprite[:margin_bottom] : margin_top_or_both
|
52
|
-
sprite[:margin_bottom] = margin_bottom ? margin_bottom.value : margin_top_or_both
|
53
|
-
margin_top
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/spec/lemonade_spec.rb
DELETED
@@ -1,119 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Lemonade::SassExtensions::Functions::Lemonade do
|
4
|
-
before :each do
|
5
|
-
@sass = Sass::Environment.new
|
6
|
-
$lemonade_sprites = nil
|
7
|
-
$lemonade_margin_bottom = nil
|
8
|
-
FileUtils.cp_r File.dirname(__FILE__) + '/images', IMAGES_TMP_PATH
|
9
|
-
end
|
10
|
-
|
11
|
-
after :each do
|
12
|
-
FileUtils.rm_r IMAGES_TMP_PATH
|
13
|
-
end
|
14
|
-
|
15
|
-
def image_size(file)
|
16
|
-
Lemonade::generate_sprites
|
17
|
-
IO.read(IMAGES_TMP_PATH + '/' + file)[0x10..0x18].unpack('NN')
|
18
|
-
end
|
19
|
-
|
20
|
-
def evaluate(value)
|
21
|
-
Sass::Script::Parser.parse(value, 0, 0).perform(@sass).to_s
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should return the sprite file name" do
|
25
|
-
evaluate('sprite-image("sprites/30x30.png")').should == "url('/sprites.png')"
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should also work with `sprite-img`" do
|
29
|
-
evaluate('sprite-img("sprites/30x30.png")').should == "url('/sprites.png')"
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should work in folders with dashes and underscores" do
|
33
|
-
evaluate('sprite-image("other_images/more-images/sprites/test.png")').should ==
|
34
|
-
"url('/other_images/more-images/sprites.png')"
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should not work without any folder" do
|
38
|
-
lambda { evaluate('sprite-image("test.png")') }.should raise_exception(Sass::SyntaxError)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should set the background position" do
|
42
|
-
evaluate('sprite-image("sprites/30x30.png")').should == "url('/sprites.png')"
|
43
|
-
evaluate('sprite-image("sprites/150x10.png")').should == "url('/sprites.png') 0 -30px"
|
44
|
-
image_size('sprites.png').should == [150, 40]
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should use the X position" do
|
48
|
-
evaluate('sprite-image("sprites/30x30.png", 5px, 0)').should == "url('/sprites.png') 5px 0"
|
49
|
-
image_size('sprites.png').should == [30, 30]
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should calculate 20px empty space between sprites" do
|
53
|
-
# Resulting sprite should look like (1 line = 10px height, X = placed image):
|
54
|
-
|
55
|
-
# X
|
56
|
-
#
|
57
|
-
#
|
58
|
-
# XX
|
59
|
-
# XX
|
60
|
-
#
|
61
|
-
#
|
62
|
-
# XXX
|
63
|
-
# XXX
|
64
|
-
# XXX
|
65
|
-
|
66
|
-
evaluate('sprite-image("sprites/10x10.png")').should == "url('/sprites.png')"
|
67
|
-
# space before #2: 20px
|
68
|
-
evaluate('sprite-image("sprites/20x20.png", 0, 0, 20px)').should == "url('/sprites.png') 0 -30px"
|
69
|
-
# space after #2: 20px
|
70
|
-
evaluate('sprite-image("sprites/30x30.png")').should == "url('/sprites.png') 0 -70px"
|
71
|
-
image_size('sprites.png').should == [30, 100]
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should calculate empty space between sprites and combine space like CSS margins" do
|
75
|
-
# Resulting sprite should look like (1 line = 10px height, X = placed image):
|
76
|
-
|
77
|
-
# X
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
# XX
|
82
|
-
# XX
|
83
|
-
#
|
84
|
-
# XXX
|
85
|
-
# XXX
|
86
|
-
# XXX
|
87
|
-
|
88
|
-
evaluate('sprite-image("sprites/10x10.png", 0, 0, 0, 30px)').should == "url('/sprites.png')"
|
89
|
-
# space between #1 and #2: 30px (=> 30px > 20px)
|
90
|
-
evaluate('sprite-image("sprites/20x20.png", 0, 0, 20px, 5px)').should == "url('/sprites.png') 0 -40px"
|
91
|
-
# space between #2 and #3: 10px (=> 5px < 10px)
|
92
|
-
evaluate('sprite-image("sprites/30x30.png", 0, 0, 10px)').should == "url('/sprites.png') 0 -70px"
|
93
|
-
image_size('sprites.png').should == [30, 100]
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should calculate empty space correctly when 2 output images are uses" do
|
97
|
-
evaluate('sprite-image("sprites/10x10.png", 0, 0, 0, 30px)').should == "url('/sprites.png')"
|
98
|
-
evaluate('sprite-image("other_images/test.png")').should == "url('/other_images.png')"
|
99
|
-
evaluate('sprite-image("sprites/20x20.png", 0, 0, 20px, 5px)').should == "url('/sprites.png') 0 -40px"
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should allow % for x positions" do
|
103
|
-
# Resulting sprite should look like (1 line = 10px height, X = placed image):
|
104
|
-
|
105
|
-
# XXXXXXXXXXXXXXX
|
106
|
-
# X
|
107
|
-
|
108
|
-
evaluate('sprite-image("sprites/150x10.png")')
|
109
|
-
evaluate('sprite-image("sprites/10x10.png", 100%)').should == "url('/sprites.png') 100% -10px"
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should not compose the same image twice" do
|
113
|
-
evaluate('sprite-image("sprites/10x10.png")').should == "url('/sprites.png')"
|
114
|
-
evaluate('sprite-image("sprites/20x20.png")').should == "url('/sprites.png') 0 -10px"
|
115
|
-
evaluate('sprite-image("sprites/20x20.png")').should == "url('/sprites.png') 0 -10px" # reuse image from line above
|
116
|
-
image_size('sprites.png').should == [20, 30]
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|
data/spec/spec.opts
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
require 'lemonade'
|
4
|
-
require 'spec'
|
5
|
-
require 'spec/autorun'
|
6
|
-
|
7
|
-
IMAGES_TMP_PATH = File.dirname(__FILE__) + '/images-tmp'
|
8
|
-
Compass.configuration.images_path = IMAGES_TMP_PATH
|
9
|
-
|
10
|
-
Spec::Runner.configure do |config|
|
11
|
-
|
12
|
-
end
|