documenter 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/documenter.gemspec +7 -1
- data/lib/documenter/ooo/odf.rb +8 -2
- data/lib/documenter/ooo/odt.rb +9 -10
- data/test/17474316977tmp.odf +0 -0
- data/test/17474338776tmp.xml +2 -0
- data/test/myout.csv +3 -0
- data/test/out.pdf +0 -0
- data/test/test1.pdf +0 -0
- data/test/test_data/custom_register.odt +0 -0
- data/test/test_documenter.rb +8 -0
- metadata +7 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/documenter.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{documenter}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["A N"]
|
@@ -44,7 +44,13 @@ Gem::Specification.new do |s|
|
|
44
44
|
"lib/documenter/ooo/odt.rb",
|
45
45
|
"lib/documenter/pdf.rb",
|
46
46
|
"lib/documenter/pdftk/pdftk.exe",
|
47
|
+
"test/17474316977tmp.odf",
|
48
|
+
"test/17474338776tmp.xml",
|
47
49
|
"test/helper.rb",
|
50
|
+
"test/myout.csv",
|
51
|
+
"test/out.pdf",
|
52
|
+
"test/test1.pdf",
|
53
|
+
"test/test_data/custom_register.odt",
|
48
54
|
"test/test_documenter.rb"
|
49
55
|
]
|
50
56
|
s.homepage = %q{http://github.com/goremika/documenter}
|
data/lib/documenter/ooo/odf.rb
CHANGED
@@ -8,8 +8,9 @@ class OdfFile
|
|
8
8
|
|
9
9
|
def initialize filename
|
10
10
|
#working with copy
|
11
|
+
ext = filename.split('.')[-1]
|
11
12
|
rn = random_name
|
12
|
-
@file = random_name+'tmp.
|
13
|
+
@file = random_name+'tmp.'+ext
|
13
14
|
@content = random_name+'tmp.xml'
|
14
15
|
|
15
16
|
File.copy filename, @file
|
@@ -37,6 +38,11 @@ class OdfFile
|
|
37
38
|
puts "just before saving"
|
38
39
|
zip.replace('content.xml',@content)
|
39
40
|
zip.close
|
40
|
-
|
41
|
+
if filename.split('.')[-1]=='odt'
|
42
|
+
File.copy @file, filename
|
43
|
+
else
|
44
|
+
Converter.convert @file, filename
|
45
|
+
end
|
46
|
+
|
41
47
|
end
|
42
48
|
end
|
data/lib/documenter/ooo/odt.rb
CHANGED
@@ -44,6 +44,13 @@ class OdtText
|
|
44
44
|
@xml.to_html
|
45
45
|
end
|
46
46
|
|
47
|
+
def fill_table params
|
48
|
+
edit_table(params) do |row, content|
|
49
|
+
row.replace_form content
|
50
|
+
row
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
47
54
|
|
48
55
|
def edit_table params
|
49
56
|
@name = params[:name]
|
@@ -69,11 +76,7 @@ class OdtText
|
|
69
76
|
#puts @xml
|
70
77
|
end
|
71
78
|
|
72
|
-
|
73
|
-
edit_table_rows(params) do |row, row_date|
|
74
|
-
row.replace_form(row_data)
|
75
|
-
end
|
76
|
-
end
|
79
|
+
|
77
80
|
|
78
81
|
end
|
79
82
|
|
@@ -81,7 +84,7 @@ class OdtFile < OdfFile
|
|
81
84
|
attr_accessor :text
|
82
85
|
|
83
86
|
def initialize filename
|
84
|
-
super
|
87
|
+
super filename
|
85
88
|
load
|
86
89
|
end
|
87
90
|
|
@@ -97,10 +100,6 @@ class OdtFile < OdfFile
|
|
97
100
|
|
98
101
|
def save filename
|
99
102
|
save_changes
|
100
|
-
name, extention = filename.split('.')
|
101
|
-
extention = 'odt' if !extention
|
102
|
-
raise "Wrong extention #{extention} for odt file" if extention != 'odt'
|
103
|
-
filename = "#{name}.#{extention}"
|
104
103
|
super filename
|
105
104
|
end
|
106
105
|
|
Binary file
|
@@ -0,0 +1,2 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:rdfa="http://docs.oasis-open.org/opendocument/meta/rdfa#" xmlns:field="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" office:version="1.2"><office:scripts/><office:font-face-decls><style:font-face style:name="OpenSymbol" svg:font-family="OpenSymbol"/><style:font-face style:name="ARial" svg:font-family="ARial" style:font-family-generic="swiss"/><style:font-face style:name="Arial1" svg:font-family="Arial" style:font-family-generic="swiss"/><style:font-face style:name="Nimbus Roman No9 L" svg:font-family="'Nimbus Roman No9 L'" style:font-family-generic="roman" style:font-pitch="variable"/><style:font-face style:name="Times New Roman" svg:font-family="'Times New Roman'" style:font-family-generic="roman" style:font-pitch="variable"/><style:font-face style:name="Arial" svg:font-family="Arial" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="DejaVu Sans1" svg:font-family="'DejaVu Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="Nimbus Sans L" svg:font-family="'Nimbus Sans L', Arial" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="DejaVu Sans" svg:font-family="'DejaVu Sans'" style:font-family-generic="system" style:font-pitch="variable"/></office:font-face-decls><office:automatic-styles><style:style style:name="Table1" style:family="table"><style:table-properties style:width="6.9375in" table:align="margins" style:writing-mode="lr-tb"/></style:style><style:style style:name="Table1.A" style:family="table-column"><style:table-column-properties style:column-width="6.9375in" style:rel-column-width="65535*"/></style:style><style:style style:name="Table1.A1" style:family="table-cell"><style:table-cell-properties fo:background-color="#e6e6e6" fo:padding="0.0382in" fo:border="0.0007in solid #000000"><style:background-image/></style:table-cell-properties></style:style><style:style style:name="posts" style:family="table"><style:table-properties style:width="6.9375in" table:align="margins" style:writing-mode="lr-tb"/></style:style><style:style style:name="posts.A" style:family="table-column"><style:table-column-properties style:column-width="6.9375in" style:rel-column-width="65535*"/></style:style><style:style style:name="posts.A1" style:family="table-cell"><style:table-cell-properties fo:padding="0.0382in" fo:border="none"/></style:style><style:style style:name="packets" style:family="table"><style:table-properties style:width="6.8611in" table:align="margins" style:writing-mode="lr-tb"/></style:style><style:style style:name="packets.A" style:family="table-column"><style:table-column-properties style:column-width="2.3299in" style:rel-column-width="22254*"/></style:style><style:style style:name="packets.B" style:family="table-column"><style:table-column-properties style:column-width="2.2438in" style:rel-column-width="21431*"/></style:style><style:style style:name="packets.C" style:family="table-column"><style:table-column-properties style:column-width="2.2875in" style:rel-column-width="21850*"/></style:style><style:style style:name="packets.1" style:family="table-row"><style:table-row-properties style:min-row-height="0.0556in"/></style:style><style:style style:name="packets.A1" style:family="table-cell"><style:table-cell-properties fo:padding="0.0382in" fo:border="none"/></style:style><style:style style:name="packets.2" style:family="table-row"><style:table-row-properties style:min-row-height="0.2167in"/></style:style><style:style style:name="Table4" style:family="table"><style:table-properties style:width="6.8611in" table:align="margins" style:writing-mode="lr-tb"/></style:style><style:style style:name="Table4.A" style:family="table-column"><style:table-column-properties style:column-width="6.8611in" style:rel-column-width="65535*"/></style:style><style:style style:name="Table4.A1" style:family="table-cell"><style:table-cell-properties fo:background-color="transparent" fo:padding="0.0382in" fo:border-left="none" fo:border-right="none" fo:border-top="none" fo:border-bottom="0.0007in solid #000000"><style:background-image/></style:table-cell-properties></style:style><style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-left="1.6807in" fo:margin-right="0in" fo:text-align="center" style:justify-single-word="false" fo:text-indent="-1.389in" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0.3193in"/><style:tab-stop style:position="1.5626in"/></style:tab-stops></style:paragraph-properties></style:style><style:style style:name="P2" style:family="paragraph" style:parent-style-name="Text_20_body"><style:paragraph-properties fo:margin-left="1.6807in" fo:margin-right="0in" fo:text-align="start" style:justify-single-word="false" fo:text-indent="-1.389in" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0.3193in"/><style:tab-stop style:position="1.5626in"/></style:tab-stops></style:paragraph-properties><style:text-properties style:font-name="ARial" fo:font-size="10pt" fo:language="en" fo:country="US" fo:font-weight="normal" style:font-size-asian="8.75pt" style:font-weight-asian="normal" style:font-size-complex="10pt" style:font-weight-complex="normal"/></style:style><style:style style:name="P3" style:family="paragraph" style:parent-style-name="Text_20_body"><style:paragraph-properties fo:margin-left="1.6807in" fo:margin-right="0in" fo:text-align="start" style:justify-single-word="false" fo:text-indent="-1.389in" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0.3193in"/><style:tab-stop style:position="1.5626in"/></style:tab-stops></style:paragraph-properties><style:text-properties style:font-name="ARial" fo:font-size="8pt" fo:language="en" fo:country="US" fo:font-weight="normal" style:font-size-asian="8pt" style:font-weight-asian="normal" style:font-size-complex="8pt" style:font-weight-complex="normal"/></style:style><style:style style:name="P4" style:family="paragraph" style:parent-style-name="Text_20_body"><style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/><style:text-properties style:font-name="ARial" fo:font-size="10pt" fo:language="en" fo:country="US" fo:font-weight="normal" style:font-size-asian="8.75pt" style:font-weight-asian="normal" style:font-size-complex="10pt" style:font-weight-complex="normal"/></style:style><style:style style:name="P5" style:family="paragraph" style:parent-style-name="Table_20_Contents"><style:text-properties fo:font-size="2pt" style:font-size-asian="2pt" style:font-size-complex="2pt"/></style:style><style:style style:name="P6" style:family="paragraph" style:parent-style-name="Table_20_Contents"><style:text-properties style:font-name="ARial"/></style:style><style:style style:name="P7" style:family="paragraph" style:parent-style-name="Table_20_Contents"><style:text-properties style:font-name="ARial" fo:font-size="2pt" fo:font-weight="normal" style:font-size-asian="2pt" style:font-weight-asian="normal" style:font-size-complex="2pt" style:font-weight-complex="normal"/></style:style><style:style style:name="P8" style:family="paragraph" style:parent-style-name="Table_20_Contents"><style:text-properties style:font-name="ARial" fo:font-size="8pt" fo:font-weight="normal" style:font-size-asian="8pt" style:font-weight-asian="normal" style:font-size-complex="8pt" style:font-weight-complex="normal"/></style:style><style:style style:name="P9" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/><style:text-properties style:font-name="ARial" fo:font-size="8pt" fo:language="en" fo:country="US" style:font-size-asian="8pt" style:font-size-complex="8pt"/></style:style><style:style style:name="P10" style:family="paragraph" style:parent-style-name="Heading_20_1"><style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/><style:text-properties style:font-name="ARial" fo:font-size="12pt" fo:language="en" fo:country="US" style:font-size-asian="12pt" style:font-size-complex="12pt"/></style:style><style:style style:name="P11" style:family="paragraph" style:parent-style-name="Heading_20_1"><style:paragraph-properties fo:background-color="transparent"><style:background-image/></style:paragraph-properties><style:text-properties style:font-name="ARial" fo:font-size="8pt" fo:language="en" fo:country="US" fo:font-weight="bold" style:font-size-asian="8pt" style:font-weight-asian="bold" style:font-size-complex="8pt" style:font-weight-complex="bold"/></style:style><style:style style:name="P12" style:family="paragraph" style:parent-style-name="Heading_20_10"><style:paragraph-properties fo:margin-left="1.6807in" fo:margin-right="0in" fo:text-align="start" style:justify-single-word="false" fo:text-indent="-1.389in" style:auto-text-indent="false"><style:tab-stops><style:tab-stop style:position="0.3193in"/><style:tab-stop style:position="1.5626in"/></style:tab-stops></style:paragraph-properties><style:text-properties style:font-name="ARial" fo:font-size="8pt" fo:font-weight="normal" style:font-size-asian="8pt" style:font-weight-asian="normal" style:font-size-complex="8pt" style:font-weight-complex="normal"/></style:style><style:style style:name="T1" style:family="text"><style:text-properties fo:language="en" fo:country="US"/></style:style><style:style style:name="T2" style:family="text"><style:text-properties style:font-name="Arial1" fo:font-size="8pt" fo:language="en" fo:country="US" style:font-size-asian="8pt" style:font-size-complex="8pt"/></style:style></office:automatic-styles><office:body><office:text><office:forms form:automatic-focus="false" form:apply-design-mode="false"/><text:sequence-decls><text:sequence-decl text:display-outline-level="0" text:name="Illustration"/><text:sequence-decl text:display-outline-level="0" text:name="Table"/><text:sequence-decl text:display-outline-level="0" text:name="Text"/><text:sequence-decl text:display-outline-level="0" text:name="Drawing"/></text:sequence-decls><text:user-field-decls><text:user-field-decl office:value-type="string" office:string-value="group_number" text:name="group_number"/><text:user-field-decl office:value-type="string" office:string-value="number" text:name="number"/><text:user-field-decl office:value-type="string" office:string-value="surname" text:name="surname"/><text:user-field-decl office:value-type="string" office:string-value="name" text:name="name"/><text:user-field-decl office:value-type="string" office:string-value="fathername" text:name="fathername"/><text:user-field-decl office:value-type="string" office:string-value="adr" text:name="adr"/><text:user-field-decl office:value-type="string" office:string-value="packet_number" text:name="packet_number"/><text:user-field-decl office:value-type="string" office:string-value="cur_date" text:name="cur_date"/><text:user-field-decl office:value-type="string" office:string-value="post_date" text:name="post_date"/><text:user-field-decl office:value-type="string" office:string-value="posts" text:name="posts"/><text:user-field-decl office:value-type="string" office:string-value="t" text:name="t"/></text:user-field-decls><text:h text:style-name="P10" text:outline-level="1"/><text:h text:style-name="P10" text:outline-level="1">Реестр выдачи экспресс-грузов</text:h><text:p text:style-name="P9"/><text:p text:style-name="P9"><text:s/></text:p><table:table table:name="Table1" table:style-name="Table1"><table:table-column table:style-name="Table1.A"/><table:table-row><table:table-cell table:style-name="Table1.A1" office:value-type="string"><text:h text:style-name="P11" text:outline-level="1">Группа №: <text:s/><text:user-field-get text:name="group_number">group_number</text:user-field-get></text:h></table:table-cell></table:table-row></table:table><text:h text:style-name="P12" text:outline-level="10"><text:span text:style-name="T1"><text:s/></text:span><text:span text:style-name="T1"><text:user-field-get text:name="number">number</text:user-field-get></text:span><text:span text:style-name="T1"> <text:tab/> </text:span><text:span text:style-name="T1"><text:user-field-get text:name="surname">surname</text:user-field-get></text:span><text:span text:style-name="T1"> </text:span><text:span text:style-name="T1"><text:user-field-get text:name="name">name</text:user-field-get></text:span><text:span text:style-name="T1"> </text:span><text:span text:style-name="T1"><text:user-field-get text:name="fathername">fathername</text:user-field-get></text:span><text:span text:style-name="T1">, </text:span><text:span text:style-name="T1"><text:user-field-get text:name="adr">adr</text:user-field-get></text:span></text:h><table:table table:name="posts" table:style-name="posts"><table:table-column table:style-name="posts.A"/><table:table-row><table:table-cell table:style-name="posts.A1" office:value-type="string"><text:p text:style-name="P5"/></table:table-cell></table:table-row><table:table-row><table:table-cell table:style-name="posts.A1" office:value-type="string"><text:p text:style-name="Table_20_Contents"/><text:p text:style-name="P1"><text:span text:style-name="T2">Отправка <text:s/></text:span><text:span text:style-name="T2"><text:user-field-get text:name="posts">posts</text:user-field-get></text:span><text:span text:style-name="T2"> <text:s text:c="14"/>от </text:span><text:span text:style-name="T2"><text:user-field-get text:name="post_date">post_date</text:user-field-get></text:span></text:p><table:table table:name="packets" table:style-name="packets"><table:table-column table:style-name="packets.A"/><table:table-column table:style-name="packets.B"/><table:table-column table:style-name="packets.C"/><table:table-row table:style-name="packets.1"><table:table-cell table:style-name="packets.A1" office:value-type="string"><text:p text:style-name="P7"/></table:table-cell><table:table-cell table:style-name="packets.A1" office:value-type="string"><text:p text:style-name="P7"/></table:table-cell><table:table-cell table:style-name="packets.A1" office:value-type="string"><text:p text:style-name="P7"/></table:table-cell></table:table-row><table:table-row table:style-name="packets.2"><table:table-cell table:style-name="packets.A1" office:value-type="string"><text:p text:style-name="P8"><text:s/><text:user-field-get text:name="packet_number">packet_number</text:user-field-get> <text:s/><text:user-field-get text:name="t">t</text:user-field-get></text:p></table:table-cell><table:table-cell table:style-name="packets.A1" office:value-type="string"><text:p text:style-name="P8">Получил:</text:p></table:table-cell><table:table-cell table:style-name="packets.A1" office:value-type="string"><text:p text:style-name="P8"><text:user-field-get text:name="cur_date">cur_date</text:user-field-get> <text:user-field-get text:name="t">t</text:user-field-get><text:user-field-get text:name="t">t</text:user-field-get></text:p></table:table-cell></table:table-row></table:table><text:p text:style-name="P4"/><table:table table:name="Table4" table:style-name="Table4"><table:table-column table:style-name="Table4.A"/><table:table-row><table:table-cell table:style-name="Table4.A1" office:value-type="string"><text:p text:style-name="P6"/></table:table-cell></table:table-row></table:table><text:p text:style-name="Text_20_body"/><text:p text:style-name="Table_20_Contents"/></table:table-cell></table:table-row></table:table><text:p text:style-name="P3"/><text:p text:style-name="P3"/><text:p text:style-name="P3"/><text:p text:style-name="P3"/><text:p text:style-name="P2"/></office:text></office:body></office:document-content>
|
data/test/myout.csv
ADDED
data/test/out.pdf
ADDED
Binary file
|
data/test/test1.pdf
ADDED
Binary file
|
Binary file
|
data/test/test_documenter.rb
CHANGED
@@ -9,5 +9,13 @@ class TestDocumenter < Test::Unit::TestCase
|
|
9
9
|
|
10
10
|
end
|
11
11
|
|
12
|
+
should "fill form and save as pdf" do
|
13
|
+
doc = OdtFile.new 'test_data/custom_register.odt'
|
14
|
+
data = [{'posts' => '123'}, {'posts' => 'abcd'}]
|
15
|
+
doc.text.fill_table(:name => "posts", :data => data)
|
16
|
+
doc.save 'out.pdf'
|
17
|
+
doc.close
|
18
|
+
end
|
19
|
+
|
12
20
|
|
13
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: documenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- A N
|
@@ -79,7 +79,13 @@ files:
|
|
79
79
|
- lib/documenter/ooo/odt.rb
|
80
80
|
- lib/documenter/pdf.rb
|
81
81
|
- lib/documenter/pdftk/pdftk.exe
|
82
|
+
- test/17474316977tmp.odf
|
83
|
+
- test/17474338776tmp.xml
|
82
84
|
- test/helper.rb
|
85
|
+
- test/myout.csv
|
86
|
+
- test/out.pdf
|
87
|
+
- test/test1.pdf
|
88
|
+
- test/test_data/custom_register.odt
|
83
89
|
- test/test_documenter.rb
|
84
90
|
has_rdoc: true
|
85
91
|
homepage: http://github.com/goremika/documenter
|