Binary mode support for proper handling of binary files on Windows.

All images will now be installed using binary mode. Additionally, any file can
be installed in binary mode if the manifest specifies the option :binary => true
for that file.
This commit is contained in:
Chris Eppstein 2009-08-16 11:17:27 -07:00
parent e6ea58fc3a
commit 0492fc9969
4 changed files with 22 additions and 8 deletions

View File

@ -1,14 +1,23 @@
COMPASS CHANGELOG
=================
0.8.10 (August 16, 2009)
------------------------
Bug Fix Release:
* Write files in binary mode to avoid data corruption when installing images on windows.
Fixes [Issue #39](http://github.com/chriseppstein/compass/issues/#issue/39)
0.8.9 (August 9, 2009)
----------------------
Bug Fix Release:
* [Blueprint] The default screen.sass generated invalid selectors due to improper nesting. A better fix is coming in the next release.
0.8.8 (July 21, 2009)
---------------------
Bug Fix Release:
* [Compass Core] Fixed a bug in alternating_rows_and_columns. Improper nesting caused some styles to be improperly rendered.
[Commit](http://github.com/chriseppstein/compass/commit/e277ed2cd3fded0b98ddaa87fc4d3b9d37cb7354)
* [YUI] Fixed a bug in yui grids where the .first div wouldn't get the right styles in some rare cases due to incorrect nesting.
@ -19,6 +28,7 @@ Bug Fix Release:
---------------------
Bug Fix Release:
* Load haml-edge only if it's all new and shiny. Closes GH-26.
[Commit](http://github.com/chriseppstein/compass/commit/59a6067b3a67a79bfd9a5ce325fc1be4bb6c9e78)
* [Blueprint] Added more descriptive comments to the Blueprint IE template.

View File

@ -1,4 +1,4 @@
---
:patch: 9
:patch: 10
:major: 0
:minor: 8

View File

@ -8,10 +8,10 @@ module Compass
end
# copy/process a template in the compass template directory to the project directory.
def copy(from, to, options = nil)
def copy(from, to, options = nil, binary = false)
options ||= self.options if self.respond_to?(:options)
contents = File.new(from).read
write_file to, contents, options
write_file to, contents, options, binary
end
# create a directory and all the directories necessary to reach it.
@ -29,7 +29,7 @@ module Compass
end
# Write a file given the file contents as a string
def write_file(file_name, contents, options = nil)
def write_file(file_name, contents, options = nil, binary = false)
options ||= self.options if self.respond_to?(:options)
skip_write = options[:dry_run]
if File.exists?(file_name)
@ -49,7 +49,9 @@ module Compass
if skip_write
FileUtils.touch file_name
else
open(file_name,'w') do |file|
mode = "w"
mode << "b" if binary
open(file_name, mode) do |file|
file.write(contents)
end
end

View File

@ -87,7 +87,7 @@ module Compass
"#{options[:pattern_name]}/" if options[:pattern_name]
end
def self.installer(type, &locator)
def self.installer(type, installer_opts = {}, &locator)
locator ||= lambda{|to| to}
loc_method = "install_location_for_#{type}".to_sym
define_method("simple_#{loc_method}", locator)
@ -99,7 +99,9 @@ module Compass
end
end
define_method "install_#{type}" do |from, to, options|
copy templatize(from), targetize(send(loc_method, to, options))
from = templatize(from)
to = targetize(send(loc_method, to, options))
copy from, to, nil, (installer_opts[:binary] || options[:binary])
end
end
@ -111,7 +113,7 @@ module Compass
"#{css_dir}/#{to}"
end
installer :image do |to|
installer :image, :binary => true do |to|
"#{images_dir}/#{to}"
end