Permalink
Browse files

moved default location constraint logic from config_loader.rb to endp…

…oint.rb
  • Loading branch information...
1 parent c9b06d4 commit 3eec3f1fa2539ace2a27302019a0370d7e628a79 @adelevie adelevie committed with Apr 8, 2013
Showing with 14 additions and 7 deletions.
  1. +0 −1 lib/jekyll-s3/config_loader.rb
  2. +3 −1 lib/jekyll-s3/endpoint.rb
  3. +0 −5 spec/lib/config_loader_spec.rb
  4. +11 −0 spec/lib/endpoint_spec.rb
@@ -24,7 +24,6 @@ def self.check_s3_configuration(site_dir)
# Raise MalformedConfigurationFileError if the configuration file does not contain the keys we expect
def self.load_configuration(site_dir)
config = load_yaml_file_and_validate site_dir
- config['s3_endpoint'] = config['s3_endpoint'] || 'us-east-1'
return config
end
@@ -1,9 +1,11 @@
module Jekyll
module S3
class Endpoint
+ DEFAULT_LOCATION_CONSTRAINT = 'us-east-1'
attr_reader :region, :location_constraint, :hostname, :website_hostname
- def initialize(location_constraint)
+ def initialize(location_constraint=nil)
+ location_constraint = DEFAULT_LOCATION_CONSTRAINT if location_constraint.nil?
raise "Invalid S3 location constraint #{location_constraint}" unless
location_constraints.has_key?location_constraint
@region = location_constraints.fetch(location_constraint)[:region]
@@ -8,11 +8,6 @@
config['s3_bucket'].should eq('galaxy')
end
- it 'uses the "us-east-1" as the default endpoint' do
- config = Jekyll::S3::ConfigLoader.load_configuration('spec/sample_files/hyde_site/_site')
- config['s3_endpoint'].should eq('us-east-1')
- end
-
it 'reads the S3 endpoint setting from _jekyll_s3.yml' do
config = Jekyll::S3::ConfigLoader.load_configuration('spec/sample_files/tokyo_site/_site')
config['s3_endpoint'].should eq('ap-northeast-1')
View
@@ -0,0 +1,11 @@
+require 'spec_helper'
+require 'pp'
+
+describe Jekyll::S3::Endpoint do
+
+ it 'uses the "us-east-1" as the default location' do
+ endpoint = Jekyll::S3::Endpoint.new
+ endpoint.location_constraint.should eq(Jekyll::S3::Endpoint::DEFAULT_LOCATION_CONSTRAINT)
+ end
+
+end

0 comments on commit 3eec3f1

Please sign in to comment.