djvu 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2465fb546da7a9d0a7e5d846255f446d4f3cc5e3
4
+ data.tar.gz: 3c88685015d29f4e3719083fec06215b431fe364
5
+ SHA512:
6
+ metadata.gz: 72cd537ddac6797dca8e604d88f85bebe5c61095d9080995cd43e43c7bf448cd37be858a790ffcc29918bafbb08a875d55b4a2f4b514b88ea1270cca1bbe7c8f
7
+ data.tar.gz: ea3eface1db0475a271d49fafdc86421d26af553c05ecb50a2ba2743cd4f99398dffaec86f0c362598d71736237360f7c34240ef9e7507f9ee70ae27262c9475
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /Guardfile
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.13.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in djvu.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 1v
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # Djvu
2
+
3
+ Ruby interface for [DjVuLibre](http://djvu.sourceforge.net/doc/index.html) tools.
4
+
5
+ ## Installation
6
+
7
+ Install [DjVuLibre](http://djvu.sourceforge.net/index.html) with this oneliner:
8
+
9
+ ```
10
+ sudo apt-get update && sudo apt-get install checkinstall && wget http://downloads.sourceforge.net/djvu/djvulibre-3.5.27.tar.gz && tar -xvzf djvulibre-3.5.27.tar.gz && rm djvulibre-3.5.27.tar.gz && cd djvulibre-3.5.27 && sudo ./configure && sudo make && sudo checkinstall && cd ../ && sudo rm -rf djvulibre-3.5.27
11
+ ```
12
+
13
+ If you need remove package:
14
+
15
+ ```
16
+ sudo dpkg -r djvulibre
17
+ ```
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ ```ruby
22
+ gem 'djvu'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install djvu
32
+
33
+ And require:
34
+
35
+ ```ruby
36
+ require 'djvu'
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ ### [ddjvu](http://djvu.sourceforge.net/doc/man/ddjvu.html)
42
+ ```
43
+ Djvu.file('Alice_in_Wonderland.djvu').ddjvu(format: 'ppm', page: 1, output_file: '1.ppm')
44
+ ```
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/1v/djvu.
49
+
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
54
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "djvu"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/djvu.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'djvu/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "djvu"
8
+ spec.version = Djvu::VERSION
9
+ spec.authors = ["1v"]
10
+ spec.email = ["forwardin+75785742@yandex.ru"]
11
+
12
+ spec.summary = %q{Ruby interface for DjVuLibre tools.}
13
+ spec.description = %q{Ruby interface for DjVuLibre tools.}
14
+ spec.homepage = "https://github.com/1v/djvu"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.13"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "codeclimate-test-reporter", "~> 0.6", ">= 0.6.0"
28
+ end
data/lib/djvu.rb ADDED
@@ -0,0 +1,47 @@
1
+ require 'djvu/version'
2
+ require 'open3'
3
+
4
+ module Djvu
5
+
6
+ # Default exception class for Djvu.
7
+ class Exception < ::StandardError
8
+ end
9
+
10
+ # Exception that is raised if no output file.
11
+ class OutputFileNotFound < Djvu::Exception
12
+ end
13
+
14
+ # Can't process page.
15
+ class UnprocessablePage < Djvu::Exception
16
+ end
17
+
18
+ def self.file(djvufile)
19
+ Djvu::File.new(djvufile)
20
+ end
21
+
22
+ class File
23
+ def initialize(djvufile)
24
+ @djvufile = djvufile
25
+ self
26
+ end
27
+
28
+ def ddjvu(options)
29
+ raise OutputFileNotFound unless options[:output_file]
30
+
31
+ result, status = Open3.capture2e('ddjvu ' + [parse_options(options), @djvufile, options[:output_file]].join(' '))
32
+
33
+ status.success? || raise(UnprocessablePage, result)
34
+ end
35
+
36
+ private
37
+
38
+ def parse_options(options)
39
+ command = []
40
+ options.each do |key, val|
41
+ next if key === :output_file
42
+ command << "-#{key}=#{val}"
43
+ end
44
+ command.join(' ')
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ module Djvu
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: djvu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - 1v
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-10-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: codeclimate-test-reporter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.6'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 0.6.0
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '0.6'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 0.6.0
75
+ description: Ruby interface for DjVuLibre tools.
76
+ email:
77
+ - forwardin+75785742@yandex.ru
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - ".gitignore"
83
+ - ".rspec"
84
+ - ".travis.yml"
85
+ - Gemfile
86
+ - LICENSE.txt
87
+ - README.md
88
+ - Rakefile
89
+ - bin/console
90
+ - bin/setup
91
+ - djvu.gemspec
92
+ - lib/djvu.rb
93
+ - lib/djvu/version.rb
94
+ homepage: https://github.com/1v/djvu
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.5.1
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Ruby interface for DjVuLibre tools.
118
+ test_files: []
119
+ has_rdoc: