Class: MasterDelivery::CliMasterDelivery

Inherits:
Object
  • Object
show all
Defined in:
lib/cli_master_delivery.rb

Overview

command line wrapper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCliMasterDelivery

Returns a new instance of CliMasterDelivery.



82
83
84
# File 'lib/cli_master_delivery.rb', line 82

def initialize
  @params = { type: VALUE_DELIVERY_TYPE[0].to_sym, dryrun: false, quiet: false }
end

Instance Attribute Details

#paramsObject

rubocop:disable Metrics/ClassLength



80
81
82
# File 'lib/cli_master_delivery.rb', line 80

def params
  @params
end

Instance Method Details

#parse_optionsObject



86
87
88
89
90
91
# File 'lib/cli_master_delivery.rb', line 86

def parse_options
  OptionParser.new do |opts|
    opts = define_options(opts)
    opts.parse!(ARGV, into: @params)
  end
end

#runObject



93
94
95
96
97
98
99
100
101
102
103
# File 'lib/cli_master_delivery.rb', line 93

def run
  return unless check_param_consistency

  fix_param_paths(%i[master delivery backup])
  basics = delivery_basics
  md = MasterDelivery.new(basics[:master_dir], basics[:backup_root])
  return unless md.confirm(basics, @params.slice(:type, :quiet, :dryrun, :yes))

  mfiles, _tmpdir = md.deliver(basics, **@params.slice(:type, :dryrun, :verbose))
  puts "done! (#{mfiles.size} master files are delivered.)" unless @params[:quiet]
end