word-to-markdown 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d0a6d4dbb16a5c53ffc336d781b5ca275acaf61
4
- data.tar.gz: 16c255b3f304c01a89d215500cdc9e235149e119
3
+ metadata.gz: 8826b727f290781e7713325662d056482018d730
4
+ data.tar.gz: 8692363359366aac70359bf251ccba409f80bba7
5
5
  SHA512:
6
- metadata.gz: 4b6ecd85ac312939fff436970472dc3d350b6d75d8a42bb82d3633a06f95ac8a970f04765da64f2ac5a2221ef492ed6ba7efd5b06a8e4ea850998826cc85a4b4
7
- data.tar.gz: 4612cadf0ba9f7b3409a7d0d378f960084bcca8980e3b6ca1e7436dc67011a33dbbb7817641cb177b769f83e92abb09f29e8758b151e2d4076e3395d00ccd4f7
6
+ metadata.gz: 8db1e766ad6bfc341de71a4fc82d14f8a3d109005f2bda9d779af2bd7b0f722d160cf873bff98cf56f9fa7929ab9282e945d249fc220fa56beafe46bd962cf9c
7
+ data.tar.gz: fd84315c249e983a6bdf073a8573d2fbca82886ed05da15b8325ceca4f655b3181cee6ee20cf888c933a4b10794a5c5145ad86a8f9ebf8f9550163de9ce284da
@@ -2,12 +2,14 @@ module Nokogiri
2
2
  module XML
3
3
  class Element
4
4
 
5
+ DEFAULT_FONT_SIZE = 12.to_f
6
+
5
7
  # The node's font size
6
8
  # Used for guessing heading sizes
7
9
  #
8
10
  # Returns a float with the font-size
9
11
  def font_size
10
- styles['font-size'].to_f if styles['font-size']
12
+ styles['font-size'] ? styles['font-size'].to_f : DEFAULT_FONT_SIZE
11
13
  end
12
14
 
13
15
  def bold?
@@ -4,6 +4,8 @@ require 'premailer'
4
4
  require 'nokogiri'
5
5
  require 'nokogiri-styles'
6
6
  require 'tmpdir'
7
+ require 'rbconfig'
8
+ require 'open3'
7
9
  require_relative 'word-to-markdown/version'
8
10
  require_relative 'word-to-markdown/document'
9
11
  require_relative 'word-to-markdown/converter'
@@ -29,34 +31,42 @@ class WordToMarkdown
29
31
  converter.convert!
30
32
  end
31
33
 
32
- # source: https://github.com/ricn/libreconv/blob/master/lib/libreconv.rb#L48
33
- def self.which(cmd)
34
- exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
35
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
36
- exts.each do |ext|
37
- exe = File.join(path, "#{cmd}#{ext}")
38
- return exe if File.executable? exe
39
- end
34
+ # source: https://stackoverflow.com/questions/11784109/detecting-operating-systems-in-ruby
35
+ def self.os
36
+ @os ||= (
37
+ host_os = RbConfig::CONFIG['host_os']
38
+ case host_os
39
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
40
+ :windows
41
+ when /darwin|mac os/
42
+ :macosx
43
+ when /linux/
44
+ :linux
45
+ when /solaris|bsd/
46
+ :unix
47
+ else
48
+ raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
40
49
  end
41
-
42
- return nil
50
+ )
43
51
  end
44
52
 
45
53
  def self.soffice_path
46
- if RUBY_PLATFORM.include?("darwin")
54
+ case os
55
+ when :macosx
47
56
  %w[~/Applications /Applications]
48
- .map { |f| File.join(f, "/LibreOffice.app/Contents/MacOS/soffice") }
49
- .find { |f| File.file?(f) } || -> { raise RuntimeError.new("Coudln't find LibreOffice on your machine.") }.call
57
+ .map { |f| File.expand_path(File.join(f, "/LibreOffice.app/Contents/MacOS/soffice")) }
58
+ .find { |f| File.file?(f) }
59
+ when :windows
60
+ 'C:\Program Files (x86)\LibreOffice 4\program\soffice.exe'
50
61
  else
51
- soffice_path ||= which("soffice")
52
- soffice_path ||= which("soffice.bin")
53
- soffice_path ||= "soffice"
62
+ "soffice"
54
63
  end
55
64
  end
56
65
 
57
- # Ideally this would be done via open3, but Travis CI can't seen to find soffice when we do
58
66
  def self.run_command(*args)
59
- `#{soffice_path} #{args.join(' ')}`
67
+ output, status = Open3.capture2e(soffice_path, *args)
68
+ raise "Command `#{soffice_path} #{args.join(" ")}` failed: #{output}" if status != 0
69
+ output
60
70
  end
61
71
 
62
72
  def self.soffice_version
@@ -85,7 +85,7 @@ class WordToMarkdown
85
85
 
86
86
  def raw_html
87
87
  @raw_html ||= begin
88
- WordToMarkdown::run_command '--headless', '--convert-to', 'html', "'#{path}'", '--outdir', tmpdir
88
+ WordToMarkdown::run_command '--headless', '--convert-to', 'html', path, '--outdir', tmpdir
89
89
  html = File.read dest_path
90
90
  File.delete dest_path
91
91
  html
@@ -1,3 +1,3 @@
1
1
  class WordToMarkdown
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  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.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Balter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-16 00:00:00.000000000 Z
11
+ date: 2015-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reverse_markdown
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.5'
19
+ version: '0.6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.5'
26
+ version: '0.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: descriptive_statistics
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.1'
33
+ version: '2.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.1'
40
+ version: '2.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: premailer
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.3'
75
+ version: '10.4'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.3'
82
+ version: '10.4'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: shoulda
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -94,20 +94,6 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.5'
97
- - !ruby/object:Gem::Dependency
98
- name: rdoc
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '4.1'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '4.1'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: bundler
113
99
  requirement: !ruby/object:Gem::Requirement
@@ -128,28 +114,28 @@ dependencies:
128
114
  requirements:
129
115
  - - "~>"
130
116
  - !ruby/object:Gem::Version
131
- version: '0.9'
117
+ version: '0.10'
132
118
  type: :development
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
122
  - - "~>"
137
123
  - !ruby/object:Gem::Version
138
- version: '0.9'
124
+ version: '0.10'
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: mocha
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
129
  - - "~>"
144
130
  - !ruby/object:Gem::Version
145
- version: '1.0'
131
+ version: '1.1'
146
132
  type: :development
147
133
  prerelease: false
148
134
  version_requirements: !ruby/object:Gem::Requirement
149
135
  requirements:
150
136
  - - "~>"
151
137
  - !ruby/object:Gem::Version
152
- version: '1.0'
138
+ version: '1.1'
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: minitest
155
141
  requirement: !ruby/object:Gem::Requirement