From a403cc8d1ddd6659ff668f428ab51639eb465f9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Fri, 6 Nov 2026 00:52:30 +0100 Subject: [PATCH] :sparkles: simplify access to input sources --- .github/workflows/pull-request.yml | 6 +- docs/code_samples/bank_account_details_v2.txt | 2 +- .../bank_statement_fr_v2_async.txt | 2 +- docs/code_samples/cropper_v1.txt | 2 +- docs/code_samples/default.txt | 2 +- docs/code_samples/default_async.txt | 2 +- docs/code_samples/expense_receipts_v5.txt | 2 +- .../expense_receipts_v5_async.txt | 2 +- docs/code_samples/financial_document_v1.txt | 2 +- .../financial_document_v1_async.txt | 2 +- docs/code_samples/idcard_fr_v2.txt | 2 +- .../international_id_v2_async.txt | 2 +- .../invoice_splitter_v1_async.txt | 2 +- docs/code_samples/invoices_v4.txt | 2 +- docs/code_samples/invoices_v4_async.txt | 2 +- .../multi_receipts_detector_v1.txt | 2 +- docs/code_samples/passport_v1.txt | 2 +- docs/code_samples/resume_v1_async.txt | 2 +- docs/code_samples/v2_classification.txt | 2 +- docs/code_samples/v2_crop.txt | 2 +- docs/code_samples/v2_extraction.txt | 2 +- docs/code_samples/v2_extraction_webhook.txt | 2 +- docs/code_samples/v2_ocr.txt | 2 +- docs/code_samples/v2_split.txt | 2 +- docs/code_samples/workflow_polling.txt | 2 +- lib/mindee.rb | 7 ++ sig/mindee.rbs | 69 ++++++++++++++----- spec/input/sources/files_handling_spec.rb | 18 ++--- spec/input/sources/sources_spec.rb | 21 +++--- spec/input/sources/url_input_source_spec.rb | 4 +- 30 files changed, 106 insertions(+), 67 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3c7db580f..7c9b8e49b 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -21,8 +21,8 @@ jobs: uses: ./.github/workflows/_test-units.yml needs: [ betterleaks, static-analysis ] secrets: inherit - test-unit-lite: - uses: ./.github/workflows/_test-units.yml + test-units-lite: + uses: ./.github/workflows/_test-units-lite.yml needs: [ betterleaks, static-analysis ] secrets: inherit test-integration: @@ -31,7 +31,7 @@ jobs: secrets: inherit test-integration-lite: uses: ./.github/workflows/_test-integration-lite.yml - needs: test-unit-lite + needs: test-units-lite secrets: inherit test-smoke: uses: ./.github/workflows/_test-smoke.yml diff --git a/docs/code_samples/bank_account_details_v2.txt b/docs/code_samples/bank_account_details_v2.txt index 197bf18ed..3091192f2 100644 --- a/docs/code_samples/bank_account_details_v2.txt +++ b/docs/code_samples/bank_account_details_v2.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( diff --git a/docs/code_samples/bank_statement_fr_v2_async.txt b/docs/code_samples/bank_statement_fr_v2_async.txt index 8e484ba55..782c8bbee 100644 --- a/docs/code_samples/bank_statement_fr_v2_async.txt +++ b/docs/code_samples/bank_statement_fr_v2_async.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( diff --git a/docs/code_samples/cropper_v1.txt b/docs/code_samples/cropper_v1.txt index 4b30cedf6..f9b19170c 100644 --- a/docs/code_samples/cropper_v1.txt +++ b/docs/code_samples/cropper_v1.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( diff --git a/docs/code_samples/default.txt b/docs/code_samples/default.txt index 6d02fb3ac..f4f8eaa3e 100644 --- a/docs/code_samples/default.txt +++ b/docs/code_samples/default.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Initialize a custom endpoint for this product custom_endpoint = mindee_client.create_endpoint( diff --git a/docs/code_samples/default_async.txt b/docs/code_samples/default_async.txt index 3cc9af5f2..fda456e7c 100644 --- a/docs/code_samples/default_async.txt +++ b/docs/code_samples/default_async.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Initialize a custom endpoint for this product custom_endpoint = mindee_client.create_endpoint( diff --git a/docs/code_samples/expense_receipts_v5.txt b/docs/code_samples/expense_receipts_v5.txt index 12f217d29..621d4434e 100644 --- a/docs/code_samples/expense_receipts_v5.txt +++ b/docs/code_samples/expense_receipts_v5.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( diff --git a/docs/code_samples/expense_receipts_v5_async.txt b/docs/code_samples/expense_receipts_v5_async.txt index 5286db69b..e44202b4d 100644 --- a/docs/code_samples/expense_receipts_v5_async.txt +++ b/docs/code_samples/expense_receipts_v5_async.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( diff --git a/docs/code_samples/financial_document_v1.txt b/docs/code_samples/financial_document_v1.txt index bb9c656f8..3775035aa 100644 --- a/docs/code_samples/financial_document_v1.txt +++ b/docs/code_samples/financial_document_v1.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( diff --git a/docs/code_samples/financial_document_v1_async.txt b/docs/code_samples/financial_document_v1_async.txt index f5d2b85d2..e61935fe3 100644 --- a/docs/code_samples/financial_document_v1_async.txt +++ b/docs/code_samples/financial_document_v1_async.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( diff --git a/docs/code_samples/idcard_fr_v2.txt b/docs/code_samples/idcard_fr_v2.txt index b97375688..ce24b3700 100644 --- a/docs/code_samples/idcard_fr_v2.txt +++ b/docs/code_samples/idcard_fr_v2.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( diff --git a/docs/code_samples/international_id_v2_async.txt b/docs/code_samples/international_id_v2_async.txt index 6aa981ee1..1dff0256d 100644 --- a/docs/code_samples/international_id_v2_async.txt +++ b/docs/code_samples/international_id_v2_async.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( diff --git a/docs/code_samples/invoice_splitter_v1_async.txt b/docs/code_samples/invoice_splitter_v1_async.txt index f602618b5..ba9004061 100644 --- a/docs/code_samples/invoice_splitter_v1_async.txt +++ b/docs/code_samples/invoice_splitter_v1_async.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( diff --git a/docs/code_samples/invoices_v4.txt b/docs/code_samples/invoices_v4.txt index b36beaf02..e465cad6a 100644 --- a/docs/code_samples/invoices_v4.txt +++ b/docs/code_samples/invoices_v4.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( diff --git a/docs/code_samples/invoices_v4_async.txt b/docs/code_samples/invoices_v4_async.txt index 60f93eb3a..0660640ab 100644 --- a/docs/code_samples/invoices_v4_async.txt +++ b/docs/code_samples/invoices_v4_async.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( diff --git a/docs/code_samples/multi_receipts_detector_v1.txt b/docs/code_samples/multi_receipts_detector_v1.txt index aa30eb140..d7f8c1fdd 100644 --- a/docs/code_samples/multi_receipts_detector_v1.txt +++ b/docs/code_samples/multi_receipts_detector_v1.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( diff --git a/docs/code_samples/passport_v1.txt b/docs/code_samples/passport_v1.txt index 842ec223a..45deea1d9 100644 --- a/docs/code_samples/passport_v1.txt +++ b/docs/code_samples/passport_v1.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( diff --git a/docs/code_samples/resume_v1_async.txt b/docs/code_samples/resume_v1_async.txt index c042a33f9..69499da03 100644 --- a/docs/code_samples/resume_v1_async.txt +++ b/docs/code_samples/resume_v1_async.txt @@ -9,7 +9,7 @@ require 'mindee' mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key') # Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') +input_source = Mindee::PathInputSource.new('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( diff --git a/docs/code_samples/v2_classification.txt b/docs/code_samples/v2_classification.txt index 455bba0f0..7c5e3e104 100644 --- a/docs/code_samples/v2_classification.txt +++ b/docs/code_samples/v2_classification.txt @@ -17,7 +17,7 @@ classification_params = { } # Load a file from disk -input_source = Mindee::Input::Source::PathInputSource.new(input_path) +input_source = Mindee::PathInputSource.new(input_path) # Send for processing response = mindee_client.enqueue_and_get_result( diff --git a/docs/code_samples/v2_crop.txt b/docs/code_samples/v2_crop.txt index e5760cfc7..a9b2fbdd7 100644 --- a/docs/code_samples/v2_crop.txt +++ b/docs/code_samples/v2_crop.txt @@ -17,7 +17,7 @@ crop_params = { } # Load a file from disk -input_source = Mindee::Input::Source::PathInputSource.new(input_path) +input_source = Mindee::PathInputSource.new(input_path) # Send for processing response = mindee_client.enqueue_and_get_result( diff --git a/docs/code_samples/v2_extraction.txt b/docs/code_samples/v2_extraction.txt index 002cf3d60..2bb15d513 100644 --- a/docs/code_samples/v2_extraction.txt +++ b/docs/code_samples/v2_extraction.txt @@ -29,7 +29,7 @@ extraction_params = { } # Load a file from disk -input_source = Mindee::Input::Source::PathInputSource.new(input_path) +input_source = Mindee::PathInputSource.new(input_path) # Send for processing response = mindee_client.enqueue_and_get_result( diff --git a/docs/code_samples/v2_extraction_webhook.txt b/docs/code_samples/v2_extraction_webhook.txt index 9b5ddd28e..d1632c763 100644 --- a/docs/code_samples/v2_extraction_webhook.txt +++ b/docs/code_samples/v2_extraction_webhook.txt @@ -30,7 +30,7 @@ extraction_params = { } # Load a file from disk -input_source = Mindee::Input::Source::PathInputSource.new(input_path) +input_source = Mindee::PathInputSource.new(input_path) # Send for processing response = mindee_client.enqueue( diff --git a/docs/code_samples/v2_ocr.txt b/docs/code_samples/v2_ocr.txt index db4f7b505..5357dc5dc 100644 --- a/docs/code_samples/v2_ocr.txt +++ b/docs/code_samples/v2_ocr.txt @@ -17,7 +17,7 @@ ocr_params = { } # Load a file from disk -input_source = Mindee::Input::Source::PathInputSource.new(input_path) +input_source = Mindee::PathInputSource.new(input_path) # Send for processing response = mindee_client.enqueue_and_get_result( diff --git a/docs/code_samples/v2_split.txt b/docs/code_samples/v2_split.txt index bc4b3ebb0..17ed609c9 100644 --- a/docs/code_samples/v2_split.txt +++ b/docs/code_samples/v2_split.txt @@ -17,7 +17,7 @@ split_params = { } # Load a file from disk -input_source = Mindee::Input::Source::PathInputSource.new(input_path) +input_source = Mindee::PathInputSource.new(input_path) # Send for processing response = mindee_client.enqueue_and_get_result( diff --git a/docs/code_samples/workflow_polling.txt b/docs/code_samples/workflow_polling.txt index 20e20135e..0163e5d01 100644 --- a/docs/code_samples/workflow_polling.txt +++ b/docs/code_samples/workflow_polling.txt @@ -11,7 +11,7 @@ workflow_id = 'workflow-id' mindee_client = Mindee::V1::Client.new # Load a file from disk -input_source = mindee_client.source_from_path('path/to/my/file.ext') +input_source = Mindee::PathInputSource.new('path/to/my/file.ext') # Initialize a custom endpoint for this product custom_endpoint = mindee_client.create_endpoint( diff --git a/lib/mindee.rb b/lib/mindee.rb index f81763968..d9fd4a252 100644 --- a/lib/mindee.rb +++ b/lib/mindee.rb @@ -112,6 +112,13 @@ module Product module Search end end + + # Aliases for deeply nested classes + Base64InputSource = Mindee::Input::Source::Base64InputSource + BytesInputSource = Mindee::Input::Source::BytesInputSource + FileInputSource = Mindee::Input::Source::FileInputSource + PathInputSource = Mindee::Input::Source::PathInputSource + URLInputSource = Mindee::Input::Source::URLInputSource end # Shorthand to call the logger from anywhere. diff --git a/sig/mindee.rbs b/sig/mindee.rbs index bdf2c27fb..1b6f53e3c 100644 --- a/sig/mindee.rbs +++ b/sig/mindee.rbs @@ -5,21 +5,22 @@ class Object end module Mindee - module Error - end + Base64InputSource: singleton(Input::Source::Base64InputSource) + BytesInputSource: singleton(Input::Source::BytesInputSource) + FileInputSource: singleton(Input::Source::FileInputSource) + PathInputSource: singleton(Input::Source::PathInputSource) + URLInputSource: singleton(Input::Source::URLInputSource) - module Extraction + module Dependencies end - module HTTP + module Error end - module PDF + module Geometry end - module Input - module Source - end + module HTTP end module Image @@ -33,30 +34,62 @@ module Mindee module Logging end - module Parsing - module Common + module Input + module Source end + end - module Standard - end + module Logging + end - module Universal - end + module PDF end module V1 - module Product - module EU + module Extraction + end + + module HTTP + end + + module Parsing + module Common + end + + module Standard + end + + module Universal end + end + module Product module FR end + end + end + + module V2 + module FileOperation + module Crop + end - module IND + module Split end + end + + module HTTP + end - module US + module Parsing + module Search end end + + module Product + end + + module Search + end end end diff --git a/spec/input/sources/files_handling_spec.rb b/spec/input/sources/files_handling_spec.rb index fb5a5c100..9248a0979 100644 --- a/spec/input/sources/files_handling_spec.rb +++ b/spec/input/sources/files_handling_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'mindee/input/sources' +require 'mindee' require 'base64' require_relative '../../data' @@ -8,7 +8,7 @@ context 'An jpg input file' do it 'should be readable as raw bytes' do file = File.join(FILE_TYPES_DIR, 'receipt.jpg') - input = Mindee::Input::Source::PathInputSource.new(file) + input = Mindee::PathInputSource.new(file) read_f = input.read_contents expect(read_f.length).to eq(2) expect(read_f[0]).to eq(File.read(file, mode: 'rb')) @@ -18,7 +18,7 @@ context 'A jpga input file' do it 'should be readable as raw bytes' do file = File.join(FILE_TYPES_DIR, 'receipt.jpga') - input = Mindee::Input::Source::PathInputSource.new(file) + input = Mindee::PathInputSource.new(file) read_f = input.read_contents expect(read_f.length).to eq(2) expect(read_f[0]).to eq(File.read(file, mode: 'rb')) @@ -28,7 +28,7 @@ context 'A heic input file' do it 'should be readable as raw bytes' do file = File.join(FILE_TYPES_DIR, 'receipt.heic') - input = Mindee::Input::Source::PathInputSource.new(file) + input = Mindee::PathInputSource.new(file) read_f = input.read_contents expect(read_f.length).to eq(2) expect(read_f[0]).to eq(File.read(file, mode: 'rb')) @@ -38,7 +38,7 @@ context 'A tif input file' do it 'should be readable as raw bytes' do file = File.join(FILE_TYPES_DIR, 'receipt.tif') - input = Mindee::Input::Source::PathInputSource.new(file) + input = Mindee::PathInputSource.new(file) read_f = input.read_contents expect(read_f.length).to eq(2) expect(read_f[0]).to eq(File.read(file, mode: 'rb')) @@ -48,7 +48,7 @@ context 'A tiff input file' do it 'should be readable as raw bytes' do file = File.join(FILE_TYPES_DIR, 'receipt.tiff') - input = Mindee::Input::Source::PathInputSource.new(file) + input = Mindee::PathInputSource.new(file) read_f = input.read_contents expect(read_f.length).to eq(2) expect(read_f[0]).to eq(File.read(file, mode: 'rb')) @@ -58,7 +58,7 @@ context 'A txt input file' do it 'should stay in base64' do file = File.join(FILE_TYPES_DIR, 'receipt.txt') - input = Mindee::Input::Source::Base64InputSource.new(File.read(file), 'receipt.txt') + input = Mindee::Base64InputSource.new(File.read(file), 'receipt.txt') read_f = input.read_contents expect(read_f.length).to eq(2) expect(read_f[0].gsub("\n", '')).to eq(File.read(file).gsub("\n", '')) @@ -68,7 +68,7 @@ context 'A standard pdf input file' do it 'should not be converted' do file = File.join(FILE_TYPES_DIR, 'pdf/not_blank_image_only.pdf') - input = Mindee::Input::Source::PathInputSource.new(file) + input = Mindee::PathInputSource.new(file) read_f = input.read_contents file_contents = File.read(file) expect(read_f[0]).to_not eq(Base64.encode64(file_contents)) @@ -80,7 +80,7 @@ context 'A valid written pdf input file' do it 'should not be converted' do file = File.join(FILE_TYPES_DIR, 'pdf/valid_exported.pdf') - input = Mindee::Input::Source::PathInputSource.new(file) + input = Mindee::PathInputSource.new(file) read_f = input.read_contents file_contents = File.read(file) expect(read_f[0]).to_not eq(Base64.encode64(file_contents)) diff --git a/spec/input/sources/sources_spec.rb b/spec/input/sources/sources_spec.rb index c070985d1..388fd07a5 100644 --- a/spec/input/sources/sources_spec.rb +++ b/spec/input/sources/sources_spec.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'mindee' -require 'mindee/input/sources' require 'mindee/error' require 'pdf-reader' if Mindee::Dependencies.all_deps_available? @@ -10,7 +9,7 @@ describe Mindee::Input::Source do context 'An image input file' do it 'should load a JPEG from a path' do - input_source = Mindee::Input::Source::PathInputSource.new( + input_source = Mindee::PathInputSource.new( File.join(FILE_TYPES_DIR, 'receipt.jpg') ) expect(input_source.file_mimetype).to eq('image/jpeg') @@ -18,7 +17,7 @@ expect(input_source.page_count).to eq(1) if Mindee::Dependencies.all_deps_available? expect(input_source.pdf?).to eq(false) - input_source = Mindee::Input::Source::PathInputSource.new( + input_source = Mindee::PathInputSource.new( File.join(FILE_TYPES_DIR, 'receipt.jpga') ) expect(input_source.file_mimetype).to eq('image/jpeg') @@ -28,7 +27,7 @@ end it 'should load a TIFF from a path' do - input_source = Mindee::Input::Source::PathInputSource.new( + input_source = Mindee::PathInputSource.new( File.join(FILE_TYPES_DIR, 'receipt.tif') ) expect(input_source.file_mimetype).to eq('image/tiff') @@ -36,7 +35,7 @@ expect(input_source.page_count).to eq(1) if Mindee::Dependencies.all_deps_available? expect(input_source.pdf?).to eq(false) - input_source = Mindee::Input::Source::PathInputSource.new( + input_source = Mindee::PathInputSource.new( File.join(FILE_TYPES_DIR, 'receipt.tiff') ) expect(input_source.file_mimetype).to eq('image/tiff') @@ -46,7 +45,7 @@ end it 'should load a HEIC from a path', :all_deps do - input_source = Mindee::Input::Source::PathInputSource.new( + input_source = Mindee::PathInputSource.new( File.join(FILE_TYPES_DIR, 'receipt.heic') ) expect(input_source.file_mimetype).to eq('image/heic') @@ -56,7 +55,7 @@ end it 'should load a HEIC from a path', :all_deps do - input_source = Mindee::Input::Source::PathInputSource.new( + input_source = Mindee::PathInputSource.new( File.join(FILE_TYPES_DIR, 'receipt.heif') ) expect(input_source.file_mimetype).to eq('image/heif') @@ -64,7 +63,7 @@ expect(input_source.page_count).to eq(1) expect(input_source.pdf?).to eq(false) - input_source2 = Mindee::Input::Source::PathInputSource.new( + input_source2 = Mindee::PathInputSource.new( File.join(FILE_TYPES_DIR, 'receipt.jpg.heif') ) expect(input_source2.file_mimetype).to eq('image/heif') @@ -76,7 +75,7 @@ context 'A PDF input file', :all_deps do it 'should load a multi-page PDF from a path' do - input_source = Mindee::Input::Source::PathInputSource.new( + input_source = Mindee::PathInputSource.new( File.join(V1_DATA_DIR, 'products/invoices/invoice.pdf') ) expect(input_source.file_mimetype).to eq('application/pdf') @@ -84,7 +83,7 @@ expect(input_source.page_count).to eq(2) expect(input_source.pdf?).to eq(true) - input_source = Mindee::Input::Source::PathInputSource.new( + input_source = Mindee::PathInputSource.new( File.join(V1_DATA_DIR, 'products/invoices/invoice.pdf') ) expect(input_source.file_mimetype).to eq('application/pdf') @@ -92,7 +91,7 @@ expect(input_source.page_count).to eq(2) expect(input_source.pdf?).to eq(true) - input_source = Mindee::Input::Source::PathInputSource.new( + input_source = Mindee::PathInputSource.new( File.join(V1_DATA_DIR, 'products/invoices/invoice_10p.pdf') ) expect(input_source.file_mimetype).to eq('application/pdf') diff --git a/spec/input/sources/url_input_source_spec.rb b/spec/input/sources/url_input_source_spec.rb index 87407af02..9840fc38f 100644 --- a/spec/input/sources/url_input_source_spec.rb +++ b/spec/input/sources/url_input_source_spec.rb @@ -3,7 +3,7 @@ require 'mindee' require_relative '../../http/mock_http_response' -describe Mindee::Input::Source::URLInputSource do +describe Mindee::URLInputSource do let(:valid_url) { 'https://validurl/some/file.jpg' } let(:valid_url_no_filename) { 'https://validurl/some/' } let(:invalid_url) { 'http://invalidurl/some/file.jpg' } @@ -50,7 +50,7 @@ it 'handles authentication' do result = url_input_source.as_local_input_source(username: 'user', password: 'pass') - expect(result).to be_a(Mindee::Input::Source::BytesInputSource) + expect(result).to be_a(Mindee::BytesInputSource) end end