Skip to content

Commit 267ff75

Browse files
committed
remove sqlite3 as a gem dependency and convert to an optional dependency required for SketchRipper
1 parent 3df3f49 commit 267ff75

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ File format | Supported? | Dependencies
2222
.docx | x |
2323
.pdf | x | Poppler-utils
2424
.txt | x |
25-
.sketch | x |
25+
.sketch | x | Sqlite3
2626

2727
## Quickstart
2828

@@ -63,3 +63,4 @@ File format | Supported? | Dependencies
6363
- Ruby version >= 1.9.2
6464
- [Poppler-utils/(pdftotext)](http://poppler.freedesktop.org/) (PDF)
6565
- [Antiword](http://www.winfield.demon.nl/) (docx) more info: http://linux.die.net/man/1/antiword
66+
- Sketch support requires sqlite3 and the [sqlite3 gem](https://rubygems.org/gems/sqlite3) gem

doc_ripper.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
2121
spec.requirements << 'Antiword'
2222
spec.requirements << "pdftotext/poppler"
2323

24-
spec.add_dependency "sqlite3", "~> 1.3.11"
2524
spec.add_dependency "CFPropertyList", '~> 2.3'
25+
spec.add_dependency 'colored', '~> 1.2'
2626

2727
spec.add_development_dependency "bundler", "~> 1.6"
2828
spec.add_development_dependency "rake", "~> 10.0"

lib/doc_ripper.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'shellwords'
2-
require "sqlite3"
32
require "doc_ripper/version"
43
require "doc_ripper/base"
54
require "doc_ripper/text_ripper"
@@ -21,4 +20,4 @@ def rip!(path)
2120
text || raise(FileNotFound)
2221
end
2322
end
24-
end
23+
end

lib/doc_ripper/formats/sketch_ripper.rb

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
require 'cfpropertylist'
2+
require 'colored'
3+
4+
SQLITE_LOAD_WARNING = 'SQLite3 optional dependency not found. Sketch files are not supported in this mode.'.yellow
5+
6+
begin
7+
# gem 'sqlite3'
8+
require 'sqlite3'
9+
rescue LoadError
10+
warn SQLITE_LOAD_WARNING
11+
end
212

313
module DocRipper
414
module Formats
515
class SketchRipper < Ripper::Base
616

17+
class Sqlite3NotFound < StandardError
18+
end
19+
720
class CFPropertyList::CFString
821
def to_s
922
value
@@ -33,6 +46,11 @@ def sketch_page?
3346
end
3447
end
3548

49+
def initialize(file_path, options= {})
50+
raise Sqlite3NotFound if !defined?(SQLite3)
51+
super
52+
end
53+
3654
def read_type
3755
:mem
3856
end
@@ -79,4 +97,4 @@ def text_objects(data)
7997
end
8098
end
8199
end
82-
end
100+
end

lib/doc_ripper/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module DocRipper
2-
VERSION = "0.0.7.1"
2+
VERSION = "0.0.7.2"
33
end
44

55

0 commit comments

Comments
 (0)