lib/munge/cli/commands/clean.rb in munge-0.18.0 vs lib/munge/cli/commands/clean.rb in munge-0.19.0
- old
+ new
@@ -4,57 +4,52 @@
# This class is used by the CLI to build and calculate output
class Clean
def initialize(bootloader, dry_run:, reporter:, verbosity:, build_root: nil)
destination_root = bootloader.root_path
config = bootloader.config
- app = application(bootloader)
destination = File.expand_path(build_root || config[:output_path], destination_root)
- @dry_run = dry_run
- io = Munge::Io::DryRun.new(Munge::Io::Filesystem.new)
+ memory = Munge::Vfs::Memory.new
+ vfs = new_vfs(dry_run, destination)
+ loader = Munge::Load.new(bootloader.root_path)
+
@runner =
- Munge::Runner.new(
- items: app.vomit(:items),
- router: app.vomit(:router),
- processor: app.vomit(:processor),
- io: io,
- reporter: Munge::Reporter.new(formatter: formatter("Silent"), verbosity: :silent),
- destination: destination,
- manager: Munge::WriteManager::All.new(io)
- )
+ loader.app do |_application, conglomerate|
+ Munge::Function::Write.new(
+ conglomerate: conglomerate,
+ reporter: Munge::Reporter.new(formatter: formatter("Silent"), verbosity: :silent),
+ manager: Munge::WriteManager::All.new(memory),
+ destination: memory
+ ).call
+ Munge::Function::Clean.new(
+ memory: memory,
+ destination: vfs
+ )
+ end
+
@output_path = File.expand_path(build_root || config[:output_path], destination_root)
end
def call
- io =
- if @dry_run
- Munge::Io::DryRun.new(Munge::Io::Filesystem.new)
- else
- Munge::Io::Filesystem.new
- end
-
- cleaner =
- Munge::Cleaner.new(
- path_to_clean: @output_path,
- paths_to_write: @runner.write,
- io: io
- )
-
- cleaner.delete
+ @runner.call
end
private
- def application(bootloader)
- bootstrap = bootloader.init
-
- bootstrap.app
+ def formatter(class_name)
+ Munge::Formatter.const_get(class_name).new
end
- def formatter(class_name)
- Munge::Formatters.const_get(class_name).new
+ def new_vfs(dry_run, destination)
+ fs = Munge::Vfs::Filesystem.new(destination)
+
+ if dry_run
+ Munge::Vfs::DryRun.new(fs)
+ else
+ fs
+ end
end
end
end
end
end