kristin 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b45b9bdf45d5b810cd5969ccaa87a7d1254a3403
4
+ data.tar.gz: a62469419326eeaa3b4b8625babc1fbd86407cb8
5
+ SHA512:
6
+ metadata.gz: 9790368a314e9ea6d05d2ece964872b2f4990d37498fdc865fcef47cd4beef811eff613f32b9b80ca0724aab08012c89e294fd331d9b2d991b4fd226781cec69
7
+ data.tar.gz: 99ea595b7b642e4f6f8d6ca14d39e0f875ca205e8acf4ac496c043f285599342884415f9f1971ddcfd6cfc95c3c75c9f03324fbda325460cd689938df7f83389
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kristin.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Richard Nyström
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Kristin
2
+ [![Code Climate](https://codeclimate.com/github/ricn/kristin.png)](https://codeclimate.com/github/ricn/kristin)
3
+
4
+ Convert PDF docs to beautiful HTML files without losing text or format. This gem uses pdf2htmlEX to do the conversion.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'kristin'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install kristin
19
+
20
+ ## Usage
21
+
22
+ You need to install [pdf2htmlEX](https://github.com/coolwanglu/pdf2htmlEX) on your system to use this gem.
23
+
24
+ ```ruby
25
+ require 'kristin'
26
+
27
+ # Converts document.pdf to document.html
28
+ # This requires that the pdf2htmlEX command is present in your PATH.
29
+ Kristin.convert('document.pdf', 'document.html')
30
+ ```
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/kristin.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kristin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kristin"
8
+ spec.version = Kristin::VERSION
9
+ spec.authors = ["Richard Nyström"]
10
+ spec.email = ["ricny046@gmail.com"]
11
+ spec.description = %q{ Convert PDF docs to beautiful HTML files without losing text or format. This gem uses pdf2htmlEX to do the conversion.}
12
+ spec.summary = %q{ Convert PDF docs to beautiful HTML files without losing text or format. This gem uses pdf2htmlEX to do the conversion. }
13
+ spec.homepage = "https://github.com/ricn/kristin"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,3 @@
1
+ module Kristin
2
+ VERSION = "0.1.0"
3
+ end
data/lib/kristin.rb ADDED
@@ -0,0 +1,46 @@
1
+ require "kristin/version"
2
+
3
+ module Kristin
4
+ def self.convert(source, target)
5
+
6
+ raise IOError, "Source file (#{source}) does not exist." if not File.exists?(source)
7
+ raise IOError, "Can't find pdf2htmlex executable in PATH" if not command_available?
8
+
9
+ cmd = "#{pdf2htmlex_command} #{source} #{target}"
10
+
11
+ `#{cmd}`
12
+
13
+ ## TODO: Grab error message from pdf2htmlex and raise a better error
14
+ raise IOError, "Could not convert #{source}" if $?.exitstatus != 0
15
+ end
16
+
17
+ private
18
+
19
+ def self.command_available?
20
+ which("pdf2htmlex") || which("pdf2htmlEX")
21
+ end
22
+
23
+ def self.pdf2htmlex_command
24
+ cmd = nil
25
+ if which("pdf2htmlex")
26
+ cmd = "pdf2htmlex"
27
+ elsif which("pdf2htmlEX")
28
+ cmd = "pdf2htmlEX"
29
+ end
30
+
31
+ cmd
32
+ end
33
+
34
+ def self.which(cmd)
35
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
36
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
37
+ exts.each do |ext|
38
+ exe = File.join(path, "#{cmd}#{ext}")
39
+
40
+ return exe if File.executable? exe
41
+ end
42
+ end
43
+
44
+ return nil
45
+ end
46
+ end
Binary file
Binary file