ydocx 1.1.9 → 1.2.0

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,8 @@
1
+ === 1.2.0 / 07..2012
2
+
3
+ * Added support for stand alone image parsing
4
+ * Improved swissmedic number handling of fi format
5
+
1
6
  === 1.1.9 / 10.05.2012
2
7
 
3
8
  * Updating image file should not be prevented if image file already exists.
data/lib/ydocx/parser.rb CHANGED
@@ -154,24 +154,30 @@ module YDocx
154
154
  }
155
155
  ns = r.namespaces.merge additional_namespaces
156
156
  [
157
- {
157
+ { # old type shape
158
158
  :attr => 'id',
159
159
  :path => 'w:pict//v:shape//v:imagedata',
160
160
  :wrap => 'w:pict//v:shape//w10:wrap',
161
- :type => 'type',
161
+ :type => '',
162
162
  },
163
- {
163
+ { # in anchor
164
164
  :attr => 'embed',
165
165
  :path => 'w:drawing//wp:anchor//a:graphic//a:graphicData//pic:pic//pic:blipFill//a:blip',
166
166
  :wrap => 'w:drawing//wp:anchor//wp:wrapTight',
167
167
  :type => 'wrapText',
168
168
  },
169
+ { # stand alone
170
+ :attr => 'embed',
171
+ :path => 'w:drawing//a:graphic//a:graphicData//pic:pic//pic:blipFill//a:blip',
172
+ :wrap => 'w:drawing//wp:wrapTight',
173
+ :type => 'wrapText',
174
+ },
169
175
  ].each do |element|
170
176
  if image = r.xpath(element[:path], ns) and !image.empty?
171
177
  if wrap = r.xpath("#{element[:wrap]}", ns).first
172
178
  # TODO
173
179
  # wrap handling (currently all wrap off)
174
- # wrap[element[:type]] has "bothSides", "topAndBottom"
180
+ # wrap[element[:type]] has "bothSides", "topAndBottom" and "wrapText"
175
181
  @image_style = 'display:block;'
176
182
  end
177
183
  (id = image.first[element[:attr].to_s]) && break
@@ -40,9 +40,11 @@ module YDocx
40
40
  def escape_id(text)
41
41
  CGI.escape(text.gsub(/&(.)uml;/, '\1e').gsub(/\s*\/\s*|\s+|\/|\-/, '_').gsub(/\./, '').downcase)
42
42
  end
43
- def parse_code(text)
44
- if text =~ /^\s*(\d\d)(‘|’|'|.|\s*)(\d\d\d)\s*\(\s*Swiss\s*medic\s*\)(\s*|.)$/iu
43
+ def parse_code(text) # swissmedic nummer
44
+ if text =~ /^\s*(\d{2})(‘|’|'|.|\s*)(\d{3})\s*\(\s*Swiss\s*medic\s*\)(\s*|.)$/iu
45
45
  @code = "%5d" % ($1 + $3)
46
+ elsif text =~ /^\s*(\d{5})(.*|\s*)\s*\(\s*Swiss\s*medic\s*\)(\s*|.)$/iu
47
+ @code = "%5d" % $1
46
48
  else
47
49
  nil
48
50
  end
@@ -180,10 +182,11 @@ div#container {
180
182
  def output_directory
181
183
  unless @files
182
184
  if @parser.code
183
- @files = Pathname.new(@directory + '/' + @parser.code)
185
+ files = @directory + '/' + @parser.code
184
186
  else
185
- @files = @path.dirname.join(@path.basename('.docx').to_s + '_files')
187
+ files = @path.basename('.docx').to_s + '_files'
186
188
  end
189
+ @files = @path.dirname.join files
187
190
  end
188
191
  @files
189
192
  end
data/lib/ydocx.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  require 'ydocx/document'
5
5
 
6
6
  module YDocx
7
- VERSION = '1.1.9'
7
+ VERSION = '1.2.0'
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.9
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-11 00:00:00.000000000 Z
12
+ date: 2012-07-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
16
- requirement: &10924400 !ruby/object:Gem::Requirement
16
+ requirement: &12401440 !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: *10924400
24
+ version_requirements: *12401440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hoe
27
- requirement: &10923980 !ruby/object:Gem::Requirement
27
+ requirement: &12400980 !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: *10923980
35
+ version_requirements: *12400980
36
36
  description: ''
37
37
  email:
38
38
  - yasaka@ywesee.com, zdavatz@ywesee.com