Class: Csvtool::Interface::CLI::Workflows::RunRowExtractionWorkflow
- Inherits:
-
Object
- Object
- Csvtool::Interface::CLI::Workflows::RunRowExtractionWorkflow
- Defined in:
- lib/csvtool/interface/cli/workflows/run_row_extraction_workflow.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(stdin:, stdout:, stderr: stdout, use_case: Application::UseCases::RunRowExtraction.new) ⇒ RunRowExtractionWorkflow
constructor
A new instance of RunRowExtractionWorkflow.
Constructor Details
#initialize(stdin:, stdout:, stderr: stdout, use_case: Application::UseCases::RunRowExtraction.new) ⇒ RunRowExtractionWorkflow
Returns a new instance of RunRowExtractionWorkflow.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/csvtool/interface/cli/workflows/run_row_extraction_workflow.rb', line 24 def initialize(stdin:, stdout:, stderr: stdout, use_case: Application::UseCases::RunRowExtraction.new) @stdin = stdin @stdout = stdout @stderr = stderr @use_case = use_case @errors = Interface::CLI::Errors::Presenter.new(stdout: @stderr) @session_builder = Builders::RowExtractionSessionBuilder.new @output_destination_mapper = Support::OutputDestinationMapper.new @result_error_handler = Support::ResultErrorHandler.new(errors: @errors) end |
Instance Method Details
#call ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/csvtool/interface/cli/workflows/run_row_extraction_workflow.rb', line 35 def call context = { use_case: @use_case, session_builder: @session_builder, output_destination_mapper: @output_destination_mapper, handle_error: method(:handle_error) } pipeline = Steps::WorkflowStepPipeline.new(steps: [ Steps::RowExtraction::CollectSourceStep.new( file_path_prompt: Interface::CLI::Prompts::FilePathPrompt.new(stdin: @stdin, stdout: @stderr), separator_prompt: Interface::CLI::Prompts::SeparatorPrompt.new(stdin: @stdin, stdout: @stderr, errors: @errors) ), Steps::RowExtraction::ReadHeadersStep.new, Steps::RowExtraction::CollectRangeStep.new(stdin: @stdin, stdout: @stderr), Steps::RowExtraction::CollectDestinationStep.new( output_destination_prompt: Interface::CLI::Prompts::OutputDestinationPrompt.new( stdin: @stdin, stdout: @stderr, errors: @errors ) ), Steps::RowExtraction::ExecuteStep.new(stdout: @stdout, errors: @errors) ]) pipeline.call(context) rescue Domain::RowSession::InvalidStartRowError @errors.invalid_start_row rescue Domain::RowSession::InvalidEndRowError @errors.invalid_end_row rescue Domain::RowSession::InvalidRowRangeOrderError @errors.invalid_row_range_order rescue ArgumentError => e return @errors.empty_output_path if e. == "file output path cannot be empty" raise e end |