From 0492fc99695bf8ec64cb64ca41b7451db9e01fcb Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sun, 16 Aug 2009 11:17:27 -0700 Subject: [PATCH] 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. --- CHANGELOG.markdown | 10 ++++++++++ VERSION.yml | 2 +- lib/compass/actions.rb | 10 ++++++---- lib/compass/installers/base.rb | 8 +++++--- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 4902ede2..2c3b6f2a 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -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. diff --git a/VERSION.yml b/VERSION.yml index d26333b8..d0062a44 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,4 @@ --- -:patch: 9 +:patch: 10 :major: 0 :minor: 8 diff --git a/lib/compass/actions.rb b/lib/compass/actions.rb index 960d6f55..3959f7a2 100644 --- a/lib/compass/actions.rb +++ b/lib/compass/actions.rb @@ -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 diff --git a/lib/compass/installers/base.rb b/lib/compass/installers/base.rb index 0a20c2e2..fb1e26c3 100644 --- a/lib/compass/installers/base.rb +++ b/lib/compass/installers/base.rb @@ -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