Sha256: cad552f04a4a47dd98368e52a2ab8f4600aab1c2bd143ca8e8fb1d1d7ab79c5b

Contents?: true

Size: 1.41 KB

Versions: 24

Compression:

Stored size: 1.41 KB

Contents

module S3Website
  class Tasks
    def self.push(config_file_dir, site_dir, in_headless_mode = false)
      ConfigLoader.check_project site_dir
      ConfigLoader.check_s3_configuration config_file_dir
      config = S3Website::ConfigLoader.load_configuration config_file_dir
      new_files_count, changed_files_count, deleted_files_count, changed_files, changed_redirects =
        Uploader.run(site_dir, config, in_headless_mode)
      invalidated_items_count =
        invalidate_cf_dist_if_configured(config, changed_files + changed_redirects)
      {
        :new_files_count => new_files_count,
        :changed_files_count => changed_files_count,
        :deleted_files_count => deleted_files_count,
        :invalidated_items_count => invalidated_items_count,
        :changed_redirects_count => changed_redirects.size
      }
    rescue S3WebsiteError => e
      puts e.message
      exit 1
    end

    def self.config_create(dir)
      ConfigLoader.check_s3_configuration dir
    rescue S3WebsiteError => e
      puts e.message
      exit 1
    end

    private

    def self.invalidate_cf_dist_if_configured(config, changed_files)
      cloudfront_configured = config['cloudfront_distribution_id'] &&
        (not config['cloudfront_distribution_id'].empty?)
      invalidated_items_count = if cloudfront_configured
        Cloudfront::Invalidator.invalidate(config, changed_files)
      else
        0
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
s3_website-1.6.2 lib/s3_website/tasks.rb
s3_website-1.6.1 lib/s3_website/tasks.rb
s3_website-1.6.0 lib/s3_website/tasks.rb
s3_website-1.5.0 lib/s3_website/tasks.rb
s3_website-1.4.5 lib/s3_website/tasks.rb
s3_website-1.4.4 lib/s3_website/tasks.rb
s3_website-1.4.3 lib/s3_website/tasks.rb
s3_website-1.4.2 lib/s3_website/tasks.rb
s3_website-1.4.1 lib/s3_website/tasks.rb
s3_website-1.4.0 lib/s3_website/tasks.rb
s3_website-1.3.2 lib/s3_website/tasks.rb
s3_website-1.3.1 lib/s3_website/tasks.rb
s3_website-1.3.0 lib/s3_website/tasks.rb
s3_website-1.2.1 lib/s3_website/tasks.rb
s3_website-1.2.0 lib/s3_website/tasks.rb
s3_website-1.1.2 lib/s3_website/tasks.rb
s3_website-1.1.1 lib/s3_website/tasks.rb
s3_website-1.1.0 lib/s3_website/tasks.rb
s3_website-1.0.3 lib/s3_website/tasks.rb
s3_website-1.0.2 lib/s3_website/tasks.rb