Skip to content

Commit b27f423

Browse files
♻️ fix and module names + all typing issues
1 parent f30e25e commit b27f423

32 files changed

Lines changed: 61 additions & 61 deletions

lib/mindee.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
module Mindee
99
# Dependency management
10-
module Dependency
10+
module Dependencies
1111
end
1212

1313
# Mindee internal error module.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module Mindee
44
# Centralized check for optional heavy dependencies
5-
module Dependency
5+
module Dependencies
66
def self.check_all_dependencies
77
require 'origami'
88
require 'mini_magick'

lib/mindee/image/image_extractor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
Mindee::Dependency.require_all_deps!
3+
Mindee::Dependencies.require_all_deps!
44
require 'mini_magick'
55
require 'origami'
66
require 'stringio'

lib/mindee/input/sources/local_input_source.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
require 'marcel'
55
require 'fileutils'
66

7-
require_relative '../../dependency'
8-
require_relative '../../pdf' if Mindee::Dependency.all_deps_available?
9-
require_relative '../../image' if Mindee::Dependency.all_deps_available?
7+
require_relative '../../dependencies'
8+
require_relative '../../pdf' if Mindee::Dependencies.all_deps_available?
9+
require_relative '../../image' if Mindee::Dependencies.all_deps_available?
1010

1111
module Mindee
1212
module Input
@@ -143,8 +143,8 @@ def write_to_file(path)
143143
# Defaults to one for images.
144144
# @return [Integer]
145145
def page_count
146-
unless Mindee::Dependency.all_deps_available?
147-
raise NotImplementedError, Mindee::Dependency::MINDEE_DEPENDENCIES_LOAD_ERROR
146+
unless Mindee::Dependencies.all_deps_available?
147+
raise NotImplementedError, Mindee::Dependencies::MINDEE_DEPENDENCIES_LOAD_ERROR
148148
end
149149
return 1 unless pdf?
150150

@@ -163,8 +163,8 @@ def page_count
163163
# @param [bool] disable_source_text If the PDF has source text, whether to re-apply it to the original or
164164
# not. Needs force_source_text to work.
165165
def compress!(quality: 85, max_width: nil, max_height: nil, force_source_text: false, disable_source_text: true)
166-
unless Mindee::Dependency.all_deps_available?
167-
raise NotImplementedError, Mindee::Dependency::MINDEE_DEPENDENCIES_LOAD_ERROR
166+
unless Mindee::Dependencies.all_deps_available?
167+
raise NotImplementedError, Mindee::Dependencies::MINDEE_DEPENDENCIES_LOAD_ERROR
168168
end
169169

170170
buffer = if pdf?
@@ -189,8 +189,8 @@ def compress!(quality: 85, max_width: nil, max_height: nil, force_source_text: f
189189
# Checks whether the file has source text if it is a pdf. `false` otherwise
190190
# @return [bool] `true` if the file is a PDF and has source text.
191191
def source_text?
192-
unless Mindee::Dependency.all_deps_available?
193-
raise NotImplementedError, Mindee::Dependency::MINDEE_DEPENDENCIES_LOAD_ERROR
192+
unless Mindee::Dependencies.all_deps_available?
193+
raise NotImplementedError, Mindee::Dependencies::MINDEE_DEPENDENCIES_LOAD_ERROR
194194
end
195195

196196
Mindee::PDF::PDFTools.source_text?(@io_stream)

lib/mindee/pdf/pdf_compressor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
Mindee::Dependency.require_all_deps!
3+
Mindee::Dependencies.require_all_deps!
44
require 'pdf-reader'
55

66
# Shorthand for pdf-reader's PDF namespace, to avoid mixups with the local Origami fork.

lib/mindee/pdf/pdf_extractor.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ module PDF
77
class PDFExtractor
88
# @param local_input [Mindee::Input::Source::LocalInputSource]
99
def initialize(local_input)
10-
unless Mindee::Dependency.all_deps_available?
11-
raise NotImplementedError, Mindee::Dependency::MINDEE_DEPENDENCIES_LOAD_ERROR
10+
unless Mindee::Dependencies.all_deps_available?
11+
raise NotImplementedError, Mindee::Dependencies::MINDEE_DEPENDENCIES_LOAD_ERROR
1212
end
1313

1414
@filename = local_input.filename
@@ -82,14 +82,14 @@ def extract_invoices(page_indexes, strict: false)
8282
page_indexes_as_array = page_indexes # @type var page_indexes : Array[Array[Integer]]
8383
return extract_sub_documents(page_indexes_as_array)
8484
end
85-
p_ids = page_indexes # @type var page_indexes: Product::InvoiceSplitter::InvoiceSplitterV1InvoicePageGroups
85+
p_ids = page_indexes # @type var page_indexes: Mindee::V1::Product::InvoiceSplitter::InvoiceSplitterV1InvoicePageGroups
8686
return extract_sub_documents(p_ids.map(&:page_indexes)) unless strict
8787

8888
correct_page_indexes = [] # @type var correct_page_indexes: Array[Array[Integer]]
8989
current_list = [] # @type var current_list: Array[Integer]
9090
previous_confidence = nil
9191
p_ids.each_with_index do |p_i, i|
92-
page_index = p_i # @type var page_index: Product::InvoiceSplitter::InvoiceSplitterV1InvoicePageGroup
92+
page_index = p_i # @type var page_index: Mindee::V1::Product::InvoiceSplitter::InvoiceSplitterV1InvoicePageGroup
9393
confidence = page_index.confidence.to_f
9494
page_list = page_index.page_indexes
9595

lib/mindee/pdf/pdf_processor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
Mindee::Dependency.require_all_deps!
3+
Mindee::Dependencies.require_all_deps!
44
require 'origami'
55
require_relative 'pdf_tools'
66

lib/mindee/pdf/pdf_tools.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
Mindee::Dependency.require_all_deps!
3+
Mindee::Dependencies.require_all_deps!
44
require 'origami'
55

66
module Mindee

lib/mindee/v1.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
require_relative 'v1/client'
4-
require_relative 'v1/extraction' if Mindee::Dependency.all_deps_available?
4+
require_relative 'v1/extraction' if Mindee::Dependencies.all_deps_available?
55
require_relative 'v1/http'
66
require_relative 'v1/parsing'
77
require_relative 'v1/product'

lib/mindee/v1/product/invoice_splitter/invoice_splitter_v1_document.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class InvoiceSplitterV1Document < Mindee::V1::Parsing::Common::Prediction
1919
# @param page_id [Integer, nil]
2020
def initialize(prediction, page_id)
2121
super
22-
@invoice_page_groups = Product::InvoiceSplitter::InvoiceSplitterV1InvoicePageGroups.new(
22+
@invoice_page_groups = InvoiceSplitterV1InvoicePageGroups.new(
2323
prediction['invoice_page_groups'], page_id
2424
)
2525
end

0 commit comments

Comments
 (0)