openxml-package 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openxml-package/version.rb +1 -1
- data/lib/openxml/builder.rb +1 -1
- data/lib/openxml/package.rb +2 -1
- data/lib/openxml/part.rb +1 -1
- data/lib/openxml/parts/rels.rb +6 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b8b8727009d5a81ee13ed1fb5543abf6a85811f
|
4
|
+
data.tar.gz: c4d7e5c4845e6dd2c1906020fdfda4215692ec09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb19edd1f90e92b0784dd8ff54e752c204a1e83d22074dc0d44b1cfb6b0b2423ddd2d7c69f6216c8fc015984c3fad0cb99019d17f49f7e143208b54ac7bad3be
|
7
|
+
data.tar.gz: b714390cb65eda06f274d50fbd0c8f2c79ffc4bb4ac0ce90f3b083ece9d7043286f1430e4e533175b181df94efa7f4d7691dc2103d321753cb7650df141a39e0
|
data/lib/openxml/builder.rb
CHANGED
data/lib/openxml/package.rb
CHANGED
@@ -101,6 +101,7 @@ module OpenXml
|
|
101
101
|
|
102
102
|
def read_zipfile!
|
103
103
|
zipfile.entries.each do |entry|
|
104
|
+
next if entry.directory?
|
104
105
|
path, part = entry.name, Parts::UnparsedPart.new(entry)
|
105
106
|
add_part path, case path
|
106
107
|
when "[Content_Types].xml" then @content_types = Parts::ContentTypes.parse(part.content)
|
@@ -114,7 +115,7 @@ module OpenXml
|
|
114
115
|
|
115
116
|
def set_defaults
|
116
117
|
presets = self.class.content_types_presets
|
117
|
-
@content_types = Parts::ContentTypes.new(presets.defaults, presets.overrides)
|
118
|
+
@content_types = Parts::ContentTypes.new(presets.defaults.dup, presets.overrides.dup)
|
118
119
|
add_part "[Content_Types].xml", content_types
|
119
120
|
|
120
121
|
@rels = Parts::Rels.new
|
data/lib/openxml/part.rb
CHANGED
data/lib/openxml/parts/rels.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "securerandom"
|
2
|
+
require "nokogiri"
|
2
3
|
|
3
4
|
module OpenXml
|
4
5
|
module Parts
|
@@ -6,7 +7,7 @@ module OpenXml
|
|
6
7
|
include Enumerable
|
7
8
|
|
8
9
|
def self.parse(xml)
|
9
|
-
document = Nokogiri(xml)
|
10
|
+
document = Nokogiri::XML(xml)
|
10
11
|
self.new.tap do |part|
|
11
12
|
document.css("Relationship").each do |rel|
|
12
13
|
part.add_relationship rel["Type"], rel["Target"], rel["Id"], rel["TargetMode"]
|
@@ -31,6 +32,10 @@ module OpenXml
|
|
31
32
|
relationships.each(&block)
|
32
33
|
end
|
33
34
|
|
35
|
+
def empty?
|
36
|
+
relationships.empty?
|
37
|
+
end
|
38
|
+
|
34
39
|
def to_xml
|
35
40
|
build_standalone_xml do |xml|
|
36
41
|
xml.Relationships(xmlns: "http://schemas.openxmlformats.org/package/2006/relationships") do
|
@@ -43,8 +48,6 @@ module OpenXml
|
|
43
48
|
end
|
44
49
|
end
|
45
50
|
|
46
|
-
|
47
|
-
|
48
51
|
class Relationship < Struct.new(:type, :target, :id, :target_mode)
|
49
52
|
def initialize(type, target, id=nil, target_mode=nil)
|
50
53
|
super type, target, id || "R#{SecureRandom.hex}", target_mode
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openxml-package
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Lail
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|