diff --git a/docs/code_samples/default_v2.txt b/docs/code_samples/default_v2.txt index b5cd3151..8acb3123 100644 --- a/docs/code_samples/default_v2.txt +++ b/docs/code_samples/default_v2.txt @@ -11,7 +11,7 @@ mindee_client = Mindee::ClientV2.new(api_key: api_key) params = Mindee::Input::InferenceParameters.new( # ID of the model, required. model_id, - # If set to `True`, will enable Retrieval-Augmented Generation. + # If set to `true`, will enable Retrieval-Augmented Generation. rag: false, ) diff --git a/lib/mindee/input/local_response.rb b/lib/mindee/input/local_response.rb index e1cc2306..ca8988ab 100644 --- a/lib/mindee/input/local_response.rb +++ b/lib/mindee/input/local_response.rb @@ -69,10 +69,10 @@ def valid_hmac_signature?(secret_key, signature) end # Deserializes a loaded response - # @param response_class [Parsing::V2::JobResponse, Parsing::V2::InferenceResponse] class to return. + # @param response_class [Parsing::V2::CommonResponse] class to return. # @return [Parsing::V2::JobResponse, Parsing::V2::InferenceResponse] def deserialize_response(response_class) - response_class.new(as_hash) + response_class.new(as_hash) # : Parsing::V2::JobResponse | Parsing::V2::InferenceResponse rescue StandardError raise Errors::MindeeInputError, 'Invalid response provided.' end diff --git a/lib/mindee/input/sources/local_input_source.rb b/lib/mindee/input/sources/local_input_source.rb index 8e85b0cd..ca3a5f9a 100644 --- a/lib/mindee/input/sources/local_input_source.rb +++ b/lib/mindee/input/sources/local_input_source.rb @@ -166,8 +166,8 @@ def compress!(quality: 85, max_width: nil, max_height: nil, force_source_text: f @io_stream.rewind end - # Checks whether the file has source text if it is a pdf. False otherwise - # @return [bool] True if the file is a PDF and has source text. + # Checks whether the file has source text if it is a pdf. `false` otherwise + # @return [bool] `true` if the file is a PDF and has source text. def source_text? Mindee::PDF::PDFTools.source_text?(@io_stream) end diff --git a/lib/mindee/parsing/universal/universal_object_field.rb b/lib/mindee/parsing/universal/universal_object_field.rb index 4c1740e5..43b0f53b 100644 --- a/lib/mindee/parsing/universal/universal_object_field.rb +++ b/lib/mindee/parsing/universal/universal_object_field.rb @@ -78,7 +78,7 @@ def method_missing(method_name, *_args) # # @param method_name [Symbol] The name of the method being checked. # @param include_private [bool] Whether to include private methods in the check. - # @return [bool] True if the method can be responded to, false otherwise. + # @return [bool] `true` if the method can be responded to, false otherwise. def respond_to_missing?(method_name, include_private = false) @all_values.key?(method_name.to_s) || super end diff --git a/lib/mindee/parsing/v2/field/field_confidence.rb b/lib/mindee/parsing/v2/field/field_confidence.rb index d11fa2c2..66834de7 100644 --- a/lib/mindee/parsing/v2/field/field_confidence.rb +++ b/lib/mindee/parsing/v2/field/field_confidence.rb @@ -40,25 +40,25 @@ def self.from_string(value) end # Check if this is a certain confidence level. - # @return [Boolean] True if confidence is certain. + # @return [Boolean] `true` if confidence is certain. def certain? @value == CERTAIN end # Check if this is a high confidence level. - # @return [Boolean] True if confidence is high. + # @return [Boolean] `true` if confidence is high. def high? @value == HIGH end # Check if this is a medium confidence level. - # @return [Boolean] True if confidence is medium. + # @return [Boolean] `true` if confidence is medium. def medium? @value == MEDIUM end # Check if this is a low confidence level. - # @return [Boolean] True if confidence is low. + # @return [Boolean] `true` if confidence is low. def low? @value == LOW end @@ -71,7 +71,7 @@ def to_s # Compare two FieldConfidence instances. # @param other [FieldConfidence] The other confidence to compare. - # @return [Boolean] True if they have the same value. + # @return [Boolean] `true` if they have the same value. def ==(other) other.is_a?(FieldConfidence) && @value == other.value end diff --git a/lib/mindee/parsing/v2/field/inference_fields.rb b/lib/mindee/parsing/v2/field/inference_fields.rb index 19debf4d..7f717356 100644 --- a/lib/mindee/parsing/v2/field/inference_fields.rb +++ b/lib/mindee/parsing/v2/field/inference_fields.rb @@ -43,7 +43,7 @@ def method_missing(method_name, *args, &block) # Check if method_missing should handle the method. # @param method_name [Symbol] The method name. - # @return [Boolean] True if the method should be handled. + # @return [Boolean] `true` if the method should be handled. def respond_to_missing?(method_name, include_private = false) key?(method_name.to_s) || super end diff --git a/lib/mindee/parsing/v2/field/list_field.rb b/lib/mindee/parsing/v2/field/list_field.rb index 8e8dcb8b..1e6d9d69 100644 --- a/lib/mindee/parsing/v2/field/list_field.rb +++ b/lib/mindee/parsing/v2/field/list_field.rb @@ -49,7 +49,7 @@ def to_s end # Check if the list is empty. - # @return [Boolean] True if the list has no items. + # @return [Boolean] `true` if the list has no items. def empty? @items.empty? end diff --git a/lib/mindee/parsing/v2/field/object_field.rb b/lib/mindee/parsing/v2/field/object_field.rb index a68aaf4f..72658307 100644 --- a/lib/mindee/parsing/v2/field/object_field.rb +++ b/lib/mindee/parsing/v2/field/object_field.rb @@ -91,7 +91,7 @@ def method_missing(method_name, ...) # Check if method_missing should handle the method. # @param method_name [Symbol] The method name. - # @return [Boolean] True if the method should be handled. + # @return [Boolean] `true` if the method should be handled. def respond_to_missing?(method_name, include_private = false) @fields.respond_to?(method_name) || super end diff --git a/lib/mindee/pdf/pdf_tools.rb b/lib/mindee/pdf/pdf_tools.rb index 676862f5..c3e6bb54 100644 --- a/lib/mindee/pdf/pdf_tools.rb +++ b/lib/mindee/pdf/pdf_tools.rb @@ -44,7 +44,7 @@ def to_io_stream(params = {}) # Checks a PDFs stream content for text operators # See https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf page 243-251. # @param [StringIO] stream Stream object from a PDFs page. - # @return [bool] True if a text operator is found in the stream. + # @return [bool] `true` if a text operator is found in the stream. def self.stream_has_text?(stream) data = stream.data return false if data.nil? || data.empty? @@ -55,7 +55,7 @@ def self.stream_has_text?(stream) # Checks whether the file has source_text. Sends false if the file isn't a PDF. # @param [StringIO] pdf_data Abinary-encoded stream representing the PDF file. - # @return [bool] True if the pdf has source text, false otherwise. + # @return [bool] `true` if the pdf has source text, false otherwise. def self.source_text?(pdf_data) begin pdf_data.rewind diff --git a/sig/mindee/input/local_response.rbs b/sig/mindee/input/local_response.rbs index 622c229d..89a35dff 100644 --- a/sig/mindee/input/local_response.rbs +++ b/sig/mindee/input/local_response.rbs @@ -8,7 +8,7 @@ module Mindee def self.process_secret_key: (String) -> String def get_hmac_signature: (String) -> String def valid_hmac_signature?: (String, String) -> bool - def deserialize_response: (singleton(Parsing::V2::JobResponse) | singleton(Parsing::V2::InferenceResponse))-> (Parsing::V2::JobResponse | Parsing::V2::InferenceResponse) + def deserialize_response: (singleton(Parsing::V2::CommonResponse))-> (Parsing::V2::JobResponse | Parsing::V2::InferenceResponse) end end end diff --git a/spec/parsing/v2/inference_spec.rb b/spec/parsing/v2/inference_spec.rb index ead03ffd..561bb542 100644 --- a/spec/parsing/v2/inference_spec.rb +++ b/spec/parsing/v2/inference_spec.rb @@ -92,6 +92,12 @@ def load_v2_inference(resource_path) first_tax_item = taxes_list.items.first expect(first_tax_item).to be_a(object_field) + expect(fields).to have_key('line_items') + expect(fields['line_items']).not_to be_nil + expect(fields['line_items']).to be_a(list_field) + expect(fields['line_items'][0]).to be_a(object_field) + expect(fields['line_items'][0]['quantity'].value).to eq(1.0) + tax_item_obj = first_tax_item expect(tax_item_obj.fields.size).to eq(3)