word-to-markdown 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/w2m +1 -1
- data/lib/cliver/dependency_ext.rb +2 -1
- data/lib/word-to-markdown.rb +21 -7
- data/lib/word-to-markdown/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 938db70eb63b1d41df9281525cfb0334b6c1ecec
|
4
|
+
data.tar.gz: 5408876edb42f47971a4344035a66e3bb855ccd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c653fc5026f8fc2a0df92c1d4e6ca8d8c84f7bc70ea03ddfc0e9aca8e27b1d9a2b37e8d2f3b9ba50c775821551af654ee91e371000adef5ba64ab8df562c63d2
|
7
|
+
data.tar.gz: 60310ffd328fa13ef5187e46950c36906e11fcf3ba5190c469d10840829efe084cbd8b1513c1e1c8ea212d251ae6aed235bda224cc81e3e8d4ba734dfc462037
|
data/bin/w2m
CHANGED
@@ -9,7 +9,7 @@ end
|
|
9
9
|
|
10
10
|
if ARGV[0] == "--version"
|
11
11
|
puts "WordToMarkdown v#{WordToMarkdown::VERSION}"
|
12
|
-
puts "LibreOffice v#{WordToMarkdown.soffice.version}"
|
12
|
+
puts "LibreOffice v#{WordToMarkdown.soffice.version}" unless Gem.win_platform?
|
13
13
|
else
|
14
14
|
doc = WordToMarkdown.new ARGV[0]
|
15
15
|
puts doc.to_s
|
@@ -20,12 +20,13 @@ module Cliver
|
|
20
20
|
# Returns the version of the resolved dependency
|
21
21
|
def version
|
22
22
|
return @detected_version if defined? @detected_version
|
23
|
+
return if Gem.win_platform?
|
23
24
|
version = installed_versions.find { |p, v| p == path }
|
24
25
|
@detected_version = version.nil? ? nil : version[1]
|
25
26
|
end
|
26
27
|
|
27
28
|
def major_version
|
28
|
-
version.split(".").first
|
29
|
+
version.split(".").first if version
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
data/lib/word-to-markdown.rb
CHANGED
@@ -27,10 +27,11 @@ class WordToMarkdown
|
|
27
27
|
SOFFICE_VERSION_REQUIREMENT = '> 4.0'
|
28
28
|
|
29
29
|
PATHS = [
|
30
|
+
"*", # Sub'd for ENV["PATH"]
|
30
31
|
"~/Applications/LibreOffice.app/Contents/MacOS",
|
31
32
|
"/Applications/LibreOffice.app/Contents/MacOS",
|
32
|
-
"/
|
33
|
-
"/
|
33
|
+
"/Program Files/LibreOffice 5/program",
|
34
|
+
"/Program Files (x86)/LibreOffice 4/program"
|
34
35
|
]
|
35
36
|
|
36
37
|
# Create a new WordToMarkdown object
|
@@ -49,7 +50,7 @@ class WordToMarkdown
|
|
49
50
|
|
50
51
|
output, status = Open3.capture2e(soffice.path, *args)
|
51
52
|
logger.debug output
|
52
|
-
raise "Command `#{
|
53
|
+
raise "Command `#{soffice.path} #{args.join(" ")}` failed: #{output}" if status.exitstatus != 0
|
53
54
|
output
|
54
55
|
end
|
55
56
|
|
@@ -62,10 +63,7 @@ class WordToMarkdown
|
|
62
63
|
# version - returns the resolved version
|
63
64
|
# open - is the dependency currently open/running?
|
64
65
|
def self.soffice
|
65
|
-
@@soffice_dependency ||= Cliver::Dependency.new(
|
66
|
-
"soffice", SOFFICE_VERSION_REQUIREMENT,
|
67
|
-
:path => "*:" + PATHS.join(":")
|
68
|
-
)
|
66
|
+
@@soffice_dependency ||= Cliver::Dependency.new("soffice", *soffice_dependency_args)
|
69
67
|
end
|
70
68
|
|
71
69
|
def self.logger
|
@@ -84,4 +82,20 @@ class WordToMarkdown
|
|
84
82
|
def to_s
|
85
83
|
document.to_s
|
86
84
|
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
# Workaround for two upstream bugs:
|
89
|
+
# 1. `soffice.exe --version` on windows opens a popup and retuns a null string when manually closed
|
90
|
+
# 2. Even if the second argument to Cliver is nil, Cliver thinks there's a requirement
|
91
|
+
# and will shell out to `soffice.exe --version`
|
92
|
+
# In order to support Windows, don't pass *any* version requirement to Cliver
|
93
|
+
def self.soffice_dependency_args
|
94
|
+
args = [:path => PATHS.join(File::PATH_SEPARATOR)]
|
95
|
+
if Gem.win_platform?
|
96
|
+
args
|
97
|
+
else
|
98
|
+
args.unshift SOFFICE_VERSION_REQUIREMENT
|
99
|
+
end
|
100
|
+
end
|
87
101
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: word-to-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: reverse_markdown
|
@@ -217,3 +217,4 @@ signing_key:
|
|
217
217
|
specification_version: 4
|
218
218
|
summary: Ruby Gem to convert Word documents to markdown
|
219
219
|
test_files: []
|
220
|
+
has_rdoc:
|