Skip to content

Commit

Permalink
Get deploy working for ruby 1.9.2
Browse files Browse the repository at this point in the history
When I tried running this in Ruby 1.9.2 I got the error:

undefined method `to_ruby' for #<Syck::Map:0x007fd625e11948>

This fixes that by using load_file which is supported across the
different ruby versions. (I've tested with 1.8.7, 1.9.2 and 1.9.3)
  • Loading branch information
thechrisoshow committed Aug 30, 2012
1 parent dfc1bc2 commit 0227b7d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/s3deploy.rb
@@ -1,7 +1,7 @@
require "s3deploy/version" require "s3deploy/version"
require "AWS/S3" require "AWS/S3"
require "digest/md5" require "digest/md5"
require "yaml" unless defined? YAML require "yaml"

This comment has been minimized.

Copy link
@lindblom

lindblom Aug 31, 2012

i had it like this before but got warnings that i tried to load yaml twice. But maybe that was just something with my system :)



class S3deploy class S3deploy


Expand Down Expand Up @@ -112,7 +112,7 @@ def upload_file(local, remote, simulate, options = {})
options[:access] = :public_read options[:access] = :public_read


if @options["cache_regex"] && remote =~ Regexp.new(@options["cache_regex"]) if @options["cache_regex"] && remote =~ Regexp.new(@options["cache_regex"])
options[:"Cache-Control"] = "public, max-age=31557600" options[:"Cache-Control"] = "public, max-age=31557600"
end end


options[:content_type] = "text/html; charset=#{@options["html_charset"]}" if @options["html_charset"] && remote =~ /.+\.(html|htm)(\.gz)?$/i options[:content_type] = "text/html; charset=#{@options["html_charset"]}" if @options["html_charset"] && remote =~ /.+\.(html|htm)(\.gz)?$/i
Expand Down Expand Up @@ -159,9 +159,9 @@ def all_files(path = ".")
end end
files files
end end

def import_settings(file) def import_settings(file)
settings = YAML::parse_file(file).to_ruby if File.file? file settings = YAML::load_file(file) if File.file? file
if settings && settings.class == Hash if settings && settings.class == Hash
settings.delete_if { |k,v| k != "aws_region" && v.nil? } settings.delete_if { |k,v| k != "aws_region" && v.nil? }
else else
Expand All @@ -172,7 +172,7 @@ def import_settings(file)
def set_aws_region(region) def set_aws_region(region)


unless AWS_REGIONS.include? region.downcase unless AWS_REGIONS.include? region.downcase
raise "#{region} is not a valid region, please select from #{AWS_REGIONS.join(", ")} or leave it blank for US Standard." raise "#{region} is not a valid region, please select from #{AWS_REGIONS.join(", ")} or leave it blank for US Standard."
end end


AWS::S3::DEFAULT_HOST.replace "s3-#{region}.amazonaws.com" AWS::S3::DEFAULT_HOST.replace "s3-#{region}.amazonaws.com"
Expand Down

2 comments on commit 0227b7d

@lindblom
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup, guess i have to make my editor show trailing whitespace. :)

@thechrisoshow
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use SublimeText - it's amazing. It makes for slightly annoying commits though!

Please sign in to comment.