mupdf 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +14 -1
- data/lib/mupdf/document.rb +21 -0
- data/lib/mupdf/info.rb +25 -0
- data/lib/mupdf/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 025aace876d1fc5f6ba89c7e94fb7a618b645c5011d1eb7d3923252ca1643693
|
4
|
+
data.tar.gz: 9cc27d161818550e2b3290933652be4c1b8474f550f7c6f71a59eda5af4f02cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baf0ad502de63e12d938481d8944a96091a74f85e5d42189bcac9b7b0afb5b262f133e70eae434ac3f129349105262ececeff6e3feadbc037f4be14fd7127502
|
7
|
+
data.tar.gz: 90a9bedd5984280f820b76bbbcab596bea290bdb79c6e699cf029898569cc006e23e7c26ea1877a95d8406a025e2dd70f2faec675f8aab0af2b143d9fa76352f
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -14,6 +14,19 @@ gem install mupdf
|
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
+
### Document
|
18
|
+
|
19
|
+
A `MuPDF::Document` wraps for a file:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
document = MuPDF::Document.new('./file.pdf')
|
23
|
+
```
|
24
|
+
|
25
|
+
#### Info
|
26
|
+
|
27
|
+
The `info` command displays information about a document such as the number of pages:
|
28
|
+
|
17
29
|
```ruby
|
18
|
-
|
30
|
+
info = document.info
|
31
|
+
info.pages # e.g. 2
|
19
32
|
```
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MuPDF
|
4
|
+
# A wrapper for a PDF document allowing for MuPDF APIs.
|
5
|
+
class Document
|
6
|
+
# @param pathname [Pathname]
|
7
|
+
def initialize(pathname)
|
8
|
+
@pathname = pathname
|
9
|
+
end
|
10
|
+
|
11
|
+
# @raise [MuPDF::CommandError]
|
12
|
+
#
|
13
|
+
# @return [MuPDF::Info]
|
14
|
+
def info
|
15
|
+
@info ||= begin
|
16
|
+
result = MuPDF.mutool('info', String(@pathname))
|
17
|
+
MuPDF::Info.parse(result)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/mupdf/info.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MuPDF
|
4
|
+
# A wrapper for the result of a `mutool info ...` command.
|
5
|
+
class Info
|
6
|
+
PARSE_REGEX = /^Pages: (?<pages>\d+)$/
|
7
|
+
|
8
|
+
# @!attribute description
|
9
|
+
# @return [String] The description of the task.
|
10
|
+
attr_reader :pages
|
11
|
+
|
12
|
+
# @param text [String]
|
13
|
+
#
|
14
|
+
# @return [MuPDF::Info]
|
15
|
+
def self.parse(text)
|
16
|
+
match = text.match(PARSE_REGEX)
|
17
|
+
new(pages: Integer(match[:pages]))
|
18
|
+
end
|
19
|
+
|
20
|
+
# @param pages [Integer]
|
21
|
+
def initialize(pages:)
|
22
|
+
@pages = pages
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/mupdf/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mupdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Sylvestre
|
@@ -51,6 +51,8 @@ files:
|
|
51
51
|
- bin/setup
|
52
52
|
- lib/mupdf.rb
|
53
53
|
- lib/mupdf/command_error.rb
|
54
|
+
- lib/mupdf/document.rb
|
55
|
+
- lib/mupdf/info.rb
|
54
56
|
- lib/mupdf/version.rb
|
55
57
|
homepage: https://github.com/ksylvest/mupdf
|
56
58
|
licenses:
|
@@ -58,8 +60,8 @@ licenses:
|
|
58
60
|
metadata:
|
59
61
|
rubygems_mfa_required: 'true'
|
60
62
|
homepage_uri: https://github.com/ksylvest/mupdf
|
61
|
-
source_code_uri: https://github.com/ksylvest/mupdf/tree/v0.
|
62
|
-
changelog_uri: https://github.com/ksylvest/mupdf/releases/tag/v0.
|
63
|
+
source_code_uri: https://github.com/ksylvest/mupdf/tree/v0.3.0
|
64
|
+
changelog_uri: https://github.com/ksylvest/mupdf/releases/tag/v0.3.0
|
63
65
|
documentation_uri: https://mupdf.ksylvest.com/
|
64
66
|
post_install_message:
|
65
67
|
rdoc_options: []
|