lib/cloudfront/invalidator.rb in s3_website-1.3.2 vs lib/cloudfront/invalidator.rb in s3_website-1.4.0

- old
+ new

@@ -2,21 +2,29 @@ module Cloudfront class Invalidator def self.invalidate(config, changed_files) aws_key = config['s3_id'] aws_secret = config['s3_secret'] - s3_bucket_name = config['s3_bucket'] cloudfront_distribution_id = config['cloudfront_distribution_id'] - s3 = AWS::S3.new( - :access_key_id => aws_key, - :secret_access_key => aws_secret) - s3_object_keys = changed_files + s3_object_keys = apply_config config, changed_files s3_object_keys << "" report = SimpleCloudfrontInvalidator::CloudfrontClient.new( - aws_key, aws_secret, cloudfront_distribution_id).invalidate( - s3_object_keys) + aws_key, aws_secret, cloudfront_distribution_id + ).invalidate(s3_object_keys) puts report[:text_report] report[:invalidated_items_count] + end + + private + + def self.apply_config(config, changed_files) + if config['cloudfront_invalidate_root'] + changed_files.map { |changed_file| + changed_file.sub /\/index.html$/, '/' + } + else + changed_files + end end end end end