docxi 0.0.2 → 0.1.0.rc1
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 +5 -5
- data/CHANGELOG.md +31 -0
- data/README.md +79 -4
- data/Rakefile +28 -0
- data/lib/docxi/content_types.rb +6 -2
- data/lib/docxi/document.rb +5 -5
- data/lib/docxi/properties.rb +2 -4
- data/lib/docxi/relationships.rb +1 -2
- data/lib/docxi/util.rb +19 -0
- data/lib/docxi/version.rb +1 -1
- data/lib/docxi/word/contents/frame.rb +84 -0
- data/lib/docxi/word/contents/image.rb +74 -10
- data/lib/docxi/word/contents/paragraph.rb +68 -1
- data/lib/docxi/word/contents/tab.rb +33 -0
- data/lib/docxi/word/contents/table.rb +80 -0
- data/lib/docxi/word/contents/text.rb +7 -1
- data/lib/docxi/word/contents.rb +2 -0
- data/lib/docxi/word/document.rb +45 -6
- data/lib/docxi/word/effects.rb +1 -2
- data/lib/docxi/word/endnotes.rb +1 -2
- data/lib/docxi/word/fonts.rb +1 -2
- data/lib/docxi/word/footers/footer.rb +24 -6
- data/lib/docxi/word/footnotes.rb +1 -2
- data/lib/docxi/word/headers/header.rb +57 -13
- data/lib/docxi/word/helpers.rb +12 -0
- data/lib/docxi/word/hyperlinks/hyperlink.rb +94 -0
- data/lib/docxi/word/hyperlinks.rb +30 -0
- data/lib/docxi/word/medias/media.rb +18 -0
- data/lib/docxi/word/medias.rb +1 -2
- data/lib/docxi/word/numbering.rb +1 -2
- data/lib/docxi/word/relationships/relationship.rb +8 -3
- data/lib/docxi/word/relationships.rb +5 -6
- data/lib/docxi/word/settings.rb +1 -2
- data/lib/docxi/word/styles.rb +6 -6
- data/lib/docxi/word/themes.rb +1 -2
- data/lib/docxi/word/web_settings.rb +1 -2
- data/lib/docxi.rb +12 -1
- metadata +74 -20
data/lib/docxi/word/medias.rb
CHANGED
data/lib/docxi/word/numbering.rb
CHANGED
|
@@ -3,16 +3,21 @@ module Docxi
|
|
|
3
3
|
class Relationships
|
|
4
4
|
class Relationship
|
|
5
5
|
|
|
6
|
-
attr_accessor :id, :type, :target
|
|
6
|
+
attr_accessor :id, :type, :target, :tm
|
|
7
7
|
|
|
8
|
-
def initialize(id, type, target)
|
|
8
|
+
def initialize(id, type, target, tm = '')
|
|
9
9
|
@id = id
|
|
10
10
|
@type = type
|
|
11
11
|
@target = target
|
|
12
|
+
@tm = tm
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
def build(xml)
|
|
15
|
-
|
|
16
|
+
if Docxi::Util.blank?(@tm)
|
|
17
|
+
xml.Relationship('Id' => @id, 'Type' => @type, 'Target' => @target)
|
|
18
|
+
else
|
|
19
|
+
xml.Relationship('Id' => @id, 'Type' => @type, 'Target' => @target, 'TargetMode' => @tm)
|
|
20
|
+
end
|
|
16
21
|
end
|
|
17
22
|
|
|
18
23
|
end
|
|
@@ -21,15 +21,14 @@ module Docxi
|
|
|
21
21
|
add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering", "numbering.xml")
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
def add(type, target)
|
|
25
|
-
relationship = create_relationship(sequence, type, target)
|
|
24
|
+
def add(type, target, tm = '')
|
|
25
|
+
relationship = create_relationship(sequence, type, target,tm)
|
|
26
26
|
@relationships << relationship if relationship
|
|
27
27
|
relationship
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def render(zip)
|
|
31
|
-
|
|
32
|
-
zip.write(Docxi.to_xml(document))
|
|
31
|
+
Docxi.write_entry(zip, 'word/_rels/document.xml.rels', Docxi.to_xml(document))
|
|
33
32
|
end
|
|
34
33
|
|
|
35
34
|
private
|
|
@@ -43,8 +42,8 @@ module Docxi
|
|
|
43
42
|
end
|
|
44
43
|
end
|
|
45
44
|
|
|
46
|
-
def create_relationship(id, type, target)
|
|
47
|
-
Relationship.new(id, type, target)
|
|
45
|
+
def create_relationship(id, type, target, tm = '')
|
|
46
|
+
Relationship.new(id, type, target, tm)
|
|
48
47
|
end
|
|
49
48
|
|
|
50
49
|
def sequence
|
data/lib/docxi/word/settings.rb
CHANGED
data/lib/docxi/word/styles.rb
CHANGED
|
@@ -8,8 +8,7 @@ module Docxi
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def render(zip)
|
|
11
|
-
|
|
12
|
-
zip.write(Docxi.to_xml(document))
|
|
11
|
+
Docxi.write_entry(zip, 'word/styles.xml', Docxi.to_xml(document))
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
private
|
|
@@ -20,15 +19,16 @@ module Docxi
|
|
|
20
19
|
xml['w'].docDefaults do
|
|
21
20
|
xml['w'].rPrDefault do
|
|
22
21
|
xml['w'].rPr do
|
|
23
|
-
xml['w'].rFonts('w:asciiTheme' => "minorHAnsi", 'w:eastAsiaTheme' => "minorHAnsi", 'w:hAnsiTheme' => "minorHAnsi", 'w:cstheme' => "minorBidi")
|
|
24
|
-
xml['w'].
|
|
25
|
-
xml['w'].
|
|
22
|
+
# xml['w'].rFonts('w:asciiTheme' => "minorHAnsi", 'w:eastAsiaTheme' => "minorHAnsi", 'w:hAnsiTheme' => "minorHAnsi", 'w:cstheme' => "minorBidi")
|
|
23
|
+
xml['w'].rFonts( 'w:cs'=> 'Arial', 'w:ascii'=> 'Arial', 'w:hAnsi' => 'Arial' )
|
|
24
|
+
xml['w'].sz('w:val' => 24)
|
|
25
|
+
xml['w'].szCs('w:val' => 24)
|
|
26
26
|
xml['w'].lang('w:val' => "en-US", 'w:eastAsia' => "en-US", 'w:bidi' => "ar-SA")
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
xml['w'].pPrDefault do
|
|
30
30
|
xml['w'].pPr do
|
|
31
|
-
xml['w'].spacing(
|
|
31
|
+
xml['w'].spacing("w:lineRule"=>"atLeast", "w:line"=>"240")
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
end
|
data/lib/docxi/word/themes.rb
CHANGED
data/lib/docxi.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
require 'nokogiri'
|
|
2
|
-
require 'zip
|
|
2
|
+
require 'zip'
|
|
3
3
|
|
|
4
|
+
require 'docxi/version'
|
|
5
|
+
require 'docxi/util'
|
|
4
6
|
require 'docxi/relationships'
|
|
5
7
|
require 'docxi/content_types'
|
|
6
8
|
require 'docxi/properties'
|
|
@@ -13,6 +15,15 @@ module Docxi
|
|
|
13
15
|
document.to_xml(:save_with => Nokogiri::XML::Node::SaveOptions::AS_XML).gsub("\n", "\r\n").strip
|
|
14
16
|
end
|
|
15
17
|
|
|
18
|
+
# The size is set up front because rubyzip 3 otherwise adds Zip64 extra
|
|
19
|
+
# fields to every entry, and Google Docs and older LibreOffice reject those.
|
|
20
|
+
def self.write_entry(zip, name, data)
|
|
21
|
+
entry = Zip::Entry.new('', name)
|
|
22
|
+
entry.size = data.bytesize
|
|
23
|
+
zip.put_next_entry(entry)
|
|
24
|
+
zip.write(data)
|
|
25
|
+
end
|
|
26
|
+
|
|
16
27
|
def self.test
|
|
17
28
|
word = Docxi::Document.new
|
|
18
29
|
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: docxi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.1.0.rc1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
8
|
-
autorequire:
|
|
7
|
+
- Hammad Maqbool
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: nokogiri
|
|
@@ -16,40 +15,89 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 1.
|
|
18
|
+
version: '1.8'
|
|
20
19
|
- - "<"
|
|
21
20
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '
|
|
21
|
+
version: '2'
|
|
23
22
|
type: :runtime
|
|
24
23
|
prerelease: false
|
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
25
|
requirements:
|
|
27
26
|
- - ">="
|
|
28
27
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: 1.
|
|
28
|
+
version: '1.8'
|
|
30
29
|
- - "<"
|
|
31
30
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
31
|
+
version: '2'
|
|
33
32
|
- !ruby/object:Gem::Dependency
|
|
34
33
|
name: rubyzip
|
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
|
36
35
|
requirements:
|
|
37
|
-
- - "
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '1.3'
|
|
39
|
+
- - "<"
|
|
38
40
|
- !ruby/object:Gem::Version
|
|
39
|
-
version:
|
|
41
|
+
version: '4'
|
|
40
42
|
type: :runtime
|
|
41
43
|
prerelease: false
|
|
42
44
|
version_requirements: !ruby/object:Gem::Requirement
|
|
43
45
|
requirements:
|
|
44
|
-
- - "
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '1.3'
|
|
49
|
+
- - "<"
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: '4'
|
|
52
|
+
- !ruby/object:Gem::Dependency
|
|
53
|
+
name: minitest
|
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
|
55
|
+
requirements:
|
|
56
|
+
- - ">="
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
version: '5.15'
|
|
59
|
+
- - "<"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '7'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
45
67
|
- !ruby/object:Gem::Version
|
|
46
|
-
version:
|
|
68
|
+
version: '5.15'
|
|
69
|
+
- - "<"
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: '7'
|
|
72
|
+
- !ruby/object:Gem::Dependency
|
|
73
|
+
name: rake
|
|
74
|
+
requirement: !ruby/object:Gem::Requirement
|
|
75
|
+
requirements:
|
|
76
|
+
- - ">="
|
|
77
|
+
- !ruby/object:Gem::Version
|
|
78
|
+
version: '12'
|
|
79
|
+
- - "<"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '14'
|
|
82
|
+
type: :development
|
|
83
|
+
prerelease: false
|
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '12'
|
|
89
|
+
- - "<"
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '14'
|
|
47
92
|
description: Create docx template using Ruby
|
|
48
|
-
email:
|
|
93
|
+
email:
|
|
94
|
+
- hammad.maqbool@phaedrasolutions.com
|
|
95
|
+
- hammad417@gmail.com
|
|
49
96
|
executables: []
|
|
50
97
|
extensions: []
|
|
51
98
|
extra_rdoc_files: []
|
|
52
99
|
files:
|
|
100
|
+
- CHANGELOG.md
|
|
53
101
|
- LICENSE
|
|
54
102
|
- README.md
|
|
55
103
|
- Rakefile
|
|
@@ -63,12 +111,15 @@ files:
|
|
|
63
111
|
- lib/docxi/properties/core.rb
|
|
64
112
|
- lib/docxi/relationships.rb
|
|
65
113
|
- lib/docxi/relationships/relationship.rb
|
|
114
|
+
- lib/docxi/util.rb
|
|
66
115
|
- lib/docxi/version.rb
|
|
67
116
|
- lib/docxi/word.rb
|
|
68
117
|
- lib/docxi/word/contents.rb
|
|
69
118
|
- lib/docxi/word/contents/break.rb
|
|
119
|
+
- lib/docxi/word/contents/frame.rb
|
|
70
120
|
- lib/docxi/word/contents/image.rb
|
|
71
121
|
- lib/docxi/word/contents/paragraph.rb
|
|
122
|
+
- lib/docxi/word/contents/tab.rb
|
|
72
123
|
- lib/docxi/word/contents/table.rb
|
|
73
124
|
- lib/docxi/word/contents/table_of_content.rb
|
|
74
125
|
- lib/docxi/word/contents/text.rb
|
|
@@ -83,6 +134,8 @@ files:
|
|
|
83
134
|
- lib/docxi/word/headers.rb
|
|
84
135
|
- lib/docxi/word/headers/header.rb
|
|
85
136
|
- lib/docxi/word/helpers.rb
|
|
137
|
+
- lib/docxi/word/hyperlinks.rb
|
|
138
|
+
- lib/docxi/word/hyperlinks/hyperlink.rb
|
|
86
139
|
- lib/docxi/word/medias.rb
|
|
87
140
|
- lib/docxi/word/medias/media.rb
|
|
88
141
|
- lib/docxi/word/numbering.rb
|
|
@@ -93,11 +146,14 @@ files:
|
|
|
93
146
|
- lib/docxi/word/themes.rb
|
|
94
147
|
- lib/docxi/word/themes/theme.rb
|
|
95
148
|
- lib/docxi/word/web_settings.rb
|
|
96
|
-
homepage:
|
|
149
|
+
homepage: https://github.com/hammad417/docxi
|
|
97
150
|
licenses:
|
|
98
151
|
- MIT
|
|
99
|
-
metadata:
|
|
100
|
-
|
|
152
|
+
metadata:
|
|
153
|
+
source_code_uri: https://github.com/hammad417/docxi
|
|
154
|
+
changelog_uri: https://github.com/hammad417/docxi/blob/master/CHANGELOG.md
|
|
155
|
+
bug_tracker_uri: https://github.com/hammad417/docxi/issues
|
|
156
|
+
rubygems_mfa_required: 'true'
|
|
101
157
|
rdoc_options: []
|
|
102
158
|
require_paths:
|
|
103
159
|
- lib
|
|
@@ -105,16 +161,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
105
161
|
requirements:
|
|
106
162
|
- - ">="
|
|
107
163
|
- !ruby/object:Gem::Version
|
|
108
|
-
version: '
|
|
164
|
+
version: '2.5'
|
|
109
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
166
|
requirements:
|
|
111
167
|
- - ">="
|
|
112
168
|
- !ruby/object:Gem::Version
|
|
113
169
|
version: '0'
|
|
114
170
|
requirements: []
|
|
115
|
-
|
|
116
|
-
rubygems_version: 2.4.3
|
|
117
|
-
signing_key:
|
|
171
|
+
rubygems_version: 4.0.20
|
|
118
172
|
specification_version: 4
|
|
119
173
|
summary: Docx Template Generator
|
|
120
174
|
test_files: []
|