djvu 0.1.2 → 0.2.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 +4 -4
- data/README.md +8 -0
- data/djvu.gemspec +6 -1
- data/lib/djvu/version.rb +1 -1
- data/lib/djvu.rb +43 -13
- metadata +1 -5
- data/.codeclimate.yml +0 -25
- data/.gitignore +0 -10
- data/.rspec +0 -2
- data/.travis.yml +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 429d5cbf8b922aae12d9834ef45985363abaeb54
|
4
|
+
data.tar.gz: d7c37ac6c7ff1593fd293ef554ccfb326c645687
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16559b6be5719fe4d2124e4f885e8d1b0e8d1a445d4ab7737224fabd31b8c1534085a0c38e28579c3d542750cc6a48d25c795844f2b7ff741d937c7aa21ec9b4
|
7
|
+
data.tar.gz: bd9692b0c1951df0e2bb0d3de8774026c49b61d641054fda4a9c777126128e477eb6e54729ebf5301d82984cad4ca6932429420a1dab6ed7be417ebacb42d419
|
data/README.md
CHANGED
@@ -52,12 +52,20 @@ MiniMagick::Image.open('1.ppm').write('1.png')
|
|
52
52
|
```
|
53
53
|
### [djvutxt](http://djvu.sourceforge.net/doc/man/djvutxt.html)
|
54
54
|
```ruby
|
55
|
+
# Extract text layer from page to txt file
|
55
56
|
Djvu.file('Alice_in_Wonderland.djvu').djvutxt(page: 8, output_file: '1.txt')
|
57
|
+
# Extract text layer from page to variable
|
58
|
+
text = Djvu.file('Alice_in_Wonderland.djvu').djvutxt(page: 8)
|
56
59
|
```
|
57
60
|
### [djvudump](http://djvu.sourceforge.net/doc/man/djvudump.html)
|
58
61
|
```ruby
|
59
62
|
dump = Djvu.file('Alice_in_Wonderland.djvu').djvudump
|
60
63
|
```
|
64
|
+
### [djvused](http://djvu.sourceforge.net/doc/man/djvused.html)
|
65
|
+
```ruby
|
66
|
+
# Getting number of pages in djvu file
|
67
|
+
num = Djvu.file('Alice_in_Wonderland.djvu').djvused(e: 'n')
|
68
|
+
```
|
61
69
|
|
62
70
|
## Contributing
|
63
71
|
|
data/djvu.gemspec
CHANGED
@@ -15,7 +15,12 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
-
f.match(%r{^(test|spec|features|tmp)/})
|
18
|
+
f.match(%r{^(test|spec|features|tmp)/}) \
|
19
|
+
|| f.match(%r{^(\.rubocop\.yml
|
20
|
+
|\.codeclimate\.yml
|
21
|
+
|\.gitignore
|
22
|
+
|\.rspec
|
23
|
+
|\.travis\.yml)$}x)
|
19
24
|
end
|
20
25
|
spec.bindir = "exe"
|
21
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
data/lib/djvu/version.rb
CHANGED
data/lib/djvu.rb
CHANGED
@@ -7,6 +7,10 @@ module Djvu
|
|
7
7
|
class Exception < ::StandardError
|
8
8
|
end
|
9
9
|
|
10
|
+
# Exception that is raised if no input file.
|
11
|
+
class InputFileNotFound < Djvu::Exception
|
12
|
+
end
|
13
|
+
|
10
14
|
# Exception that is raised if no output file.
|
11
15
|
class OutputFileNotFound < Djvu::Exception
|
12
16
|
end
|
@@ -15,42 +19,68 @@ module Djvu
|
|
15
19
|
class UnprocessablePage < Djvu::Exception
|
16
20
|
end
|
17
21
|
|
22
|
+
# Can't process page.
|
23
|
+
class MissingRequiredArgument < Djvu::Exception
|
24
|
+
end
|
25
|
+
|
18
26
|
def self.file(djvufile)
|
19
|
-
Djvu::
|
27
|
+
Djvu::Tools.new(djvufile)
|
20
28
|
end
|
21
29
|
|
22
|
-
class
|
30
|
+
class Tools
|
23
31
|
def initialize(djvufile)
|
24
32
|
@djvufile = djvufile
|
25
33
|
self
|
26
34
|
end
|
27
35
|
|
28
36
|
def ddjvu(options)
|
29
|
-
raise
|
37
|
+
raise(MissingRequiredArgument, '-format is required') unless options[:format]
|
38
|
+
|
39
|
+
command = []
|
40
|
+
command << 'ddjvu'
|
41
|
+
command << parse_options(options)
|
42
|
+
command << @djvufile
|
43
|
+
command << options[:output_file] if options[:output_file]
|
30
44
|
|
31
|
-
result, status = Open3.capture2e(
|
45
|
+
result, status = Open3.capture2e(command.join(' '))
|
32
46
|
|
33
47
|
status.success? || raise(UnprocessablePage, result)
|
34
48
|
end
|
35
49
|
|
36
|
-
def djvutxt(options)
|
37
|
-
|
50
|
+
def djvutxt(options = false)
|
51
|
+
command = []
|
52
|
+
command << 'djvutxt'
|
53
|
+
command << parse_options(options, '--%s=%s') if options
|
54
|
+
command << @djvufile
|
55
|
+
command << options[:output_file] if options && options[:output_file]
|
38
56
|
|
39
|
-
result, status = Open3.capture2e(
|
57
|
+
result, status = Open3.capture2e(command.join(' '))
|
40
58
|
|
41
59
|
status.success? || raise(UnprocessablePage, result)
|
60
|
+
|
61
|
+
result
|
42
62
|
end
|
43
63
|
|
44
|
-
def djvudump(options =
|
45
|
-
|
64
|
+
def djvudump(options = false)
|
65
|
+
command = []
|
66
|
+
command << 'djvudump'
|
67
|
+
command << parse_options(options, '-%s %s') if options
|
68
|
+
command << @djvufile
|
69
|
+
|
70
|
+
result, status = Open3.capture2e(command.join(' '))
|
46
71
|
|
47
72
|
status.success? || raise(UnprocessablePage, result)
|
48
73
|
|
49
|
-
result unless options[:o]
|
74
|
+
result unless options && options[:o]
|
50
75
|
end
|
51
76
|
|
52
|
-
def djvused(options =
|
53
|
-
|
77
|
+
def djvused(options = false)
|
78
|
+
command = []
|
79
|
+
command << 'djvused'
|
80
|
+
command << parse_options(options, "-%s '%s'") if options
|
81
|
+
command << @djvufile
|
82
|
+
|
83
|
+
result, status = Open3.capture2e(command.join(' '))
|
54
84
|
|
55
85
|
status.success? || raise(UnprocessablePage, result)
|
56
86
|
|
@@ -59,7 +89,7 @@ module Djvu
|
|
59
89
|
|
60
90
|
private
|
61
91
|
|
62
|
-
def parse_options(options, pattern =
|
92
|
+
def parse_options(options, pattern = '-%s=%s')
|
63
93
|
command = []
|
64
94
|
options.each do |key, val|
|
65
95
|
next if key === :output_file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: djvu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 1v
|
@@ -73,10 +73,6 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- ".codeclimate.yml"
|
77
|
-
- ".gitignore"
|
78
|
-
- ".rspec"
|
79
|
-
- ".travis.yml"
|
80
76
|
- Gemfile
|
81
77
|
- LICENSE.txt
|
82
78
|
- README.md
|
data/.codeclimate.yml
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
---
|
2
|
-
engines:
|
3
|
-
duplication:
|
4
|
-
enabled: true
|
5
|
-
config:
|
6
|
-
languages:
|
7
|
-
- ruby
|
8
|
-
- javascript
|
9
|
-
- python
|
10
|
-
- php
|
11
|
-
fixme:
|
12
|
-
enabled: true
|
13
|
-
rubocop:
|
14
|
-
enabled: true
|
15
|
-
ratings:
|
16
|
-
paths:
|
17
|
-
- "**.inc"
|
18
|
-
- "**.js"
|
19
|
-
- "**.jsx"
|
20
|
-
- "**.module"
|
21
|
-
- "**.php"
|
22
|
-
- "**.py"
|
23
|
-
- "**.rb"
|
24
|
-
exclude_paths:
|
25
|
-
- spec/
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
sudo: true
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 1.9.3
|
5
|
-
- 2.0.0
|
6
|
-
- 2.1.7
|
7
|
-
- 2.2.1
|
8
|
-
- 2.2.3
|
9
|
-
- 2.3.1
|
10
|
-
before_install:
|
11
|
-
- sudo apt-get update
|
12
|
-
- wget http://downloads.sourceforge.net/djvu/djvulibre-3.5.27.tar.gz
|
13
|
-
- tar -xvzf djvulibre-3.5.27.tar.gz
|
14
|
-
- rm djvulibre-3.5.27.tar.gz
|
15
|
-
- cd djvulibre-3.5.27
|
16
|
-
- sudo ./configure
|
17
|
-
- sudo make
|
18
|
-
- sudo make install
|
19
|
-
- cd ../
|
20
|
-
- sudo rm -rf djvulibre-3.5.27
|
21
|
-
- gem install bundler -v 1.13.6
|
22
|
-
addons:
|
23
|
-
code_climate:
|
24
|
-
repo_token: dcdb2b8d67dad3b794f81cdb25ec5c016b677002fadb5296f8ae12c00c789cb8
|