class S3AssetsUploader::Config
Constants
- DEFAULT_ASSETS_PATH
- DEFAULT_CACHE_CONTROL
Public Class Methods
new()
click to toggle source
# File lib/s3_assets_uploader/config.rb, line 11 def initialize self.assets_path = DEFAULT_ASSETS_PATH self.cache_control = DEFAULT_CACHE_CONTROL self.additional_paths = [] self.content_type = nil end
Public Instance Methods
assets_path()
click to toggle source
# File lib/s3_assets_uploader/config.rb, line 18 def assets_path Pathname.new(self[:assets_path]) end
content_type(&block)
click to toggle source
# File lib/s3_assets_uploader/config.rb, line 37 def content_type(&block) self[:content_type] = block end
guess_content_type(path)
click to toggle source
# File lib/s3_assets_uploader/config.rb, line 41 def guess_content_type(path) return unless self[:content_type] self[:content_type].call(path) end
public_path()
click to toggle source
# File lib/s3_assets_uploader/config.rb, line 22 def public_path assets_path.parent end
validate!()
click to toggle source
# File lib/s3_assets_uploader/config.rb, line 26 def validate! if bucket.nil? raise ValidationError.new('config.bucket must be set') end additional_paths.each do |path| assert_under_public_path!(path) end self.s3_client ||= create_default_client true end
Private Instance Methods
assert_under_public_path!(path)
click to toggle source
# File lib/s3_assets_uploader/config.rb, line 53 def assert_under_public_path!(path) if Pathname.new(path).relative_path_from(public_path).to_s.start_with?('../') raise ValidationError.new("#{path} must be under #{public_path}") end true end
create_default_client()
click to toggle source
# File lib/s3_assets_uploader/config.rb, line 49 def create_default_client Aws::S3::Client.new end