Skip to content

Commit 258502c

Browse files
authored
Merge pull request #5 from cpetersen/dependabot/cargo/ext/parsekit/quick-xml-0.38
Update quick-xml requirement from 0.36 to 0.38 in /ext/parsekit
2 parents e5fdd26 + d3bdd87 commit 258502c

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

ext/parsekit/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ tesseract-rs = "0.1" # Tesseract with optional bundling
2020
image = "0.25" # Image processing library (match rusty-tesseract's version)
2121
calamine = "0.30" # Excel parsing
2222
docx-rs = "0.4" # Word document parsing
23+
quick-xml = "0.38" # XML parsing
2324
zip = "2.1" # ZIP archive handling for PPTX
24-
quick-xml = "0.36" # XML parsing
2525
serde_json = "1.0" # JSON parsing
2626
regex = "1.10" # Text parsing
2727
encoding_rs = "0.8" # Encoding detection
@@ -33,4 +33,4 @@ bundled-tesseract = []
3333
[profile.release]
3434
opt-level = 3
3535
lto = true
36-
codegen-units = 1
36+
codegen-units = 1

ext/parsekit/src/error.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use magnus::{exception, Error, RModule, Ruby, Module};
1+
use magnus::{Error, RModule, Ruby, Module};
22

33
/// Custom error types for ParseKit
44
#[derive(Debug)]
@@ -15,13 +15,13 @@ impl ParserError {
1515
pub fn to_error(&self) -> Error {
1616
match self {
1717
ParserError::ParseError(msg) => {
18-
Error::new(exception::runtime_error(), msg.clone())
18+
Error::new(Ruby::get().unwrap().exception_runtime_error(), msg.clone())
1919
}
2020
ParserError::ConfigError(msg) => {
21-
Error::new(exception::arg_error(), msg.clone())
21+
Error::new(Ruby::get().unwrap().exception_arg_error(), msg.clone())
2222
}
2323
ParserError::IoError(msg) => {
24-
Error::new(exception::io_error(), msg.clone())
24+
Error::new(Ruby::get().unwrap().exception_io_error(), msg.clone())
2525
}
2626
}
2727
}
@@ -37,9 +37,9 @@ pub fn init(_ruby: &Ruby, module: RModule) -> Result<(), Error> {
3737

3838
// Define error classes as regular Ruby classes
3939
// Users can still rescue them by name in Ruby code
40-
let _error = module.define_class("Error", magnus::class::object())?;
41-
let _parse_error = module.define_class("ParseError", magnus::class::object())?;
42-
let _config_error = module.define_class("ConfigError", magnus::class::object())?;
40+
let _error = module.define_class("Error", Ruby::get().unwrap().class_object())?;
41+
let _parse_error = module.define_class("ParseError", Ruby::get().unwrap().class_object())?;
42+
let _config_error = module.define_class("ConfigError", Ruby::get().unwrap().class_object())?;
4343

4444
Ok(())
4545
}

ext/parsekit/src/parser.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use magnus::{
2-
class, function, method, prelude::*, scan_args, Error, Module, RHash, RModule, Ruby, Value,
2+
function, method, prelude::*, scan_args, Error, Module, RHash, RModule, Ruby, Value,
33
};
44
use std::path::Path;
55

@@ -59,7 +59,7 @@ impl Parser {
5959
// Check size limit
6060
if data.len() > self.config.max_size {
6161
return Err(Error::new(
62-
magnus::exception::runtime_error(),
62+
Ruby::get().unwrap().exception_runtime_error(),
6363
format!(
6464
"File size {} exceeds maximum allowed size {}",
6565
data.len(),
@@ -192,7 +192,7 @@ impl Parser {
192192

193193
if let Err(e) = init_result {
194194
return Err(Error::new(
195-
magnus::exception::runtime_error(),
195+
Ruby::get().unwrap().exception_runtime_error(),
196196
format!("Failed to initialize Tesseract: {:?}", e),
197197
))
198198
}
@@ -201,7 +201,7 @@ impl Parser {
201201
let img = match image::load_from_memory(&data) {
202202
Ok(img) => img,
203203
Err(e) => return Err(Error::new(
204-
magnus::exception::runtime_error(),
204+
Ruby::get().unwrap().exception_runtime_error(),
205205
format!("Failed to load image: {}", e),
206206
))
207207
};
@@ -220,7 +220,7 @@ impl Parser {
220220
(width * 4) as i32, // bytes per line
221221
) {
222222
return Err(Error::new(
223-
magnus::exception::runtime_error(),
223+
Ruby::get().unwrap().exception_runtime_error(),
224224
format!("Failed to set image: {}", e),
225225
))
226226
}
@@ -229,7 +229,7 @@ impl Parser {
229229
match tesseract.get_utf8_text() {
230230
Ok(text) => Ok(text.trim().to_string()),
231231
Err(e) => Err(Error::new(
232-
magnus::exception::runtime_error(),
232+
Ruby::get().unwrap().exception_runtime_error(),
233233
format!("Failed to perform OCR: {}", e),
234234
)),
235235
}
@@ -251,7 +251,7 @@ impl Parser {
251251
Ok(count) => count,
252252
Err(e) => {
253253
return Err(Error::new(
254-
magnus::exception::runtime_error(),
254+
Ruby::get().unwrap().exception_runtime_error(),
255255
format!("Failed to get page count: {}", e),
256256
))
257257
}
@@ -284,7 +284,7 @@ impl Parser {
284284
}
285285
}
286286
Err(e) => Err(Error::new(
287-
magnus::exception::runtime_error(),
287+
Ruby::get().unwrap().exception_runtime_error(),
288288
format!("Failed to parse PDF: {}", e),
289289
)),
290290
}
@@ -323,7 +323,7 @@ impl Parser {
323323
Ok(result.trim().to_string())
324324
}
325325
Err(e) => Err(Error::new(
326-
magnus::exception::runtime_error(),
326+
Ruby::get().unwrap().exception_runtime_error(),
327327
format!("Failed to parse DOCX file: {}", e),
328328
)),
329329
}
@@ -339,7 +339,7 @@ impl Parser {
339339
Ok(archive) => archive,
340340
Err(e) => {
341341
return Err(Error::new(
342-
magnus::exception::runtime_error(),
342+
Ruby::get().unwrap().exception_runtime_error(),
343343
format!("Failed to open PPTX as ZIP: {}", e),
344344
))
345345
}
@@ -441,7 +441,7 @@ impl Parser {
441441
}
442442
Ok(Event::Text(e)) => {
443443
if in_text_element {
444-
if let Ok(text) = e.unescape() {
444+
if let Ok(text) = e.decode() {
445445
let text_str = text.trim();
446446
if !text_str.is_empty() {
447447
text_parts.push(text_str.to_string());
@@ -493,7 +493,7 @@ impl Parser {
493493
Ok(result)
494494
}
495495
Err(e) => Err(Error::new(
496-
magnus::exception::runtime_error(),
496+
Ruby::get().unwrap().exception_runtime_error(),
497497
format!("Failed to parse Excel file: {}", e),
498498
)),
499499
}
@@ -522,13 +522,13 @@ impl Parser {
522522
loop {
523523
match reader.read_event_into(&mut buf) {
524524
Ok(Event::Text(e)) => {
525-
txt.push_str(&e.unescape().unwrap_or_default());
525+
txt.push_str(&e.decode().unwrap_or_default());
526526
txt.push(' ');
527527
}
528528
Ok(Event::Eof) => break,
529529
Err(e) => {
530530
return Err(Error::new(
531-
magnus::exception::runtime_error(),
531+
Ruby::get().unwrap().exception_runtime_error(),
532532
format!("XML parse error: {}", e),
533533
))
534534
}
@@ -558,7 +558,7 @@ impl Parser {
558558
fn parse(&self, input: String) -> Result<String, Error> {
559559
if input.is_empty() {
560560
return Err(Error::new(
561-
magnus::exception::arg_error(),
561+
Ruby::get().unwrap().exception_arg_error(),
562562
"Input cannot be empty",
563563
));
564564
}
@@ -578,7 +578,7 @@ impl Parser {
578578

579579
let data = fs::read(&path).map_err(|e| {
580580
Error::new(
581-
magnus::exception::io_error(),
581+
Ruby::get().unwrap().exception_io_error(),
582582
format!("Failed to read file: {}", e),
583583
)
584584
})?;
@@ -590,7 +590,7 @@ impl Parser {
590590
fn parse_bytes(&self, data: Vec<u8>) -> Result<String, Error> {
591591
if data.is_empty() {
592592
return Err(Error::new(
593-
magnus::exception::arg_error(),
593+
Ruby::get().unwrap().exception_arg_error(),
594594
"Data cannot be empty",
595595
));
596596
}
@@ -668,7 +668,7 @@ fn parse_bytes_direct(data: Vec<u8>) -> Result<String, Error> {
668668

669669
/// Initialize the Parser class
670670
pub fn init(_ruby: &Ruby, module: RModule) -> Result<(), Error> {
671-
let class = module.define_class("Parser", class::object())?;
671+
let class = module.define_class("Parser", Ruby::get().unwrap().class_object())?;
672672

673673
// Instance methods
674674
class.define_singleton_method("new", function!(Parser::new, -1))?;

0 commit comments

Comments
 (0)