mupdf 0.2.0 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcb2e83601972892c61f01d0a91ad66f53c1d1a1df766c45c469c19eb00de40f
4
- data.tar.gz: aad84a0df2ba34f3b30d6a9d8972ac8d82ecdc676178921e14cd08056c16b462
3
+ metadata.gz: 025aace876d1fc5f6ba89c7e94fb7a618b645c5011d1eb7d3923252ca1643693
4
+ data.tar.gz: 9cc27d161818550e2b3290933652be4c1b8474f550f7c6f71a59eda5af4f02cc
5
5
  SHA512:
6
- metadata.gz: acab8e6d850da0af08debf29efce668cec344eea8f107d5a907c39852503d18a5605724af28aed3bdb4bfa7966866f9ca7cdb02101eafcb82c5945f74308121b
7
- data.tar.gz: '08bbc69726f80f47888c5dc5dcfc76282f6b70f23199bacc2f3600103264cb011e46344e0f8ffa53877cd528f11f0e5a9d36947381c5c76a3fe6a22f6f338131'
6
+ metadata.gz: baf0ad502de63e12d938481d8944a96091a74f85e5d42189bcac9b7b0afb5b262f133e70eae434ac3f129349105262ececeff6e3feadbc037f4be14fd7127502
7
+ data.tar.gz: 90a9bedd5984280f820b76bbbcab596bea290bdb79c6e699cf029898569cc006e23e7c26ea1877a95d8406a025e2dd70f2faec675f8aab0af2b143d9fa76352f
data/Gemfile CHANGED
@@ -10,4 +10,5 @@ gem 'rspec_junit_formatter'
10
10
  gem 'rubocop'
11
11
  gem 'rubocop-rake'
12
12
  gem 'rubocop-rspec'
13
+ gem 'simplecov'
13
14
  gem 'yard'
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
- MuPDF.mutool('info', 'file.pdf')
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MuPDF
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
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.2.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.2.0
62
- changelog_uri: https://github.com/ksylvest/mupdf/releases/tag/v0.2.0
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: []