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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df8d84152bdb9bd084049457e5d4b7873947ea7d
4
- data.tar.gz: 61d994a96bc8b0a0d6f98ffb10802c2b80422447
3
+ metadata.gz: 67d0f7c76e86cb16aa718ed1b4868ff957878227
4
+ data.tar.gz: efde21663754a80ab324d80bfb04935fbd712bb2
5
5
  SHA512:
6
- metadata.gz: b3096708a2dd8854a36be52da95ae61848c51ddde69e3fbee23b326790aa93ec2e97f37f93dda0108b26480cba0a8cb3d979d0acc9d5d36a7bf8420bcce62a6f
7
- data.tar.gz: 112d12a289eb3cab46a4404c2b51799cd99a42d90a406b109acf23bedfa1a7f203d838b9e19f11c74ecb1bf7dd8ab860dc96175b1b88d85e4213ff1a01af2ad9
6
+ metadata.gz: 4f47e1fddc20d3967cefbb9ee8397e49ef52e2a94479fecc9393f55ff49e7ed5ad4def7cc47ebfb6814b5f321484e5cf008230ba55226d3240a0c8206e7e2145
7
+ data.tar.gz: 5edbcb7ce66dafa336a02baee0dbe41fda7faf332db8579e6c7bf591fe1617c28f4e8378c9a6f059a6e7b610665aca57387165395f5db5072d4a317c4f90abda
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v0.4.3 - 2017-12-15
2
+
3
+ Handle files smaller than 6144 bytes. Relaxed version requirements.
4
+
1
5
  # v0.4.2 - 2017-12-15
2
6
 
3
7
  Try harder to determine image dimensions.
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", "~> 1.3.0"
23
- spec.add_dependency "nokogiri", ">= 1.7.1", "< 1.9"
24
- spec.add_dependency "rubyzip", "~> 1.0"
22
+ spec.add_dependency "dimensions"
23
+ spec.add_dependency "nokogiri"
24
+ spec.add_dependency "rubyzip"
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.12"
27
- spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency "minitest", "~> 5.0"
29
- spec.add_development_dependency "fakeweb", "~> 1.3"
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
@@ -13,6 +13,7 @@ module Html2Odt
13
13
  ODT_TEMPLATE = File.join(File.dirname(__FILE__), "..", "odt", "template.odt")
14
14
  end
15
15
 
16
+ require "html2odt/dimensions_patches"
16
17
  require "html2odt/document"
17
18
  require "html2odt/image"
18
19
  require "html2odt/version"
@@ -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
@@ -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"
@@ -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
- # for some files, peek doesn't seem to do the trick and width/height
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 = reader.angle
41
+ @angle = reader.angle
51
42
 
52
- @valid = not(@width.nil? or @height.nil?)
43
+ @valid = true
53
44
  else
54
45
  @valid = false
55
46
  end
@@ -1,3 +1,3 @@
1
1
  module Html2Odt
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
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.2
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: 1.3.0
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: 1.3.0
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: 1.7.1
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: 1.7.1
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: '1.0'
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: '1.0'
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: '1.12'
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: '1.12'
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: '10.0'
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: '10.0'
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: '5.0'
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: '5.0'
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: '1.3'
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: '1.3'
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