Class: S3ckup::Manifest
- Inherits:
-
Object
- Object
- S3ckup::Manifest
- Defined in:
- lib/s3ckup/manifest.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #-(manifest) ⇒ Object
- #diff(manifest) ⇒ Object
- #file_list ⇒ Object
-
#initialize(*args) ⇒ Manifest
constructor
A new instance of Manifest.
- #to_yaml ⇒ Object
Constructor Details
#initialize(*args) ⇒ Manifest
Returns a new instance of Manifest.
8 9 10 11 12 13 14 |
# File 'lib/s3ckup/manifest.rb', line 8 def initialize(*args) if args.first.is_a?(Hash) @files = args.first else @files = create_manifest(Array(args).flatten) end end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
6 7 8 |
# File 'lib/s3ckup/manifest.rb', line 6 def files @files end |
Instance Method Details
#-(manifest) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/s3ckup/manifest.rb', line 24 def -(manifest) raise ArgumentError unless manifest.is_a?(Manifest) remaining_files = file_list - manifest.file_list remaining_files = @files.clone.keep_if { |file| remaining_files.include?(file) } Manifest.new(remaining_files) end |
#diff(manifest) ⇒ Object
31 32 33 34 |
# File 'lib/s3ckup/manifest.rb', line 31 def diff(manifest) files_to_upload = @files.to_a - manifest.files.to_a Manifest.new(Hash[*files_to_upload.flatten]) end |
#file_list ⇒ Object
20 21 22 |
# File 'lib/s3ckup/manifest.rb', line 20 def file_list @files.keys.sort end |
#to_yaml ⇒ Object
16 17 18 |
# File 'lib/s3ckup/manifest.rb', line 16 def to_yaml @files.to_yaml end |