Class: Nanoc::Deploying::Deployers::Fog Private

Inherits:
Nanoc::Deploying::Deployer show all
Defined in:
lib/nanoc/deploying/deployers/fog.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A deployer that deploys a site using [fog](github.com/fog/fog).

Examples:

A deployment configuration with public and staging configurations


deploy:
  public:
    kind:       fog
    bucket:     nanoc-site
    cdn_id:     XXXXXX
  preprod:
    kind:       fog
    provider:   local
    local_root: ~/myCloud
    bucket:     nanoc-site
  staging:
    kind:       fog
    provider:   local
    local_root: ~/myCloud
    bucket:     nanoc-site-staging

Defined Under Namespace

Classes: FogWrapper

Instance Attribute Summary

Attributes inherited from Nanoc::Deploying::Deployer

#config, #dry_run, #source_path

Instance Method Summary collapse

Methods inherited from Nanoc::Deploying::Deployer

#initialize

Constructor Details

This class inherits a constructor from Nanoc::Deploying::Deployer

Instance Method Details

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/nanoc/deploying/deployers/fog.rb', line 86

def run
  require 'fog/core'

  src      = File.expand_path(source_path)
  bucket   = config[:bucket] || config[:bucket_name]
  path     = config[:path]
  cdn_id   = config[:cdn_id]

  if path&.end_with?('/')
    raise "The path `#{path}` is not supposed to have a trailing slash"
  end

  connection = connect
  directory = get_or_create_bucket(connection, bucket, path)
  wrapper = FogWrapper.new(directory, dry_run?)

  remote_files = list_remote_files(directory)
  etags = read_etags(remote_files)

  modified_keys, retained_keys = upload_all(src, path, etags, wrapper)

  removed_keys = remote_files.map(&:key) - retained_keys - modified_keys
  wrapper.remove(removed_keys)

  if cdn_id
    cdn = ::Fog::CDN.new(config_for_fog)
    distribution = cdn.get_distribution(cdn_id)
    wrapper.invalidate(modified_keys + removed_keys, cdn, distribution)
  end
end