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

Inherits:
Object
  • Object
show all
Defined in:
lib/nanoc/deploying/deployers/fog.rb

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.

Instance Method Summary collapse

Constructor Details

#initialize(directory, is_dry_run) ⇒ FogWrapper

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.

Returns a new instance of FogWrapper.



31
32
33
34
# File 'lib/nanoc/deploying/deployers/fog.rb', line 31

def initialize(directory, is_dry_run)
  @directory = directory
  @is_dry_run = is_dry_run
end

Instance Method Details

#dry_run?Boolean

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.

Returns:

  • (Boolean)


72
73
74
# File 'lib/nanoc/deploying/deployers/fog.rb', line 72

def dry_run?
  @is_dry_run
end

#invalidate(keys, cdn, distribution) ⇒ Object

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.



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/nanoc/deploying/deployers/fog.rb', line 60

def invalidate(keys, cdn, distribution)
  keys.each_slice(1000) do |keys_slice|
    keys_slice.each do |key|
      log_effectful("invalidating #{key}")
    end

    unless dry_run?
      cdn.post_invalidation(distribution, keys_slice)
    end
  end
end

#log_effectful(str) ⇒ Object

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.



76
77
78
79
80
81
82
# File 'lib/nanoc/deploying/deployers/fog.rb', line 76

def log_effectful(str)
  if @is_dry_run
    puts "[dry run] #{str}"
  else
    puts str
  end
end

#remove(keys) ⇒ Object

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.



50
51
52
53
54
55
56
57
58
# File 'lib/nanoc/deploying/deployers/fog.rb', line 50

def remove(keys)
  keys.each do |key|
    log_effectful("removing #{key}")

    unless dry_run?
      @directory.files.get(key).destroy
    end
  end
end

#upload(source_filename, destination_key) ⇒ Object

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.



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/nanoc/deploying/deployers/fog.rb', line 36

def upload(source_filename, destination_key)
  log_effectful("uploading #{source_filename} -> #{destination_key}")

  unless dry_run?
    File.open(source_filename) do |io|
      @directory.files.create(
        key: destination_key,
        body: io,
        public: true,
      )
    end
  end
end