Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Remove whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
sikachu committed Jun 15, 2012
1 parent d46a1af commit e90de5d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions lib/paperclip/storage/fog.rb
Expand Up @@ -119,14 +119,14 @@ def public_url(style = default_style)
end
end
end

def expiring_url(time = 3600, style = default_style)
expiring_url = directory.files.get_http_url(path(style), time)

if @options[:fog_host]
expiring_url.gsub!(/#{host_name_for_directory}/, dynamic_fog_host_for_style(style))
end

return expiring_url
end

Expand All @@ -148,20 +148,20 @@ def copy_to_local_file(style, local_dest_path)
end

private

def dynamic_fog_host_for_style(style)
if @options[:fog_host].respond_to?(:call)
@options[:fog_host].call(self)
else
(@options[:fog_host] =~ /%d/) ? @options[:fog_host] % (path(style).hash % 4) : @options[:fog_host]
end
end

def host_name_for_directory
if @options[:fog_directory].to_s =~ Fog::AWS_BUCKET_SUBDOMAIN_RESTRICTON_REGEX
# This:
"#{@options[:fog_directory]}."

# Should be modified to this:
# "#{@options[:fog_directory]}.s3.amazonaws.com"
# When fog with https://github.com/fog/fog/pull/857 gets released
Expand Down
18 changes: 9 additions & 9 deletions test/storage/fog_test.rb
Expand Up @@ -208,7 +208,7 @@ class FogTest < Test::Unit::TestCase
# For now, use this passing one:
assert_match /^https:\/\/papercliptests.\/avatars\/5k.png\?\d*$/, @dummy.avatar.url
end

should "provide an url that expires in subdomain style" do
# The following line is the correct one when this pull request in Fog is released:
# https://github.com/fog/fog/pull/857
Expand Down Expand Up @@ -236,7 +236,7 @@ class FogTest < Test::Unit::TestCase
should "provide an url in folder style" do
assert_match /^https:\/\/s3.amazonaws.com\/this_is_invalid\/avatars\/5k.png\?\d*$/, @dummy.avatar.url
end

should "provide a url that expires in folder style" do
assert_match /^http:\/\/s3.amazonaws.com\/this_is_invalid\/avatars\/5k.png\?AWSAccessKeyId=.+$/, @dummy.avatar.expiring_url
end
Expand Down Expand Up @@ -271,38 +271,38 @@ class FogTest < Test::Unit::TestCase
should "provide a public url" do
assert_match /http:\/\/dynamicfoghost\.com/, @dummy.avatar.url
end

end

context "with a custom fog_host" do
setup do
rebuild_model(@options.merge(:fog_host => "http://dynamicfoghost.com"))
@dummy = Dummy.new
@dummy.avatar = @file
@dummy.save
end

should "provide a public url" do
assert_match /http:\/\/dynamicfoghost\.com/, @dummy.avatar.url
end

should "provide an expiring url" do
assert_match /http:\/\/dynamicfoghost\.com/, @dummy.avatar.expiring_url
end

context "with an invalid bucket name for a subdomain" do
setup do
rebuild_model(@options.merge({:fog_directory => "this_is_invalid", :fog_host => "http://dynamicfoghost.com"}))
@dummy = Dummy.new
@dummy.avatar = @file
@dummy.save
end

should "provide an expiring url" do
assert_match /http:\/\/dynamicfoghost\.com/, @dummy.avatar.expiring_url
end
end

end

context "with a proc for the fog_credentials evaluating a model method" do
Expand Down

6 comments on commit e90de5d

@mhuggins
Copy link

Choose a reason for hiding this comment

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

Oh man, you are my arch nemesis. I am OCD about making sure the tabs are there on blank lines so that they match the indentation of the surrounding lines. ;)

@sikachu
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hahahaha. I actually have a script to highlight the whitespaces in the file, and those whitespaces bugged me >_<

@mike-burns
Copy link
Member

Choose a reason for hiding this comment

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

@mhuggins That makes it so you can't use { and } to jump between paragraphs!

@mhuggins
Copy link

Choose a reason for hiding this comment

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

@mike-burns What IDE are you talking about? I've never had any issues.

@mike-burns
Copy link
Member

Choose a reason for hiding this comment

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

@mhuggins vim. Which IDE do you use?

@mhuggins
Copy link

Choose a reason for hiding this comment

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

TextMate. :) Can't stand vim. :P

Please sign in to comment.