swordfish 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjlkNGYxMWRlZmZkMzVlYzI2YWYzNjA2MTA0MzU0MWIyZTY5ZDdhYQ==
4
+ ZTEyODI1ZjU2OTMyODY3ZDM0NjM3OGY3ZjcyNTU1YTIwMjk1NDQ0ZA==
5
5
  data.tar.gz: !binary |-
6
- Y2E2MDA5YzFiODYzNDhkMTdkYzNkNWFlNTM4NGVhNGU0YWI5NzIwYw==
6
+ YTIxMTkzNWMzNmYwNTY3YTNmOTg2YzE1MTYyZDUxYjk3YTNkZGU1MQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWE3MGJmZjc2N2M2MDQ4ZjMxYzNlMGZjY2ZjZGEyNTIyODZkYjQ1NTUwMWNi
10
- OGZhODAyODI0NDJlZmZmM2M3NDc5YzZiZjg1YmNkNDA1ZGY3YzVkMzkyZmVl
11
- YWNhMWI0YzU4MzA1NTQ3ZDQ5MTE0YWIzN2Y4ZGEyMDQzOTUxN2M=
9
+ ZmQ2YTk3YTcxNzFmNjNhMTg4Yjk0OGE1ZmI0ZjVmMWM5M2U1NmM1NDA3Y2Y0
10
+ MzUzNjI4NGQ1Y2IwOTgyNGI3MmM3M2M2OGM3OGIwMzAyY2VmZjE3NWMyNmJl
11
+ N2M0MjQ1OGQzZDZhMjI1M2RmN2Y4MTE0MjYyOGZjZWQ4MzJiZWY=
12
12
  data.tar.gz: !binary |-
13
- YjQ4OGY2ZjNmNWVlMTI5NzhjYjIzOTc1NzJlNWMzYWQ4NWZmNzM1Yzg1NTY1
14
- OWI4ZDhmYmZmMGNjZTA1MWI1OTA1MjA1M2RhYjc2MTZjNjFiMjFjMzkyMGYx
15
- MGQwMGI3YjI5ZDljMjI3MWZjZGYwYzNlN2UxMzBiNmMwMWI3YzY=
13
+ YjY5NDlhZmQ0N2I0NGYzNjA0OGY4YzQ5MjY1YmI1MDM4OTIzODYxNDBjODIy
14
+ OGE3MjdjZTU4YmNkNmVmZjk1NDAxYjA2MmVkMzAzNzViY2ExYzg3MjU5ZjU0
15
+ ZGE1NTY5ZWQ1MTI2ZWU5MjJjMTI5Y2ZmYzM1NTI5YWU3YWJmNjM=
@@ -1,4 +1,5 @@
1
1
  require 'cgi'
2
+ require 'uri'
2
3
  require 'swordfish/stylesheet'
3
4
  require 'swordfish/nodes/base'
4
5
  require 'swordfish/nodes/text'
@@ -18,8 +18,8 @@ module Swordfish
18
18
  docx_archive = Zip::File.open(filepath)
19
19
  document = docx_archive.read 'word/document.xml'
20
20
  styles = docx_archive.read 'word/styles.xml'
21
- numbering = docx_archive.read 'word/numbering.xml'
22
- relationships = docx_archive.read 'word/_rels/document.xml.rels'
21
+ numbering = docx_archive.read('word/numbering.xml') rescue nil
22
+ relationships = docx_archive.read('word/_rels/document.xml.rels') rescue nil
23
23
 
24
24
  # Parse the XML files and generate the Swordfish::Document
25
25
  swordfish_docx = new docx_archive, document, styles, numbering, relationships
@@ -30,8 +30,8 @@ module Swordfish
30
30
  @docx_archive = archive
31
31
  @swordfish_doc = Swordfish::Document.new
32
32
  parse_styles styles_xml
33
- parse_numbering numbering_xml
34
- parse_relationships relationships_xml
33
+ parse_numbering(numbering_xml) if numbering_xml
34
+ parse_relationships(relationships_xml) if relationships_xml
35
35
  parse document_xml
36
36
  end
37
37
 
@@ -170,7 +170,7 @@ module Swordfish
170
170
  text.content = run_xml.xpath('./w:t')[0].content
171
171
  get_styles_for_node(text, run_xml.xpath('./w:rPr')[0])
172
172
  texts << text
173
- elsif run_xml.xpath('.//pic:pic', :pic => @namespaces['xmlns:pic']).length > 0
173
+ elsif @namespaces['xmlns:pic'] && run_xml.xpath('.//pic:pic', :pic => @namespaces['xmlns:pic']).length > 0
174
174
  # An image run
175
175
  image = Swordfish::Node::Image.new
176
176
  relationship_id = run_xml.xpath('.//pic:pic/pic:blipFill/a:blip', :pic => @namespaces['xmlns:pic'], :a => @namespaces['xmlns:a'])[0]['r:embed'] rescue nil
@@ -8,7 +8,7 @@ module Swordfish
8
8
 
9
9
  def to_html
10
10
  @href ||= ""
11
- "<a href=\"#{CGI::escape(@href)}\">#{@children.map(&:to_html).join}</a>"
11
+ "<a href=\"#{URI::escape(@href)}\">#{@children.map(&:to_html).join}</a>"
12
12
  end
13
13
 
14
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swordfish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Posthumus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-01 00:00:00.000000000 Z
11
+ date: 2014-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler