Skip to content

Commit

Permalink
Replace Book kind with Ebook
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalecot committed Jan 30, 2024
1 parent e4975f0 commit afd9026
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 24 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

- Add `Compressed` kind
- Add `Diagram` kind
- Add `Ebook` kind
- Add `Formula` kind
- Add `Metadata` kind
- Add `Other` kind
- Add `Presentation` kind
- Add `Spreadsheet` kind
- Change `FileFormat::from_bytes` argument type
- Drop `Application` kind
- Drop `Book` kind
- Drop `Certificate` kind
- Drop `Compression` kind
- Drop `Syndication` kind
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,6 @@ identification.
- Waveform Audio (WAV)
- Windows Media Audio (WMA)

### Book

- Broad Band eBook (BBeB)
- Electronic Publication (EPUB)
- FictionBook (FB2)
- FictionBook Zipped (FBZ)
- Microsoft Reader (LIT)
- Mobipocket (MOBI)

### Compressed

- BZip3 (BZ3)
Expand Down Expand Up @@ -225,6 +216,15 @@ identification.
- Uniform Office Format Text (UOT)
- WordPerfect Document (WPD)

### Ebook

- Broad Band eBook (BBeB)
- Electronic Publication (EPUB)
- FictionBook (FB2)
- FictionBook Zipped (FBZ)
- Microsoft Reader (LIT)
- Mobipocket (MOBI)

### Executable

- Commodore 64 Program (PRG)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions src/formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ formats! {
short_name = "BBeB"
media_type = "application/x-lrf"
extension = "lrf"
kind = Book
kind = Ebook

format = Bzip
name = "bzip"
Expand Down Expand Up @@ -650,7 +650,7 @@ formats! {
short_name = "EPUB"
media_type = "application/epub+zip"
extension = "epub"
kind = Book
kind = Ebook

format = EmbeddedOpentype
name = "Embedded OpenType"
Expand Down Expand Up @@ -747,14 +747,14 @@ formats! {
short_name = "FB2"
media_type = "application/x-fb2+xml"
extension = "fb2"
kind = Book
kind = Ebook

format = FictionbookZipped
name = "FictionBook Zipped"
short_name = "FBZ"
media_type = "application/x-fbz"
extension = "fbz"
kind = Book
kind = Ebook

format = Filmbox
name = "Filmbox"
Expand Down Expand Up @@ -1418,7 +1418,7 @@ formats! {
short_name = "LIT"
media_type = "application/x-ms-reader"
extension = "lit"
kind = Book
kind = Ebook

format = MicrosoftSoftwareInstaller
name = "Microsoft Software Installer"
Expand Down Expand Up @@ -1509,7 +1509,7 @@ formats! {
short_name = "MOBI"
media_type = "application/x-mobipocket-ebook"
extension = "mobi"
kind = Book
kind = Ebook

format = Model3dAscii
name = "Model 3D ASCII"
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,6 @@ pub enum Kind {
Archive,
/// Musics, sound effects, and spoken audio recordings.
Audio,
/// Electronic books.
Book,
/// Compressed single files or streams.
Compressed,
/// Organized collections of data.
Expand All @@ -341,6 +339,8 @@ pub enum Kind {
Disk,
/// Word processing and desktop publishing documents.
Document,
/// Electronic books.
Ebook,
/// Machine-executable code, virtual machine code and shared libraries.
Executable,
/// Typefaces used for displaying text on screen or in print.
Expand Down
14 changes: 7 additions & 7 deletions tests/book.rs → tests/ebook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,45 @@ use file_format::FileFormat;

#[test]
fn test_broad_band_ebook() {
let fmt = FileFormat::from_file("fixtures/book/sample.lrf").unwrap();
let fmt = FileFormat::from_file("fixtures/ebook/sample.lrf").unwrap();
assert_eq!(fmt, FileFormat::BroadBandEbook);
}

#[cfg(feature = "reader-zip")]
#[test]
fn test_electronic_publication() {
let fmt = FileFormat::from_file("fixtures/book/sample.epub").unwrap();
let fmt = FileFormat::from_file("fixtures/ebook/sample.epub").unwrap();
assert_eq!(fmt, FileFormat::ElectronicPublication);
}

#[test]
fn test_fictionbook_1() {
let fmt = FileFormat::from_file("fixtures/book/sample1.fb2").unwrap();
let fmt = FileFormat::from_file("fixtures/ebook/sample1.fb2").unwrap();
assert_eq!(fmt, FileFormat::Fictionbook);
}

#[cfg(feature = "reader-xml")]
#[test]
fn test_fictionbook_2() {
let fmt = FileFormat::from_file("fixtures/book/sample2.fb2").unwrap();
let fmt = FileFormat::from_file("fixtures/ebook/sample2.fb2").unwrap();
assert_eq!(fmt, FileFormat::Fictionbook);
}

#[cfg(feature = "reader-zip")]
#[test]
fn test_fictionbook_zipped() {
let fmt = FileFormat::from_file("fixtures/book/sample.fbz").unwrap();
let fmt = FileFormat::from_file("fixtures/ebook/sample.fbz").unwrap();
assert_eq!(fmt, FileFormat::FictionbookZipped);
}

#[test]
fn test_microsoft_reader() {
let fmt = FileFormat::from_file("fixtures/book/sample.lit").unwrap();
let fmt = FileFormat::from_file("fixtures/ebook/sample.lit").unwrap();
assert_eq!(fmt, FileFormat::MicrosoftReader);
}

#[test]
fn test_mobipocket() {
let fmt = FileFormat::from_file("fixtures/book/sample.mobi").unwrap();
let fmt = FileFormat::from_file("fixtures/ebook/sample.mobi").unwrap();
assert_eq!(fmt, FileFormat::Mobipocket);
}

0 comments on commit afd9026

Please sign in to comment.