Rename Lemonade to Compass::Sprites
This commit is contained in:
parent
ac85ca1e7a
commit
6a44d58b7c
@ -15,8 +15,6 @@ module Compass
|
||||
module_function :base_directory, :lib_directory
|
||||
end
|
||||
|
||||
%w(configuration frameworks app_integration actions compiler).each do |lib|
|
||||
%w(configuration frameworks app_integration actions compiler sprites).each do |lib|
|
||||
require "compass/#{lib}"
|
||||
end
|
||||
|
||||
require "lemonade"
|
||||
|
@ -1,7 +1,7 @@
|
||||
require 'chunky_png'
|
||||
require 'lemonade/sprite_info.rb'
|
||||
require 'compass/sprites/sprite_info'
|
||||
|
||||
module Lemonade
|
||||
module Compass::Sprites
|
||||
@@sprites = {}
|
||||
@@sprites_path = nil
|
||||
@@images_path = nil
|
||||
@ -45,8 +45,8 @@ module Lemonade
|
||||
def extend_sass!
|
||||
require 'sass'
|
||||
require 'sass/plugin'
|
||||
require File.expand_path('../lemonade/sass_functions', __FILE__)
|
||||
require File.expand_path('../lemonade/sass_extension', __FILE__)
|
||||
require 'compass/sprites/sass_functions'
|
||||
require 'compass/sprites/sass_extension'
|
||||
end
|
||||
|
||||
def sprite_changed?(sprite_name, sprite)
|
||||
@ -68,7 +68,7 @@ module Lemonade
|
||||
private
|
||||
|
||||
def sprite_info_file(sprite_name)
|
||||
File.join(Lemonade.images_path, "#{sprite_name}.sprite_info.yml")
|
||||
File.join(Compass::Sprites.images_path, "#{sprite_name}.sprite_info.yml")
|
||||
end
|
||||
|
||||
def timestamps(sprite)
|
||||
@ -108,7 +108,7 @@ module Lemonade
|
||||
y = sprite_item[:y].value
|
||||
sprite_image.replace sprite_item_image, x, y
|
||||
end
|
||||
sprite_image.save File.join(Lemonade.images_path, sprite[:file])
|
||||
sprite_image.save File.join(Compass::Sprites.images_path, sprite[:file])
|
||||
end
|
||||
|
||||
end
|
||||
@ -119,9 +119,9 @@ end
|
||||
if defined?(ActiveSupport) and Sass::Util.has?(:public_method, ActiveSupport, :on_load)
|
||||
# Rails 3.0
|
||||
ActiveSupport.on_load :before_initialize do
|
||||
Lemonade.extend_sass!
|
||||
Compass::Sprites.extend_sass!
|
||||
end
|
||||
else
|
||||
Lemonade.extend_sass!
|
||||
Compass::Sprites.extend_sass!
|
||||
end
|
||||
|
@ -4,12 +4,12 @@ module Sass
|
||||
|
||||
class RootNode < Node
|
||||
|
||||
alias_method :render_without_lemonade, :render
|
||||
alias_method :render_without_sprites, :render
|
||||
def render
|
||||
if result = render_without_lemonade
|
||||
Lemonade.generate_sprites
|
||||
if result = render_without_sprites
|
||||
Compass::Sprites.generate_sprites
|
||||
result = ERB.new(result).result(binding)
|
||||
Lemonade.reset
|
||||
Compass::Sprites.reset
|
||||
return result
|
||||
end
|
||||
end
|
@ -44,20 +44,20 @@ module Sass::Script::Functions
|
||||
private
|
||||
|
||||
def sprite_file_list_from_folder(folder)
|
||||
dir = File.join(Lemonade.sprites_path, folder.value)
|
||||
dir = File.join(Compass::Sprites.sprites_path, folder.value)
|
||||
Dir.glob(File.join(dir, '*.png')).sort
|
||||
end
|
||||
|
||||
def sprite_url_and_position(file, position_x = nil, position_y_shift = nil, margin_top_or_both = nil, margin_bottom = nil)
|
||||
dir, name, basename = extract_names(file, :check_file => true)
|
||||
filestr = File.join(Lemonade.sprites_path, file.value)
|
||||
filestr = File.join(Compass::Sprites.sprites_path, file.value)
|
||||
|
||||
sprite_file = "#{dir}#{name}.png"
|
||||
sprite = sprite_for(sprite_file)
|
||||
sprite_item = image_for(sprite, filestr, position_x, position_y_shift, margin_top_or_both, margin_bottom)
|
||||
|
||||
# Create a temporary destination file so compass doesn't complain about a missing image
|
||||
FileUtils.touch File.join(Lemonade.images_path, sprite_file) unless File.exists?(File.join(Lemonade.images_path, sprite_file))
|
||||
FileUtils.touch File.join(Compass::Sprites.images_path, sprite_file) unless File.exists?(File.join(Compass::Sprites.images_path, sprite_file))
|
||||
|
||||
[sprite, sprite_item]
|
||||
end
|
||||
@ -76,7 +76,7 @@ private
|
||||
|
||||
def sprite_for(file)
|
||||
file = "#{file}.png" unless file =~ /\.png$/
|
||||
Lemonade.sprites[file] ||= {
|
||||
Compass::Sprites.sprites[file] ||= {
|
||||
:file => "#{file}",
|
||||
:height => 0,
|
||||
:width => 0,
|
||||
@ -111,7 +111,7 @@ private
|
||||
end
|
||||
image
|
||||
rescue Errno::ENOENT
|
||||
raise Sass::SyntaxError, "#{file} does not exist in sprites_dir #{Lemonade.sprites_path}"
|
||||
raise Sass::SyntaxError, "#{file} does not exist in sprites_dir #{Compass::Sprites.sprites_path}"
|
||||
rescue ChunkyPNG::SignatureMismatch
|
||||
raise Sass::SyntaxError, "#{file} is not a recognized png file, can't use for sprite creation"
|
||||
end
|
@ -43,7 +43,7 @@ module Sass::Script
|
||||
if @sprite_item[:index] == 0 and (@position_y_shift.nil? or @position_y_shift.value == 0)
|
||||
"#{x.inspect} 0"
|
||||
else
|
||||
expression = "Lemonade.sprites['#{@sprite[:file]}'][:images][#{@sprite_item[:index]}][:y].unary_minus"
|
||||
expression = "Compass::Sprites.sprites['#{@sprite[:file]}'][:images][#{@sprite_item[:index]}][:y].unary_minus"
|
||||
expression << ".plus(Sass::Script::Number.new(#{@position_y_shift.value}, ['px']))" if @position_y_shift
|
||||
"#{x.inspect} <%= #{expression} %>"
|
||||
end
|
@ -1,3 +0,0 @@
|
||||
module Lemonade
|
||||
Version = "1.0.0.beta.1"
|
||||
end
|
@ -1,6 +1,6 @@
|
||||
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
||||
|
||||
describe Lemonade do
|
||||
describe Compass::Sprites do
|
||||
|
||||
before :each do
|
||||
@sprite = {
|
||||
@ -13,14 +13,14 @@ describe Lemonade do
|
||||
|
||||
@file = ""
|
||||
File.stub!(:read => @file)
|
||||
Lemonade.stub(:images_path).and_return('image_path')
|
||||
Compass::Sprites.stub(:images_path).and_return('image_path')
|
||||
File.stub!(:ctime => Time.parse('2010-01-01 12:00'))
|
||||
end
|
||||
|
||||
###
|
||||
|
||||
describe '#remember_sprite_info' do
|
||||
subject { Lemonade }
|
||||
subject { Compass::Sprites }
|
||||
|
||||
it 'should save sprite info into a file' do
|
||||
File.should_receive(:open).with(File.join('image_path', 'the_sprite.sprite_info.yml'), 'w').and_yield(@file)
|
||||
@ -32,7 +32,7 @@ describe Lemonade do
|
||||
###
|
||||
|
||||
describe '#sprite_changed?' do
|
||||
subject { Lemonade }
|
||||
subject { Compass::Sprites }
|
||||
|
||||
it 'should be false if nothing changed' do
|
||||
File.should_receive(:open).and_yield(@file)
|
||||
|
@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
||||
describe Sass::Script::Functions do
|
||||
|
||||
before :each do
|
||||
Lemonade.reset
|
||||
Compass::Sprites.reset
|
||||
FileUtils.cp_r File.dirname(__FILE__) + '/images', IMAGES_TMP_PATH
|
||||
end
|
||||
|
||||
|
@ -7,7 +7,7 @@ require 'spec'
|
||||
require 'spec/autorun'
|
||||
|
||||
IMAGES_TMP_PATH = File.join(File.dirname(__FILE__), 'images-tmp')
|
||||
Lemonade.images_path = IMAGES_TMP_PATH
|
||||
Compass::Sprites.images_path = IMAGES_TMP_PATH
|
||||
|
||||
Spec::Runner.configure do |config|
|
||||
|
||||
|
@ -20,7 +20,7 @@ describe Sass::Script::SpriteInfo do
|
||||
sprite_item = { :y => Sass::Script::Number.new(20, ['px']), :index => 1 }
|
||||
x = Sass::Script::Number.new(10, ['px'])
|
||||
sprite_info(:position, sprite, sprite_item, x).should ==
|
||||
"10px <%= Lemonade.sprites['sprites.png'][:images][1][:y].unary_minus %>"
|
||||
"10px <%= Compass::Sprites.sprites['sprites.png'][:images][1][:y].unary_minus %>"
|
||||
end
|
||||
|
||||
it "should output the position with y shift" do
|
||||
@ -29,7 +29,7 @@ describe Sass::Script::SpriteInfo do
|
||||
x = Sass::Script::Number.new(10, ['px'])
|
||||
y_shift = Sass::Script::Number.new(3, ['px'])
|
||||
sprite_info(:position, sprite, sprite_item, x, y_shift).should ==
|
||||
"10px <%= Lemonade.sprites['sprites.png'][:images][1][:y].unary_minus.plus(Sass::Script::Number.new(3, ['px'])) %>"
|
||||
"10px <%= Compass::Sprites.sprites['sprites.png'][:images][1][:y].unary_minus.plus(Sass::Script::Number.new(3, ['px'])) %>"
|
||||
end
|
||||
|
||||
it "should output the position with percentage" do
|
||||
@ -37,7 +37,7 @@ describe Sass::Script::SpriteInfo do
|
||||
sprite_item = { :y => Sass::Script::Number.new(20, ['px']), :index => 2 }
|
||||
x = Sass::Script::Number.new(100, ['%'])
|
||||
sprite_info(:position, sprite, sprite_item, x).should ==
|
||||
"100% <%= Lemonade.sprites['sprites.png'][:images][2][:y].unary_minus %>"
|
||||
"100% <%= Compass::Sprites.sprites['sprites.png'][:images][2][:y].unary_minus %>"
|
||||
end
|
||||
|
||||
it "should output the url" do
|
||||
|
Loading…
Reference in New Issue
Block a user