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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae52e67709cf5e65ec3a4dad4c3cd7f88a40b538
4
- data.tar.gz: 29dfc74ba61458cc74ba029c1a4bc9941d8cbd89
3
+ metadata.gz: 8b8b8727009d5a81ee13ed1fb5543abf6a85811f
4
+ data.tar.gz: c4d7e5c4845e6dd2c1906020fdfda4215692ec09
5
5
  SHA512:
6
- metadata.gz: 08a1895d8a8e4c2c5324efa071d7635b214cebd99a1619fa3620072a3d876c9953fe191db353a8a2b78ed13f55fcc5e969366ae70975870da48d6acddb1f9f6d
7
- data.tar.gz: 3255c8264fa47faf23980a903042a43dc155875a48a1dfc5eddae57c6bc7f61f2b650c4ca9b60be56939aa002b30550aa57a10deeb7c8bbdbb615c4d7af2e6b4
6
+ metadata.gz: bb19edd1f90e92b0784dd8ff54e752c204a1e83d22074dc0d44b1cfb6b0b2423ddd2d7c69f6216c8fc015984c3fad0cb99019d17f49f7e143208b54ac7bad3be
7
+ data.tar.gz: b714390cb65eda06f274d50fbd0c8f2c79ffc4bb4ac0ce90f3b083ece9d7043286f1430e4e533175b181df94efa7f4d7691dc2103d321753cb7650df141a39e0
@@ -1,3 +1,3 @@
1
1
  module OpenXmlPackage
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
@@ -14,7 +14,7 @@ module OpenXml
14
14
  @to_s_options = { with_xml: true }
15
15
 
16
16
  @document = Ox::Document.new(
17
- encoding: "utf-8",
17
+ encoding: "UTF-8",
18
18
  version: "1.0",
19
19
  standalone: options[:standalone])
20
20
  @parent = @document
@@ -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
@@ -17,7 +17,7 @@ module OpenXml
17
17
  alias :content :read
18
18
 
19
19
  def to_xml
20
- raise NotImplementedError
20
+ raise NotImplementedError, "#{self.class} needs to implements to_xml"
21
21
  end
22
22
 
23
23
  end
@@ -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.7
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-03-03 00:00:00.000000000 Z
11
+ date: 2017-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip