Skip to content

Commit 60b7497

Browse files
✨ ⬆️ add support for mindee-lite gem (#240)
1 parent 2b8237f commit 60b7497

50 files changed

Lines changed: 430 additions & 133 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/_publish-code.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ on:
55
workflow_dispatch:
66

77
jobs:
8-
linting:
8+
publish:
99
name: Publish to Rubygems
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v5
1313
with:
1414
submodules: recursive
15-
1615
- name: Set up Ruby
1716
uses: ruby/setup-ruby@v1
1817
with:
@@ -28,10 +27,13 @@ jobs:
2827
echo -e "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}" > ~/.gem/credentials
2928
chmod 600 ~/.gem/credentials
3029
31-
- name: Build the Gem
30+
- name: Build the Gems
3231
run: |
33-
gem build --strict --output mindee.gem
32+
gem build mindee.gemspec --strict --output mindee.gem
33+
gem build mindee-lite.gemspec --strict --output mindee-lite.gem
3434
35-
- name: Publish the Gem
35+
- name: Publish the Gems
3636
run: |
37+
# Push both generated files to Rubygems
3738
gem push mindee.gem
39+
gem push mindee-lite.gem
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#
2+
# Run integration tests.
3+
#
4+
name: Integration Tests - Minimal Dependencies
5+
6+
on:
7+
workflow_call:
8+
workflow_dispatch:
9+
10+
env:
11+
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
12+
WORKFLOW_ID: ${{ secrets.WORKFLOW_ID_SE_TESTS }}
13+
MINDEE_V2_API_KEY: ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }}
14+
MINDEE_V2_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
15+
MINDEE_V2_SE_TESTS_BLANK_PDF_URL: ${{ secrets.MINDEE_V2_SE_TESTS_BLANK_PDF_URL }}
16+
MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
17+
MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
18+
MINDEE_V2_SE_TESTS_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
19+
MINDEE_V2_SE_TESTS_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}
20+
MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
21+
MINDEE_LOG_LEVEL: DEBUG
22+
MINDEE_GEM_NAME: mindee-lite
23+
24+
jobs:
25+
integration-tests:
26+
name: Run Integration Tests
27+
timeout-minutes: 30
28+
runs-on: ${{ matrix.os }}
29+
strategy:
30+
max-parallel: 3
31+
matrix:
32+
os:
33+
- "ubuntu-24.04"
34+
- "macos-latest"
35+
ruby:
36+
- "4.0"
37+
steps:
38+
- uses: actions/checkout@v5
39+
with:
40+
submodules: recursive
41+
42+
- name: set up Ruby ${{ matrix.ruby }}
43+
uses: ruby/setup-ruby@v1
44+
with:
45+
ruby-version: ${{ matrix.ruby }}
46+
bundler-cache: true
47+
48+
- name: Run Rspec for integration tests
49+
run: |
50+
bundle exec rake integration
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Run integration tests.
33
#
4-
name: Integration Tests
4+
name: Integration Tests - All Dependencies
55

66
on:
77
workflow_call:
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#
2+
# Run lite unit tests.
3+
#
4+
name: Unit Tests - Minimal Dependencies
5+
6+
on:
7+
workflow_call:
8+
9+
env:
10+
MINDEE_GEM_NAME: mindee-lite
11+
12+
jobs:
13+
tests:
14+
name: Run Unit Tests
15+
timeout-minutes: 30
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
os:
20+
- "ubuntu-24.04"
21+
- "macos-latest"
22+
ruby:
23+
- "3.2"
24+
- "4.0"
25+
steps:
26+
- uses: actions/checkout@v5
27+
with:
28+
submodules: recursive
29+
30+
- name: set up Ruby ${{ matrix.ruby }}
31+
uses: ruby/setup-ruby@v1
32+
with:
33+
ruby-version: ${{ matrix.ruby }}
34+
bundler-cache: true
35+
36+
- name: Run Rspec
37+
env:
38+
MINDEE_LOG_LEVEL: DEBUG
39+
run: |
40+
bundle exec rake spec

.github/workflows/_test-units.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
2-
# Run unit tests.
2+
# Run full unit tests.
33
#
4-
name: Tests
4+
name: Unit Tests - All Dependencies
55

66
on:
77
workflow_call:
@@ -15,7 +15,6 @@ jobs:
1515
matrix:
1616
os:
1717
- "ubuntu-24.04"
18-
- "ubuntu-22.04"
1918
- "macos-latest"
2019
ruby:
2120
- "3.2"

.github/workflows/pull-request.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,27 @@ permissions:
1010
jobs:
1111
static-analysis:
1212
uses: ./.github/workflows/_static-analysis.yml
13-
test-units:
13+
test-unit:
1414
uses: ./.github/workflows/_test-units.yml
1515
needs: static-analysis
1616
secrets: inherit
17-
test-integrations:
18-
uses: ./.github/workflows/_test-integrations.yml
19-
needs: test-units
17+
test-unit-lite:
18+
uses: ./.github/workflows/_test-units.yml
19+
needs: static-analysis
20+
secrets: inherit
21+
test-integration:
22+
uses: ./.github/workflows/_test-integration.yml
23+
needs: test-unit
24+
secrets: inherit
25+
test-integration-lite:
26+
uses: ./.github/workflows/_test-integration-lite.yml
27+
needs: test-unit-lite
2028
secrets: inherit
2129
test-smoke:
2230
uses: ./.github/workflows/_test-smoke.yml
23-
needs: test-units
31+
needs: test-unit
2432
secrets: inherit
2533
test-cli:
2634
uses: ./.github/workflows/_test-cli.yml
27-
needs: test-units
35+
needs: test-unit
2836
secrets: inherit

Gemfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,12 @@
33
source 'https://rubygems.org'
44

55
# Specify your gem's dependencies in mindee.gemspec
6-
gemspec
6+
7+
gemspec name: ENV.fetch('MINDEE_GEM_NAME', 'mindee')
8+
9+
group :development, :test do
10+
gem 'openssl', '~> 4.0'
11+
gem 'prism', '~> 1.3'
12+
gem 'rake', '~> 13.3'
13+
gem 'rspec', '~> 3.13'
14+
end

Rakefile

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,39 @@
22

33
require 'rake'
44
require 'rspec/core/rake_task'
5-
require 'yard'
5+
6+
is_lite_mode = ENV.fetch('MINDEE_GEM_NAME', 'mindee') == 'mindee-lite'
67

78
begin
89
require 'bundler/setup'
9-
Bundler::GemHelper.install_tasks
10+
require 'bundler/gem_helper'
11+
Bundler::GemHelper.install_tasks(name: ENV.fetch('MINDEE_GEM_NAME', 'mindee'))
1012
rescue LoadError
1113
puts 'although not required, bundler is recommended for running the tests'
1214
end
1315

1416
task default: :spec
17+
exclusion_opts = is_lite_mode ? ['--tag', '~all_deps'] : []
18+
RSpec::Core::RakeTask.new(:spec) do |t|
19+
t.rspec_opts = exclusion_opts
20+
end
21+
unless is_lite_mode
22+
require 'yard'
23+
desc 'Generate documentation'
24+
YARD::Rake::YardocTask.new(:doc) do |task|
25+
task.files = ['lib/**/*.rb']
26+
end
1527

16-
RSpec::Core::RakeTask.new(:spec)
17-
18-
desc 'Generate documentation'
19-
YARD::Rake::YardocTask.new(:doc) do |task|
20-
task.files = ['lib/**/*.rb']
28+
Rake::Task[:doc].enhance do
29+
FileUtils.cp_r(
30+
File.join('docs', 'code_samples'),
31+
File.join('docs', '_build')
32+
)
33+
end
2134
end
2235

2336
desc 'Run integration tests'
2437
RSpec::Core::RakeTask.new(:integration) do |t|
2538
t.pattern = 'spec/**/*_integration.rb'
26-
t.rspec_opts = ['--require', 'integration_helper']
27-
end
28-
29-
Rake::Task[:doc].enhance do
30-
FileUtils.cp_r(
31-
File.join('docs', 'code_samples'),
32-
File.join('docs', '_build')
33-
)
39+
t.rspec_opts = ['--require', 'integration_helper'] + exclusion_opts
3440
end

examples/auto_invoice_splitter_extraction.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def invoice_splitter_auto_extraction(file_path)
66
mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key')
77
input_source = mindee_client.source_from_path(file_path)
88

9-
if input_source.pdf? && input_source.count_pages > 1
9+
if input_source.pdf? && input_source.page_count > 1
1010
parse_multi_page(mindee_client, input_source)
1111
else
1212
parse_single_page(mindee_client, input_source)

lib/mindee.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
require 'mindee/v2'
77

88
module Mindee
9+
# Dependency management
10+
module Dependency
11+
end
12+
913
# Mindee internal error module.
1014
module Error
1115
end

0 commit comments

Comments
 (0)