html2odt 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/html2odt.gemspec +7 -7
- data/lib/html2odt.rb +1 -0
- data/lib/html2odt/dimensions_patches.rb +28 -0
- data/lib/html2odt/document.rb +2 -2
- data/lib/html2odt/image.rb +5 -14
- data/lib/html2odt/version.rb +1 -1
- metadata +28 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67d0f7c76e86cb16aa718ed1b4868ff957878227
|
4
|
+
data.tar.gz: efde21663754a80ab324d80bfb04935fbd712bb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f47e1fddc20d3967cefbb9ee8397e49ef52e2a94479fecc9393f55ff49e7ed5ad4def7cc47ebfb6814b5f321484e5cf008230ba55226d3240a0c8206e7e2145
|
7
|
+
data.tar.gz: 5edbcb7ce66dafa336a02baee0dbe41fda7faf332db8579e6c7bf591fe1617c28f4e8378c9a6f059a6e7b610665aca57387165395f5db5072d4a317c4f90abda
|
data/CHANGELOG.md
CHANGED
data/html2odt.gemspec
CHANGED
@@ -19,12 +19,12 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
spec.executables << "html2odt.rb"
|
21
21
|
|
22
|
-
spec.add_dependency "dimensions"
|
23
|
-
spec.add_dependency "nokogiri"
|
24
|
-
spec.add_dependency "rubyzip"
|
22
|
+
spec.add_dependency "dimensions"
|
23
|
+
spec.add_dependency "nokogiri"
|
24
|
+
spec.add_dependency "rubyzip"
|
25
25
|
|
26
|
-
spec.add_development_dependency "bundler"
|
27
|
-
spec.add_development_dependency "rake"
|
28
|
-
spec.add_development_dependency "minitest"
|
29
|
-
spec.add_development_dependency "fakeweb"
|
26
|
+
spec.add_development_dependency "bundler"
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
spec.add_development_dependency "minitest"
|
29
|
+
spec.add_development_dependency "fakeweb"
|
30
30
|
end
|
data/lib/html2odt.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Html2Odt::DimensionsPatches
|
2
|
+
# Default implemenation of IO#peek from GEM_PATH/dimensions-1.3.0/lib/dimensions/io.rb:
|
3
|
+
#
|
4
|
+
# def peek
|
5
|
+
# unless no_peeking?
|
6
|
+
# read(pos + 1024) while @reader.width.nil? && pos < 6144
|
7
|
+
# rewind
|
8
|
+
# end
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# It had two problems:
|
12
|
+
#
|
13
|
+
# a) if the file is shorter than 6144 bytes, it would keep reading infinitely
|
14
|
+
# b) if the width can only be detected after the 6144 limit, it would not work
|
15
|
+
# as expected
|
16
|
+
#
|
17
|
+
# Now we keep reading the file, until we can determine a width or until
|
18
|
+
# there's nothing left to read.
|
19
|
+
#
|
20
|
+
def peek
|
21
|
+
return if no_peeking?
|
22
|
+
|
23
|
+
while read(pos + 1024) && @reader.width.nil?
|
24
|
+
end
|
25
|
+
|
26
|
+
rewind
|
27
|
+
end
|
28
|
+
end
|
data/lib/html2odt/document.rb
CHANGED
@@ -363,8 +363,8 @@ class Html2Odt::Document
|
|
363
363
|
height = img["height"].to_i
|
364
364
|
width = height * image.height / image.width
|
365
365
|
else
|
366
|
-
width = image.width
|
367
|
-
height = image.height
|
366
|
+
width = image.width.to_i
|
367
|
+
height = image.height.to_i
|
368
368
|
end
|
369
369
|
|
370
370
|
img["width"] = "#{(width / DPI * INCH_TO_CM).round(2)}cm"
|
data/lib/html2odt/image.rb
CHANGED
@@ -23,6 +23,7 @@ class Html2Odt::Image
|
|
23
23
|
if @valid.nil?
|
24
24
|
File.open(source, "rb") do |io|
|
25
25
|
Dimensions(io)
|
26
|
+
io.extend Html2Odt::DimensionsPatches
|
26
27
|
|
27
28
|
# Interacting with Dimensions::Reader directly to
|
28
29
|
#
|
@@ -32,24 +33,14 @@ class Html2Odt::Image
|
|
32
33
|
io.send :peek
|
33
34
|
reader = io.instance_variable_get :@reader
|
34
35
|
|
35
|
-
if reader.type
|
36
|
+
if reader.type && reader.width && reader.height
|
36
37
|
@type = reader.type
|
37
38
|
|
38
|
-
|
39
|
-
# stay nil. According to
|
40
|
-
# https://github.com/sstephenson/dimensions#reading-dimensions-from-a-stream
|
41
|
-
# the dimensions get initialized 'once enough of the file' has been
|
42
|
-
# read, so we do that.
|
43
|
-
#
|
44
|
-
while reader.width.nil?
|
45
|
-
break unless io.read(8192)
|
46
|
-
end
|
47
|
-
|
48
|
-
@width = reader.width
|
39
|
+
@width = reader.width
|
49
40
|
@height = reader.height
|
50
|
-
@angle
|
41
|
+
@angle = reader.angle
|
51
42
|
|
52
|
-
@valid =
|
43
|
+
@valid = true
|
53
44
|
else
|
54
45
|
@valid = false
|
55
46
|
end
|
data/lib/html2odt/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html2odt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregor Schmidt (Planio)
|
@@ -14,106 +14,100 @@ dependencies:
|
|
14
14
|
name: dimensions
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '0'
|
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:
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: nokogiri
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
- - "<"
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: '1.9'
|
33
|
+
version: '0'
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - ">="
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
44
|
-
- - "<"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '1.9'
|
40
|
+
version: '0'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: rubyzip
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
|
-
- - "
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
47
|
+
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
|
-
- - "
|
52
|
+
- - ">="
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
54
|
+
version: '0'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: bundler
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
|
-
- - "
|
59
|
+
- - ">="
|
66
60
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
61
|
+
version: '0'
|
68
62
|
type: :development
|
69
63
|
prerelease: false
|
70
64
|
version_requirements: !ruby/object:Gem::Requirement
|
71
65
|
requirements:
|
72
|
-
- - "
|
66
|
+
- - ">="
|
73
67
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
68
|
+
version: '0'
|
75
69
|
- !ruby/object:Gem::Dependency
|
76
70
|
name: rake
|
77
71
|
requirement: !ruby/object:Gem::Requirement
|
78
72
|
requirements:
|
79
|
-
- - "
|
73
|
+
- - ">="
|
80
74
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
75
|
+
version: '0'
|
82
76
|
type: :development
|
83
77
|
prerelease: false
|
84
78
|
version_requirements: !ruby/object:Gem::Requirement
|
85
79
|
requirements:
|
86
|
-
- - "
|
80
|
+
- - ">="
|
87
81
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
82
|
+
version: '0'
|
89
83
|
- !ruby/object:Gem::Dependency
|
90
84
|
name: minitest
|
91
85
|
requirement: !ruby/object:Gem::Requirement
|
92
86
|
requirements:
|
93
|
-
- - "
|
87
|
+
- - ">="
|
94
88
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
89
|
+
version: '0'
|
96
90
|
type: :development
|
97
91
|
prerelease: false
|
98
92
|
version_requirements: !ruby/object:Gem::Requirement
|
99
93
|
requirements:
|
100
|
-
- - "
|
94
|
+
- - ">="
|
101
95
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
96
|
+
version: '0'
|
103
97
|
- !ruby/object:Gem::Dependency
|
104
98
|
name: fakeweb
|
105
99
|
requirement: !ruby/object:Gem::Requirement
|
106
100
|
requirements:
|
107
|
-
- - "
|
101
|
+
- - ">="
|
108
102
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
103
|
+
version: '0'
|
110
104
|
type: :development
|
111
105
|
prerelease: false
|
112
106
|
version_requirements: !ruby/object:Gem::Requirement
|
113
107
|
requirements:
|
114
|
-
- - "
|
108
|
+
- - ">="
|
115
109
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
110
|
+
version: '0'
|
117
111
|
description: html2odt generates ODT documents based on HTML fragments using xhtml2odt
|
118
112
|
email:
|
119
113
|
- gregor@plan.io
|
@@ -135,6 +129,7 @@ files:
|
|
135
129
|
- bin/html2odt.rb
|
136
130
|
- html2odt.gemspec
|
137
131
|
- lib/html2odt.rb
|
132
|
+
- lib/html2odt/dimensions_patches.rb
|
138
133
|
- lib/html2odt/document.rb
|
139
134
|
- lib/html2odt/image.rb
|
140
135
|
- lib/html2odt/version.rb
|