Class: Nanoc::Extra::Deployers::Fog::FogWrapper Private
- Inherits:
-
Object
- Object
- Nanoc::Extra::Deployers::Fog::FogWrapper
- Defined in:
- lib/nanoc/extra/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
- #dry_run? ⇒ Boolean private
-
#initialize(directory, is_dry_run) ⇒ FogWrapper
constructor
private
A new instance of FogWrapper.
- #invalidate(keys, cdn, distribution) ⇒ Object private
- #log_effectful(s) ⇒ Object private
- #remove(keys) ⇒ Object private
- #upload(source_filename, destination_key) ⇒ Object private
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.
25 26 27 28 |
# File 'lib/nanoc/extra/deployers/fog.rb', line 25 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.
65 66 67 |
# File 'lib/nanoc/extra/deployers/fog.rb', line 65 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.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/nanoc/extra/deployers/fog.rb', line 53 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(s) ⇒ 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.
69 70 71 72 73 74 75 |
# File 'lib/nanoc/extra/deployers/fog.rb', line 69 def log_effectful(s) if @is_dry_run puts "[dry run] #{s}" else puts s 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.
43 44 45 46 47 48 49 50 51 |
# File 'lib/nanoc/extra/deployers/fog.rb', line 43 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.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nanoc/extra/deployers/fog.rb', line 30 def upload(source_filename, destination_key) log_effectful("uploading #{source_filename} -> #{destination_key}") unless dry_run? # FIXME: source_filename file is never closed @directory.files.create( key: destination_key, body: File.open(source_filename), public: true, ) end end |