1
0

Add command line program to process a file

This commit is contained in:
Tim Kächele 2024-08-25 10:16:28 +02:00
parent bf84952f56
commit 5fd48ead13

36
bin/process Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/setup'
require 'planet_express'
file = File.open(ARGV[0], "r")
shipping_option_repository = PlanetExpress::ShippingOptionRepository.new
shipment_repository = PlanetExpress::ShipmentRepository.new(data: [])
discount_budget_for_month_repository = PlanetExpress::DiscountBudgetForMonthRepository.new
shipment_reader = PlanetExpress::ShipmentReader.new(file, shipping_option_repository)
shipment_formatter = PlanetExpress::ShipmentFormatter.new
rules = [
PlanetExpress::SShipmentDiscountRule.new(
discount_budget_for_month_repository: discount_budget_for_month_repository,
shipping_option_repository: shipping_option_repository,
shipment_repository: shipment_repository
),
PlanetExpress::LShipmentDiscountRule.new(
discount_budget_for_month_repository: discount_budget_for_month_repository,
shipping_option_repository: shipping_option_repository,
shipment_repository: shipment_repository
)
]
PlanetExpress::ShipmentDiscountCalculator.new(
shipment_repository: shipment_repository,
rules: rules
).run(shipment_reader)
shipment_repository.each do |shipment|
puts shipment_formatter.format(shipment)
end