mathpix 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +53 -0
  3. data/README.md +114 -1
  4. data/lib/mathpix/batch.rb +7 -8
  5. data/lib/mathpix/batched_document_conversion.rb +238 -0
  6. data/lib/mathpix/client.rb +33 -27
  7. data/lib/mathpix/configuration.rb +5 -9
  8. data/lib/mathpix/conversion.rb +2 -6
  9. data/lib/mathpix/document.rb +47 -12
  10. data/lib/mathpix/document_batcher.rb +191 -0
  11. data/lib/mathpix/mcp/auth/oauth_provider.rb +8 -9
  12. data/lib/mathpix/mcp/base_tool.rb +8 -5
  13. data/lib/mathpix/mcp/elicitations/ambiguity_elicitation.rb +8 -11
  14. data/lib/mathpix/mcp/elicitations/base_elicitation.rb +2 -0
  15. data/lib/mathpix/mcp/elicitations/confidence_elicitation.rb +2 -1
  16. data/lib/mathpix/mcp/elicitations.rb +1 -1
  17. data/lib/mathpix/mcp/middleware/cors_middleware.rb +2 -6
  18. data/lib/mathpix/mcp/middleware/oauth_middleware.rb +2 -6
  19. data/lib/mathpix/mcp/middleware/rate_limiting_middleware.rb +19 -18
  20. data/lib/mathpix/mcp/resources/formats_list_resource.rb +54 -54
  21. data/lib/mathpix/mcp/resources/hierarchical_router.rb +9 -18
  22. data/lib/mathpix/mcp/resources/latest_snip_resource.rb +22 -22
  23. data/lib/mathpix/mcp/resources/recent_snips_resource.rb +11 -10
  24. data/lib/mathpix/mcp/resources/snip_stats_resource.rb +14 -12
  25. data/lib/mathpix/mcp/server.rb +18 -18
  26. data/lib/mathpix/mcp/tools/batch_convert_tool.rb +31 -37
  27. data/lib/mathpix/mcp/tools/check_document_status_tool.rb +5 -5
  28. data/lib/mathpix/mcp/tools/convert_document_tool.rb +15 -14
  29. data/lib/mathpix/mcp/tools/convert_image_tool.rb +15 -14
  30. data/lib/mathpix/mcp/tools/convert_strokes_tool.rb +13 -13
  31. data/lib/mathpix/mcp/tools/get_account_info_tool.rb +1 -1
  32. data/lib/mathpix/mcp/tools/get_usage_tool.rb +5 -7
  33. data/lib/mathpix/mcp/tools/list_formats_tool.rb +30 -30
  34. data/lib/mathpix/mcp/tools/search_results_tool.rb +13 -14
  35. data/lib/mathpix/mcp/transports/http_streaming_transport.rb +129 -118
  36. data/lib/mathpix/mcp/transports/sse_stream_handler.rb +37 -35
  37. data/lib/mathpix/result.rb +3 -2
  38. data/lib/mathpix/version.rb +1 -1
  39. data/lib/mathpix.rb +3 -1
  40. metadata +60 -2
@@ -16,6 +16,7 @@ module Mathpix
16
16
  # @return [String, nil] URL if source was remote, nil otherwise
17
17
  def source_url
18
18
  return nil unless @source_path.is_a?(String)
19
+
19
20
  @source_path.start_with?('http://', 'https://') ? @source_path : nil
20
21
  end
21
22
 
@@ -188,7 +189,7 @@ module Mathpix
188
189
  # Is this line printed?
189
190
  # @return [Boolean]
190
191
  def printed?
191
- data['type'] == 'printed' || data['type'] == 'print'
192
+ %w[printed print].include?(data['type'])
192
193
  end
193
194
 
194
195
  # LaTeX for this line
@@ -328,7 +329,7 @@ module Mathpix
328
329
  # Is this a chemistry result?
329
330
  # @return [Boolean]
330
331
  def chemistry?
331
- molecular_formula || inchi || smiles&.match?(/^[A-Za-z0-9@\[\]\(\)=#\+\-\\\/\.]+$/)
332
+ molecular_formula || inchi || smiles&.match?(%r{^[A-Za-z0-9@\[\]()=#+\-\\/.]+$})
332
333
  end
333
334
 
334
335
  # --- Success/Failure ---
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Mathpix
4
4
  # Gem version following semantic versioning
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
 
7
7
  # Seed for deterministic behavior
8
8
  SEED = 1069
data/lib/mathpix.rb CHANGED
@@ -12,6 +12,8 @@ require_relative 'mathpix/result'
12
12
  require_relative 'mathpix/conversion'
13
13
  require_relative 'mathpix/chemistry'
14
14
  require_relative 'mathpix/document'
15
+ require_relative 'mathpix/document_batcher'
16
+ require_relative 'mathpix/batched_document_conversion'
15
17
  require_relative 'mathpix/batch'
16
18
  require_relative 'mathpix/errors'
17
19
  require_relative 'mathpix/balanced_ternary'
@@ -178,7 +180,7 @@ module Mathpix
178
180
  # end
179
181
  def batch(image_paths, &block)
180
182
  Batch.new(client, image_paths).tap do |batch|
181
- block.call(batch) if block
183
+ block&.call(batch)
182
184
  end.process
183
185
  end
184
186
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mathpix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Barton Rhodes
@@ -66,6 +66,48 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: ostruct
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.6'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pdf-reader
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.11'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.11'
97
+ - !ruby/object:Gem::Dependency
98
+ name: prawn
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.4'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.4'
69
111
  - !ruby/object:Gem::Dependency
70
112
  name: cucumber
71
113
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +206,20 @@ dependencies:
164
206
  - - "~>"
165
207
  - !ruby/object:Gem::Version
166
208
  version: '0.9'
209
+ - !ruby/object:Gem::Dependency
210
+ name: rack-test
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '2.1'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '2.1'
167
223
  - !ruby/object:Gem::Dependency
168
224
  name: bundler-audit
169
225
  requirement: !ruby/object:Gem::Requirement
@@ -212,6 +268,7 @@ files:
212
268
  - lib/mathpix.rb
213
269
  - lib/mathpix/balanced_ternary.rb
214
270
  - lib/mathpix/batch.rb
271
+ - lib/mathpix/batched_document_conversion.rb
215
272
  - lib/mathpix/capture_builder.rb
216
273
  - lib/mathpix/chemistry.rb
217
274
  - lib/mathpix/client.rb
@@ -219,6 +276,7 @@ files:
219
276
  - lib/mathpix/configuration.rb.backup
220
277
  - lib/mathpix/conversion.rb
221
278
  - lib/mathpix/document.rb
279
+ - lib/mathpix/document_batcher.rb
222
280
  - lib/mathpix/errors.rb
223
281
  - lib/mathpix/mcp.rb
224
282
  - lib/mathpix/mcp/auth.rb
@@ -274,7 +332,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
274
332
  requirements:
275
333
  - - ">="
276
334
  - !ruby/object:Gem::Version
277
- version: 2.7.0
335
+ version: 3.2.0
278
336
  required_rubygems_version: !ruby/object:Gem::Requirement
279
337
  requirements:
280
338
  - - ">="