Class: Bard::Backup::FileTree
- Inherits:
-
Object
- Object
- Bard::Backup::FileTree
- Defined in:
- lib/bard/backup/file_tree.rb
Constant Summary collapse
- MANIFEST_PATH =
".bard-file-tree-sync.json"- DEFAULT_BUCKET =
"bard-data"
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(s3_tree, data_paths) ⇒ FileTree
constructor
A new instance of FileTree.
Constructor Details
#initialize(s3_tree, data_paths) ⇒ FileTree
Returns a new instance of FileTree.
24 25 26 27 |
# File 'lib/bard/backup/file_tree.rb', line 24 def initialize(s3_tree, data_paths) @s3_tree = s3_tree @data_paths = data_paths end |
Class Method Details
.create!(data_paths: nil, project_name: nil, bucket: DEFAULT_BUCKET, **s3_config) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/bard/backup/file_tree.rb', line 11 def self.create!(data_paths: nil, project_name: nil, bucket: DEFAULT_BUCKET, **s3_config) = defined?(Bard::Config) ? Bard::Config.current : nil data_paths ||= &.data || [] project_name ||= &.project_name return if data_paths.empty? encryption_key = s3_config.delete(:encryption_key) encryption_key ||= &.respond_to?(:encryption_key) ? .encryption_key : nil s3_tree = S3Tree.new(path: "#{bucket}/#{project_name}", encryption_key: encryption_key, **s3_config) new(s3_tree, data_paths).call end |
Instance Method Details
#call ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bard/backup/file_tree.rb', line 29 def call manifest = load_manifest local_files = collect_local_files if manifest.empty? sync_from_s3(local_files) else sync_from_manifest(local_files, manifest) end end |