ydocx 1.1.7 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.1.8 / 10.05.2012
2
+
3
+ * Fixed image reference option for fi/pi format
4
+
1
5
  === 1.1.7 / 10.05.2012
2
6
 
3
7
  * Improved title detecting. skipped blank line.
data/lib/ydocx/builder.rb CHANGED
@@ -8,12 +8,13 @@ require 'ydocx/markup_method'
8
8
  module YDocx
9
9
  class Builder
10
10
  include MarkupMethod
11
- attr_accessor :contents, :container, :indecies,
11
+ attr_accessor :contents, :container, :indecies, :references,
12
12
  :block, :files, :style, :title
13
13
  def initialize(contents)
14
14
  @contents = contents
15
15
  @container = {}
16
16
  @indecies = []
17
+ @references = []
17
18
  @block = :div
18
19
  @files = Pathname.new('.')
19
20
  @style = false
@@ -22,7 +22,8 @@ module YDocx
22
22
  @parser = nil
23
23
  @builder = nil
24
24
  @contents = nil
25
- @indecies = nil
25
+ @indecies = []
26
+ @references = []
26
27
  @images = []
27
28
  @options = options
28
29
  @path = Pathname.new('.')
@@ -47,9 +48,10 @@ module YDocx
47
48
  builder.title = @path.basename
48
49
  builder.files = files.relative_path_from(files.dirname)
49
50
  builder.style = options[:style] if options.has_key?(:style)
50
- if @indecies
51
- builder.indecies = @indecies
52
- end
51
+ # option
52
+ builder.indecies = @indecies.dup
53
+ builder.references = @references.dup
54
+
53
55
  html = builder.build_html
54
56
  end
55
57
  unless file.empty?
@@ -164,14 +164,13 @@ div#container {
164
164
  style.gsub(/\s\s+|\n/, ' ')
165
165
  end
166
166
  def resolve_path(path)
167
- path
167
+ if reference = @references.shift
168
+ File.dirname(path) + '/' + reference.basename.to_s
169
+ else
170
+ path
171
+ end
168
172
  end
169
173
  end
170
- # == Document
171
- # Image reference option
172
- # Currently, this supports only all images or first one reference.
173
- #
174
- # $ docx2html example.docx --format fachinfo refence1.png refenece2.png
175
174
  class Document
176
175
  def init
177
176
  @directory = 'fi'
@@ -198,16 +197,21 @@ div#container {
198
197
  end
199
198
  private
200
199
  def has_image?
201
- # TODO
200
+ # NOTE
202
201
  # fi/pi format needs always directories.
203
202
  # now returns just true
204
203
  true
205
204
  end
205
+ # NOTE
206
+ # Image reference option
207
+ # Currently, this supports only all images or first one reference.
208
+ #
209
+ # $ docx2html example.docx --format fachinfo refence1.png refenece2.png
206
210
  alias :copy_or_convert :organize_image
207
211
  def organize_image(origin_path, source_path)
208
- if reference = @references.shift and
209
- File.extname(reference) == source_path.extname
210
- FileUtils.copy reference, @files.join(source_path)
212
+ if reference = @references.shift
213
+ new_source_path = source_path.dirname.to_s + '/' + File.basename(reference)
214
+ FileUtils.copy reference, @files.join(new_source_path)
211
215
  else
212
216
  copy_or_convert(origin_path, source_path)
213
217
  end
@@ -215,8 +219,8 @@ div#container {
215
219
  def prepare_reference
216
220
  ARGV.reverse.each do |arg|
217
221
  if arg.downcase =~ /\.(jpeg|jpg|png|gif)$/
218
- path = Pathname.new(arg).realpath
219
- @references << path if path.exist?
222
+ path = Pathname.new(arg)
223
+ @references << path.realpath if path.exist?
220
224
  end
221
225
  end
222
226
  @references.reverse unless @references.empty?
data/lib/ydocx.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  require 'ydocx/document'
5
5
 
6
6
  module YDocx
7
- VERSION = '1.1.7'
7
+ VERSION = '1.1.8'
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ydocx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
16
- requirement: &21948440 !ruby/object:Gem::Requirement
16
+ requirement: &24290600 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.10'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *21948440
24
+ version_requirements: *24290600
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hoe
27
- requirement: &21948020 !ruby/object:Gem::Requirement
27
+ requirement: &24290180 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '2.13'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *21948020
35
+ version_requirements: *24290180
36
36
  description: ''
37
37
  email:
38
38
  - yasaka@ywesee.com, zdavatz@ywesee.com