Skip to content

Commit

Permalink
Merge pull request #302 from josacar/master
Browse files Browse the repository at this point in the history
Support for fog_path_style config option
  • Loading branch information
PikachuEXE committed Apr 25, 2016
2 parents a1523df + d5f1485 commit d9a5921
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ AssetSync.config.gzip_compression == ENV['ASSET_SYNC_GZIP_COMPRESSION']
#### Fog (Optional)
* **fog\_region**: the region your storage bucket is in e.g. *eu-west-1*
* **fog\_path\_style**: To use buckets with dot in names, check https://github.com/fog/fog/issues/2381#issuecomment-28088524
#### AWS
Expand Down
3 changes: 3 additions & 0 deletions lib/asset_sync/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Invalid < StandardError; end
attr_accessor :fog_provider # Currently Supported ['AWS', 'Rackspace']
attr_accessor :fog_directory # e.g. 'the-bucket-name'
attr_accessor :fog_region # e.g. 'eu-west-1'
attr_accessor :fog_path_style # e.g true

# Amazon AWS
attr_accessor :aws_access_key_id, :aws_secret_access_key, :aws_reduced_redundancy, :aws_iam_roles
Expand Down Expand Up @@ -139,6 +140,7 @@ def load_yml!
self.fog_provider = yml["fog_provider"]
self.fog_directory = yml["fog_directory"]
self.fog_region = yml["fog_region"]
self.fog_path_style = yml["fog_path_style"]
self.aws_access_key_id = yml["aws_access_key_id"]
self.aws_secret_access_key = yml["aws_secret_access_key"]
self.aws_reduced_redundancy = yml["aws_reduced_redundancy"]
Expand Down Expand Up @@ -207,6 +209,7 @@ def fog_options
end

options.merge!({:region => fog_region}) if fog_region && !rackspace?
options.merge!({:path_style => fog_path_style}) if fog_path_style && aws?
return options
end

Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/aws_with_yml/config/asset_sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defaults: &defaults
aws_secret_access_key: "zzzz"
region: "eu-west-1"
run_on_precompile: false
fog_path_style: true

development:
<<: *defaults
Expand Down
9 changes: 9 additions & 0 deletions spec/unit/asset_sync_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
config.aws_secret_access_key = 'bbbb'
config.fog_directory = 'mybucket'
config.fog_region = 'eu-west-1'
config.fog_path_style = 'true'
config.existing_remote_files = "keep"
end
end
Expand Down Expand Up @@ -50,6 +51,10 @@
expect(AssetSync.config.fog_region).to eq("eu-west-1")
end

it "should configure path_style" do
expect(AssetSync.config.fog_path_style).to be_truthy
end

it "should configure existing_remote_files" do
expect(AssetSync.config.existing_remote_files).to eq("keep")
end
Expand Down Expand Up @@ -118,6 +123,10 @@
expect(AssetSync.config.fog_region).to eq("eu-west-1")
end

it "should configure path_style" do
expect(AssetSync.config.fog_path_style).to be_truthy
end

it "should configure existing_remote_files" do
expect(AssetSync.config.existing_remote_files).to eq("keep")
end
Expand Down

0 comments on commit d9a5921

Please sign in to comment.