open_xml_package 0.1.0.beta1 → 0.1.0

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: dccd074a45e7ab40ae475a08cc76fa971b1fdf28
4
- data.tar.gz: 9c2b1b2f54b9ebe31ea4dc5fb897811ef868048c
3
+ metadata.gz: b7c6df8561b12ab2eba68c491b536858c24d1ac7
4
+ data.tar.gz: 072033ceed3d330101adade0edd83311db91fbc0
5
5
  SHA512:
6
- metadata.gz: ed7b80d5fdc04c631963c985b7cd514b1a7dcaec082ad508e5a8f4eaf01185952dc25359bd3466a027eea5c4018bec380d3243e4ba111664cc196bd793a1b58c
7
- data.tar.gz: 1e2c65ddc9e0c1f92f9b54dc02240ba50b6558f3289b0343bda5a79cc7337c8fbb2fe8b2194086cce6cb0a52a93d407f37d7caae00d9916fde35bba8fcf2a6ba
6
+ metadata.gz: 78ee971bfc8d827ca20a977004fe0bf89c09d4f15eab9f23fa4aebb559052a4215964cf638fff28fca8b3042d5b80d3e4a771504e728f6e2d4f4c5e8db7143ef
7
+ data.tar.gz: 7ddae79c7891090e17282dd30470e2f3d315176c8b81f7b7376f234ca1d6eb57445e23fe1aae7a9362b7d3f7dbf043960fd0ad36b4f33340f02a2434bc80bfa3
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # OpenXmlPackage
1
+ # OpenXml::Package
2
2
 
3
3
  A Ruby implementation of [DocumentFormat.OpenXml.Packaging.OpenXmlPackage](http://msdn.microsoft.com/en-us/library/documentformat.openxml.packaging.openxmlpackage_members(v=office.14).aspx) from Microsoft's Open XML SDK.
4
4
 
5
-
5
+ The base class for [Rocx::Package](https://github.com/genebot/rocx/blob/master/lib/rocx/package.rb), [Xlsx::Package](https://github.com/concordia-publishing-house/xlsx/blob/master/lib/xlsx/package.rb), and [Pptx::Package](https://github.com/concordia-publishing-house/pptx/blob/master/lib/pptx/package.rb).
6
6
 
7
7
 
8
8
  ## Installation
@@ -21,7 +21,6 @@ Or install it yourself as:
21
21
 
22
22
 
23
23
 
24
-
25
24
  ## Usage
26
25
 
27
26
  #### Writing
@@ -29,9 +28,9 @@ Or install it yourself as:
29
28
  You can assemble an Open XML Package in-memory and then write it to disk:
30
29
 
31
30
  ```ruby
32
- package = OpenXmlPackage.new
33
- package.add_part "content/document.xml", "<document></document>"
34
- package.add_part "media/image.png", File.open(image_path, "rb", &:read)
31
+ package = OpenXml::Package.new
32
+ package.add_part "content/document.xml", OpenXml::Parts::UnparsedPart.new("<document></document>")
33
+ package.add_part "media/image.png", OpenXml::Parts::UnparsedPart.new(File.open(image_path, "rb", &:read))
35
34
  package.write_to "~/Desktop/output.zip"
36
35
  ```
37
36
 
@@ -42,15 +41,73 @@ You can read the contents of an Open XML Package:
42
41
 
43
42
  ```ruby
44
43
  OpenXmlPackage.open("~/Desktop/output.zip") do |package|
45
- package.parts.map(&:path) # => ["content/document.xml", "media/image.png"]
44
+ package.parts.keys # => ["content/document.xml", "media/image.png"]
45
+ end
46
+ ```
47
+
48
+
49
+ #### Subclassing
50
+
51
+ `OpenXml::Package` is intended to be the base class for libraries that implement Open XML formats for Microsoft Office products.
52
+
53
+ For example, a very simple Microsoft Word document can be defined as follows:
54
+
55
+ ```ruby
56
+ require "open_xml/package"
57
+
58
+ module Rocx
59
+ class Package < OpenXml::Package
60
+ attr_reader :document,
61
+ :doc_rels,
62
+ :settings,
63
+ :styles
64
+
65
+ content_types do
66
+ default "png", TYPE_PNG
67
+ override "/word/styles.xml", TYPE_STYLES
68
+ override "/word/settings.xml", TYPE_SETTINGS
69
+ end
70
+
71
+ def initialize
72
+ super
73
+
74
+ rels.add_relationship REL_DOCUMENT, "/word/document.xml"
75
+ @doc_rels = OpenXml::Parts::Rels.new([
76
+ { type: REL_STYLES, target: "/word/styles.xml"},
77
+ { type: REL_SETTINGS, target: "/word/settings.xml"}
78
+ ])
79
+ @settings = Rocx::Parts::Settings.new
80
+ @styles = Rocx::Parts::Styles.new
81
+ @document = Rocx::Parts::Document.new
82
+
83
+ add_part "word/_rels/document.xml.rels", doc_rels
84
+ add_part "word/document.xml", document
85
+ add_part "word/settings.xml", settings
86
+ add_part "word/styles.xml", styles
87
+ end
88
+
89
+ end
46
90
  end
47
91
  ```
48
92
 
93
+ This gem also defines two "Parts" that are commonly used in Open XML packages.
94
+
95
+ ##### OpenXml::Parts::ContentTypes
96
+
97
+ Is used to identify the ContentType of all of the files in the package. There are two ways of identifying content types:
98
+
99
+ 1. **Default**: declares the default content type for a file with a given extension
100
+ 2. **Override**: declares the content type for a specific file with the given path inside the package
101
+
102
+ ##### OpenXml::Parts::Rels
103
+
104
+ Is used to identify links within the package
105
+
49
106
 
50
107
 
51
108
  ## Contributing
52
109
 
53
- 1. Fork it ( https://github.com/[my-github-username]/open_xml_package/fork )
110
+ 1. Fork it ( https://github.com/concordia-publishing-house/open_xml_package/fork )
54
111
  2. Create your feature branch (`git checkout -b my-new-feature`)
55
112
  3. Commit your changes (`git commit -am 'Add some feature'`)
56
113
  4. Push to the branch (`git push origin my-new-feature`)
@@ -1,3 +1,3 @@
1
1
  module OpenXmlPackage
2
- VERSION = "0.1.0.beta1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_xml_package
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.beta1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Lail
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-27 00:00:00.000000000 Z
11
+ date: 2015-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -200,9 +200,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
200
  version: '0'
201
201
  required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  requirements:
203
- - - ">"
203
+ - - ">="
204
204
  - !ruby/object:Gem::Version
205
- version: 1.3.1
205
+ version: '0'
206
206
  requirements: []
207
207
  rubyforge_project:
208
208
  rubygems_version: 2.2.2