Merge branch 'master' of github.com:chriseppstein/compass

This commit is contained in:
Scott Davis 2011-10-05 02:06:48 -04:00
commit 4fba9604eb
17 changed files with 93 additions and 45 deletions

View File

@ -2,7 +2,7 @@ source :rubygems
gemspec
gem "cucumber", "~> 0.9.2"
gem "cucumber", "~> 1.1.0"
gem "rspec", "~>2.0.0"
gem "rails", "~>3.0.0.rc"
gem "compass-validator", "3.0.1"
@ -18,6 +18,6 @@ gem 'mocha'
gem 'timecop'
gem 'diff-lcs', '~> 1.1.2'
gem 'rake', '0.8.7'
gem 'rake', '~> 0.9.2'
#Warning becarful adding OS dependant gems to this file it will cause issues on the CI server

View File

@ -1,7 +1,7 @@
PATH
remote: .
specs:
compass (0.12.0.alpha.0.91a748a)
compass (0.12.alpha.0.d794394)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
@ -39,16 +39,16 @@ GEM
addressable (2.2.6)
arel (2.0.10)
builder (2.1.2)
chunky_png (1.2.1)
chunky_png (1.2.5)
compass-validator (3.0.1)
css_parser (1.0.1)
cucumber (0.9.4)
builder (~> 2.1.2)
diff-lcs (~> 1.1.2)
gherkin (~> 2.2.9)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
diff-lcs (1.1.2)
cucumber (1.1.0)
builder (>= 2.1.2)
diff-lcs (>= 1.1.2)
gherkin (~> 2.5.0)
json (>= 1.4.6)
term-ansicolor (>= 1.0.6)
diff-lcs (1.1.3)
em-dir-watcher (0.9.4)
em-websocket (0.3.1)
addressable (>= 2.1.1)
@ -57,12 +57,11 @@ GEM
abstract (>= 1.0.0)
eventmachine (0.12.10)
fssm (0.2.7)
gherkin (2.2.9)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
haml (3.1.2)
gherkin (2.5.1)
json (>= 1.4.6)
haml (3.1.3)
i18n (0.5.0)
json (1.4.6)
json (1.6.1)
livereload (1.6)
em-dir-watcher (>= 0.1)
em-websocket (>= 0.1.2)
@ -72,10 +71,12 @@ GEM
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
mime-types (1.16)
mocha (0.9.12)
mocha (0.10.0)
metaclass (~> 0.0.1)
polyglot (0.3.2)
rack (1.2.3)
rack (1.2.4)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
@ -94,9 +95,9 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.4)
rake (0.8.7)
rake (0.9.2)
rcov (0.9.10)
rdoc (3.9.2)
rdoc (3.9.4)
rspec (2.0.1)
rspec-core (~> 2.0.1)
rspec-expectations (~> 2.0.1)
@ -126,13 +127,13 @@ DEPENDENCIES
compass!
compass-validator (= 3.0.1)
css_parser (~> 1.0.1)
cucumber (~> 0.9.2)
cucumber (~> 1.1.0)
diff-lcs (~> 1.1.2)
haml (~> 3.1)
livereload
mocha
rails (~> 3.0.0.rc)
rake (= 0.8.7)
rake (~> 0.9.2)
rcov
rspec (~> 2.0.0)
ruby-prof

View File

@ -1,6 +1,7 @@
require 'rubygems'
require 'bundler'
Bundler.setup
require 'rake/dsl_definition' rescue nil
require 'compass'
# ----- Default: Testing ------

View File

@ -36,5 +36,5 @@ if ARGV.delete("--profile")
printer.print(STDERR, 0)
exit exit_code
else
exit runner.call
exit runner.call || 0
end

View File

@ -20,6 +20,8 @@ The Documentation for the [latest preview release](http://beta.compass-style.org
* font-files helper: Stop requiring font type when the type can be guessed from URL
* inline-font-files: actually works now
* Upgrade CSS3 Pie to 1.0beta5
* log sprite generation and removal to the console
* Added a new helper function `compass-env()` that returns the current compass environment (development, production)
0.12.alpha.0 (8/30/2011)

View File

@ -46,18 +46,3 @@
}
}
}
// EXAMPLE
// +font-face("this name", font-files("this.woff", "woff", "this.otf", "opentype"), "this.eot", bold, italic)
//
// will generate:
//
// @font-face {
// font-family: 'this name';
// src: url('fonts/this.eot');
// src: local(""),
// url('fonts/this.otf') format('woff'),
// url('fonts/this.woff') format('opentype');
// font-weight: bold;
// font-style: italic;
// }

View File

@ -8,7 +8,7 @@ end
module Compass::RailsImageFunctionPatch
private
def image_path(image_file)
def image_path_for_size(image_file)
if file = ::Rails.application.assets.find_asset(image_file)
return file
end

View File

@ -17,6 +17,7 @@ module Compass
self.sass_options[:importer] = self.importer = Sass::Importers::Filesystem.new(from)
self.sass_options[:compass] ||= {}
self.sass_options[:compass][:logger] = self.logger
self.sass_options[:compass][:environment] = Compass.configuration.environment
self.staleness_checker = Sass::Plugin::StalenessChecker.new(sass_options)
end

View File

@ -38,6 +38,12 @@ module Compass
define_callback :sprite_generated
chained_method :run_sprite_generated
# on_sprite_removed
# yields the filename
# usage: on_sprite_removed {|filename| do_something(filename) }
define_callback :sprite_removed
chained_method :run_sprite_removed
# on_stylesheet_saved
# yields the filename
# usage: on_stylesheet_saved {|filename| do_something(filename) }

View File

@ -4,7 +4,8 @@ end
%w(
selectors enumerate urls display
inline_image image_size constants gradient_support
font_files lists colors trig sprites cross_browser_support
font_files lists colors trig
sprites env cross_browser_support
).each do |func|
require "compass/sass_extensions/functions/#{func}"
end
@ -24,6 +25,7 @@ module Sass::Script::Functions
include Compass::SassExtensions::Functions::Trig
include Compass::SassExtensions::Functions::Sprites
include Compass::SassExtensions::Functions::CrossBrowserSupport
include Compass::SassExtensions::Functions::Env
end
# Wierd that this has to be re-included to pick up sub-modules. Ruby bug?

View File

@ -0,0 +1,5 @@
module Compass::SassExtensions::Functions::Env
def compass_env
Sass::Script::String.new((options[:compass][:environment] || "development").to_s)
end
end

View File

@ -120,6 +120,8 @@ module Compass::SassExtensions::Functions::Sprites
#
# background-position: 3px -36px;
def sprite_position(map, sprite = nil, offset_x = ZERO, offset_y = ZERO)
assert_type offset_x, :Number
assert_type offset_y, :Number
sprite = convert_sprite_name(sprite)
verify_map(map, "sprite-position")
unless sprite && sprite.is_a?(Sass::Script::String)

View File

@ -60,20 +60,21 @@ module Compass
Compass.configuration.run_sprite_generated(engine.canvas)
save!
else
options[:compass][:logger].record(:unchanged, relativize(filename))
log :unchanged, filename
end
end
def cleanup_old_sprites
Dir[File.join(Compass.configuration.images_path, "#{path}-*.png")].each do |file|
options[:compass][:logger].record(:remove, relativize(file))
log :remove, file
FileUtils.rm file
Compass.configuration.run_sprite_removed(file)
end
end
# Does this sprite need to be generated
def generation_required?
!File.exists?(filename) || outdated?
!File.exists?(filename) || outdated? || options[:force]
end
# Returns the uniqueness hash for this sprite object
@ -97,7 +98,7 @@ module Compass
def save!
FileUtils.mkdir_p(File.dirname(filename))
saved = engine.save(filename)
options[:compass][:logger].record(:create, relativize(filename))
log :create, filename
Compass.configuration.run_sprite_saved(filename)
saved
end
@ -125,6 +126,11 @@ module Compass
[width, height]
end
def log(action, filename, *extra)
if options[:compass] && options[:compass][:logger] && !options[:quiet]
options[:compass][:logger].record(action, relativize(filename), *extra)
end
end
end
end
end

View File

@ -0,0 +1,9 @@
# Require any additional compass plugins here.
project_type = :stand_alone
css_dir = "tmp"
sass_dir = "sass"
images_dir = "images"
output_style = :nested
line_comments = false
disable_warnings = true

View File

@ -0,0 +1,2 @@
.env {
env: <%= options[:environment] %>; }

View File

@ -0,0 +1,3 @@
.env {
env: compass-env();
}

View File

@ -73,6 +73,28 @@ class CompassTest < Test::Unit::TestCase
end
end
def test_env_in_development
within_project('envtest', lambda {|c| c.environment = :development }) do |proj|
each_css_file(proj.css_path) do |css_file|
assert_no_errors css_file, 'envtest'
end
each_sass_file do |sass_file|
assert_renders_correctly sass_file, :ignore_charset => true, :environment => "development"
end
end
end
def test_env_in_production
within_project('envtest', lambda {|c| c.environment = :production }) do |proj|
each_css_file(proj.css_path) do |css_file|
assert_no_errors css_file, 'envtest'
end
each_sass_file do |sass_file|
assert_renders_correctly sass_file, :ignore_charset => true, :environment => "production"
end
end
end
def test_busted_image_urls
within_project('busted_image_urls') do |proj|
each_css_file(proj.css_path) do |css_file|
@ -150,6 +172,7 @@ private
if Compass.configuration.sass_path && File.exists?(Compass.configuration.sass_path)
compiler = Compass::Compiler.new *args
compiler.clean!
compiler.run
end
yield Compass.configuration if block_given?