odf-report 0.5.1 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +5 -13
  2. data/.github/workflows/gem-push.yml +40 -0
  3. data/.gitignore +2 -0
  4. data/.rspec +4 -0
  5. data/CHANGELOG.md +56 -0
  6. data/README.md +220 -0
  7. data/Rakefile +8 -0
  8. data/bin/odt-extract +10 -0
  9. data/bin/odt-viewer +18 -0
  10. data/lib/odf-report.rb +11 -9
  11. data/lib/odf-report/data_source.rb +65 -0
  12. data/lib/odf-report/field.rb +35 -36
  13. data/lib/odf-report/image.rb +57 -0
  14. data/lib/odf-report/nestable.rb +65 -0
  15. data/lib/odf-report/parser/default.rb +5 -4
  16. data/lib/odf-report/report.rb +29 -57
  17. data/lib/odf-report/section.rb +17 -80
  18. data/lib/odf-report/table.rb +52 -81
  19. data/lib/odf-report/template.rb +88 -0
  20. data/lib/odf-report/text.rb +2 -4
  21. data/lib/odf-report/version.rb +1 -1
  22. data/odf-report.gemspec +7 -4
  23. data/spec/fields_spec.rb +77 -0
  24. data/spec/images/image_1.jpg +0 -0
  25. data/spec/images/image_2.jpg +0 -0
  26. data/spec/images/image_3.jpg +0 -0
  27. data/{test → spec/images}/piriapolis.jpg +0 -0
  28. data/spec/images/placeholder.jpg +0 -0
  29. data/{test → spec/images}/rails.png +0 -0
  30. data/spec/images_spec.rb +159 -0
  31. data/spec/sections_spec.rb +51 -0
  32. data/spec/spec_helper.rb +43 -0
  33. data/spec/tables_spec.rb +39 -0
  34. data/spec/template_spec.rb +45 -0
  35. data/spec/templates/images.odt +0 -0
  36. data/spec/templates/specs.odt +0 -0
  37. data/test/fields_inside_text_test.rb +38 -0
  38. data/test/images_test.rb +32 -0
  39. data/test/nested_tables_test.rb +43 -0
  40. data/test/sections_test.rb +44 -0
  41. data/test/sub_sections_test.rb +58 -0
  42. data/test/table_headers_test.rb +41 -0
  43. data/test/tables_test.rb +67 -0
  44. data/test/templates/images/image_1.jpg +0 -0
  45. data/test/templates/images/image_2.jpg +0 -0
  46. data/test/templates/images/image_3.jpg +0 -0
  47. data/test/templates/images/placeholder.jpg +0 -0
  48. data/test/templates/images/placeholder.png +0 -0
  49. data/test/templates/piriapolis.jpg +0 -0
  50. data/test/templates/rails.png +0 -0
  51. data/test/templates/test_images.odt +0 -0
  52. data/test/templates/test_sub_sections.odt +0 -0
  53. data/test/templates/test_text.odt +0 -0
  54. data/test/test.rb +262 -0
  55. data/test/text_test.rb +56 -0
  56. metadata +151 -46
  57. data/README.textile +0 -225
  58. data/lib/odf-report/fields.rb +0 -40
  59. data/lib/odf-report/file.rb +0 -50
  60. data/lib/odf-report/images.rb +0 -44
  61. data/lib/odf-report/nested.rb +0 -34
  62. data/test/test_fields_inside_text.rb +0 -37
  63. data/test/test_nested_tables.rb +0 -39
  64. data/test/test_sections.rb +0 -39
  65. data/test/test_sub_sections.rb +0 -57
  66. data/test/test_table_headers.rb +0 -39
  67. data/test/test_tables.rb +0 -62
  68. data/test/test_text.rb +0 -48
@@ -0,0 +1,67 @@
1
+ require './lib/odf-report'
2
+ require 'ostruct'
3
+ require 'faker'
4
+ require 'launchy'
5
+
6
+
7
+ @col1 = []
8
+ (1..40).each do |i|
9
+ @col1 << {:name=>"name #{i}", :idx=>i, :address=>"this is address #{i}"}
10
+ end
11
+
12
+
13
+ @col2 = []
14
+ @col2 << OpenStruct.new({:name=>"josh harnet", :idx=>"02", :address=>"testing <&> ", :phone=>99025668, :zip=>"90420-002"})
15
+ @col2 << OpenStruct.new({:name=>"sandro duarte", :idx=>"45", :address=>"address with &", :phone=>88774451, :zip=>"90490-002"})
16
+ @col2 << OpenStruct.new({:name=>"ellen bicca", :idx=>"77", :address=>"<address with escaped html>", :phone=>77025668, :zip=>"94420-002"})
17
+ @col2 << OpenStruct.new({:name=>"luiz garcia", 'idx'=>"88", :address=>"address with\nlinebreak", :phone=>27025668, :zip=>"94520-025"})
18
+
19
+ @col3, @col4, @col5 = [], [], []
20
+
21
+
22
+
23
+ report = ODFReport::Report.new("test/templates/test_tables.odt") do |r|
24
+
25
+ r.add_field("HEADER_FIELD", "This field was in the HEADER")
26
+
27
+ r.add_field("TAG_01", "New tag")
28
+ r.add_field("TAG_02", "TAG-2 -> New tag")
29
+
30
+ r.add_table("TABLE_01", @col1, :header=>true) do |t|
31
+ t.add_column(:field_01, :idx)
32
+ t.add_column(:field_02, :name)
33
+ t.add_column(:address)
34
+ end
35
+
36
+ r.add_table("TABLE_02", @col2) do |t|
37
+ t.add_column(:field_04, :idx)
38
+ t.add_column(:field_05, :name)
39
+ t.add_column(:field_06, 'address')
40
+ t.add_column(:field_07, :phone)
41
+ t.add_column(:field_08, :zip)
42
+ end
43
+
44
+ r.add_table("TABLE_03", @col3, :header=>true) do |t|
45
+ t.add_column(:field_01, :idx)
46
+ t.add_column(:field_02, :name)
47
+ t.add_column(:field_03, :address)
48
+ end
49
+
50
+ r.add_table("TABLE_04", @col4, :header=>true, :skip_if_empty => true) do |t|
51
+ t.add_column(:field_01, :idx)
52
+ t.add_column(:field_02, :name)
53
+ t.add_column(:field_03, :address)
54
+ end
55
+
56
+ r.add_table("TABLE_05", @col5) do |t|
57
+ t.add_column(:field_01, :idx)
58
+ t.add_column(:field_02, :name)
59
+ t.add_column(:field_03, :address)
60
+ end
61
+
62
+ r.add_image("graphics1", File.join(Dir.pwd, 'test', 'templates', 'piriapolis.jpg'))
63
+ r.add_image("graphics2", File.join(Dir.pwd, 'test', 'templates', 'rails.png'))
64
+
65
+ end
66
+
67
+ report.generate("test/result/test_tables.odt")
Binary file
Binary file
@@ -0,0 +1,262 @@
1
+ require 'nokogiri'
2
+
3
+ xml = <<-XML
4
+ <?xml version="1.0" encoding="UTF-8"?>
5
+ <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:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2">
6
+ <office:scripts/>
7
+ <office:font-face-decls>
8
+ <style:font-face style:name="Tahoma1" svg:font-family="Tahoma"/>
9
+ <style:font-face style:name="Arial1" svg:font-family="Arial" style:font-family-generic="swiss"/>
10
+ <style:font-face style:name="Courier New" svg:font-family="'Courier New'" style:font-family-generic="modern" style:font-pitch="variable"/>
11
+ <style:font-face style:name="Times New Roman" svg:font-family="'Times New Roman'" style:font-family-generic="roman" style:font-pitch="variable"/>
12
+ <style:font-face style:name="Arial" svg:font-family="Arial" style:font-family-generic="swiss" style:font-pitch="variable"/>
13
+ <style:font-face style:name="Arial Unicode MS" svg:font-family="'Arial Unicode MS'" style:font-family-generic="system" style:font-pitch="variable"/>
14
+ <style:font-face style:name="Tahoma" svg:font-family="Tahoma" style:font-family-generic="system" style:font-pitch="variable"/>
15
+ </office:font-face-decls>
16
+ <office:automatic-styles>
17
+ <style:style style:name="TABLE_5f_01" style:display-name="TABLE_01" style:family="table">
18
+ <style:table-properties style:width="16.999cm" table:align="margins"/>
19
+ </style:style>
20
+ <style:style style:name="TABLE_5f_01.A" style:display-name="TABLE_01.A" style:family="table-column">
21
+ <style:table-column-properties style:column-width="5.666cm" style:rel-column-width="21845*"/>
22
+ </style:style>
23
+ <style:style style:name="TABLE_5f_01.A1" style:display-name="TABLE_01.A1" style:family="table-cell">
24
+ <style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.05pt solid #000000" fo:border-right="none" fo:border-top="0.05pt solid #000000" fo:border-bottom="0.05pt solid #000000"/>
25
+ </style:style>
26
+ <style:style style:name="TABLE_5f_01.C1" style:display-name="TABLE_01.C1" style:family="table-cell">
27
+ <style:table-cell-properties fo:padding="0.097cm" fo:border="0.05pt solid #000000"/>
28
+ </style:style>
29
+ <style:style style:name="TABLE_5f_02" style:display-name="TABLE_02" style:family="table">
30
+ <style:table-properties style:width="16.999cm" table:align="margins"/>
31
+ </style:style>
32
+ <style:style style:name="TABLE_5f_02.A" style:display-name="TABLE_02.A" style:family="table-column">
33
+ <style:table-column-properties style:column-width="5.666cm" style:rel-column-width="21845*"/>
34
+ </style:style>
35
+ <style:style style:name="TABLE_5f_02.A1" style:display-name="TABLE_02.A1" style:family="table-cell">
36
+ <style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.05pt solid #000000" fo:border-right="none" fo:border-top="0.05pt solid #000000" fo:border-bottom="0.05pt solid #000000"/>
37
+ </style:style>
38
+ <style:style style:name="TABLE_5f_02.C1" style:display-name="TABLE_02.C1" style:family="table-cell">
39
+ <style:table-cell-properties fo:padding="0.097cm" fo:border="0.05pt solid #000000"/>
40
+ </style:style>
41
+ <style:style style:name="TABLE_5f_03" style:display-name="TABLE_03" style:family="table">
42
+ <style:table-properties style:width="16.999cm" table:align="margins"/>
43
+ </style:style>
44
+ <style:style style:name="TABLE_5f_03.A" style:display-name="TABLE_03.A" style:family="table-column">
45
+ <style:table-column-properties style:column-width="5.666cm" style:rel-column-width="21845*"/>
46
+ </style:style>
47
+ <style:style style:name="TABLE_5f_03.A1" style:display-name="TABLE_03.A1" style:family="table-cell">
48
+ <style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.05pt solid #000000" fo:border-right="none" fo:border-top="0.05pt solid #000000" fo:border-bottom="0.05pt solid #000000"/>
49
+ </style:style>
50
+ <style:style style:name="TABLE_5f_03.C1" style:display-name="TABLE_03.C1" style:family="table-cell">
51
+ <style:table-cell-properties fo:padding="0.097cm" fo:border="0.05pt solid #000000"/>
52
+ </style:style>
53
+ <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard">
54
+ <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-align="start" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false" style:text-autospace="none"/>
55
+ <style:text-properties style:font-name="Arial1" fo:font-size="12pt" fo:language="zxx" fo:country="none" style:font-name-asian="Arial1" style:font-size-asian="12pt" style:language-asian="zxx" style:country-asian="none" style:font-name-complex="Arial1" style:font-size-complex="12pt" style:language-complex="zxx" style:country-complex="none"/>
56
+ </style:style>
57
+ <style:style style:name="P2" style:family="paragraph" style:parent-style-name="Standard">
58
+ <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-align="start" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false" style:text-autospace="none"/>
59
+ <style:text-properties style:font-name="Arial1" fo:font-size="12pt" fo:language="zxx" fo:country="none" officeooo:rsid="000bcb7a" officeooo:paragraph-rsid="000bcb7a" style:font-name-asian="Arial1" style:font-size-asian="12pt" style:language-asian="zxx" style:country-asian="none" style:font-name-complex="Arial1" style:font-size-complex="12pt" style:language-complex="zxx" style:country-complex="none"/>
60
+ </style:style>
61
+ <style:style style:name="P3" style:family="paragraph" style:parent-style-name="Standard">
62
+ <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-align="start" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false" style:text-autospace="none"/>
63
+ <style:text-properties style:font-name="Arial1" fo:font-size="12pt" fo:language="zxx" fo:country="none" officeooo:rsid="000ccec8" officeooo:paragraph-rsid="000ccec8" style:font-name-asian="Arial1" style:font-size-asian="12pt" style:language-asian="zxx" style:country-asian="none" style:font-name-complex="Arial1" style:font-size-complex="12pt" style:language-complex="zxx" style:country-complex="none"/>
64
+ </style:style>
65
+ <style:style style:name="P4" style:family="paragraph" style:parent-style-name="Standard">
66
+ <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-align="center" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false" style:text-autospace="none"/>
67
+ <style:text-properties style:font-name="Arial1" fo:font-size="10pt" fo:language="zxx" fo:country="none" style:font-name-asian="Arial1" style:font-size-asian="10pt" style:language-asian="zxx" style:country-asian="none" style:font-name-complex="Arial1" style:font-size-complex="10pt" style:language-complex="zxx" style:country-complex="none"/>
68
+ </style:style>
69
+ <style:style style:name="P5" style:family="paragraph" style:parent-style-name="Table_20_Contents">
70
+ <style:paragraph-properties fo:text-align="start" style:justify-single-word="false"/>
71
+ <style:text-properties style:font-name="Arial1" fo:font-size="12pt" officeooo:rsid="000bd2b4" officeooo:paragraph-rsid="000bd2b4" style:font-name-asian="Arial1" style:font-size-asian="12pt" style:font-name-complex="Arial1" style:font-size-complex="12pt"/>
72
+ </style:style>
73
+ <style:style style:name="P6" style:family="paragraph" style:parent-style-name="Standard">
74
+ <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-align="start" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false" style:text-autospace="none"/>
75
+ <style:text-properties style:font-name="Arial1" fo:font-size="12pt" fo:language="zxx" fo:country="none" officeooo:rsid="000bcb7a" officeooo:paragraph-rsid="000bcb7a" style:font-name-asian="Arial1" style:font-size-asian="12pt" style:language-asian="zxx" style:country-asian="none" style:font-name-complex="Arial1" style:font-size-complex="12pt" style:language-complex="zxx" style:country-complex="none"/>
76
+ </style:style>
77
+ <style:style style:name="P7" style:family="paragraph" style:parent-style-name="Standard">
78
+ <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-align="start" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false" style:text-autospace="none"/>
79
+ <style:text-properties style:font-name="Arial1" fo:font-size="12pt" fo:language="zxx" fo:country="none" officeooo:rsid="000df62c" officeooo:paragraph-rsid="000df62c" style:font-name-asian="Arial1" style:font-size-asian="12pt" style:language-asian="zxx" style:country-asian="none" style:font-name-complex="Arial1" style:font-size-complex="12pt" style:language-complex="zxx" style:country-complex="none"/>
80
+ </style:style>
81
+ <style:style style:name="P8" style:family="paragraph" style:parent-style-name="Standard">
82
+ <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-align="start" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false" style:text-autospace="none"/>
83
+ <style:text-properties style:font-name="Arial1" fo:font-size="12pt" fo:language="zxx" fo:country="none" style:font-name-asian="Arial1" style:font-size-asian="12pt" style:language-asian="zxx" style:country-asian="none" style:font-name-complex="Arial1" style:font-size-complex="12pt" style:language-complex="zxx" style:country-complex="none"/>
84
+ </style:style>
85
+ <style:style style:name="P9" style:family="paragraph" style:parent-style-name="Standard">
86
+ <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-align="start" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false" style:text-autospace="none"/>
87
+ <style:text-properties style:font-name="Arial1" fo:font-size="12pt" fo:language="zxx" fo:country="none" officeooo:paragraph-rsid="000df62c" style:font-name-asian="Arial1" style:font-size-asian="12pt" style:language-asian="zxx" style:country-asian="none" style:font-name-complex="Arial1" style:font-size-complex="12pt" style:language-complex="zxx" style:country-complex="none"/>
88
+ </style:style>
89
+ <style:style style:name="P10" style:family="paragraph" style:parent-style-name="Standard">
90
+ <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-align="start" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false" style:text-autospace="none"/>
91
+ <style:text-properties style:font-name="Courier New" fo:font-size="14pt" fo:language="zxx" fo:country="none" officeooo:rsid="000df62c" officeooo:paragraph-rsid="000df62c" style:font-name-asian="Arial1" style:font-size-asian="14pt" style:language-asian="zxx" style:country-asian="none" style:font-name-complex="Arial1" style:font-size-complex="14pt" style:language-complex="zxx" style:country-complex="none"/>
92
+ </style:style>
93
+ <style:style style:name="P11" style:family="paragraph" style:parent-style-name="Standard">
94
+ <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-align="start" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false" fo:break-before="page" style:text-autospace="none"/>
95
+ <style:text-properties style:font-name="Courier New" fo:font-size="14pt" fo:language="zxx" fo:country="none" officeooo:rsid="000df62c" officeooo:paragraph-rsid="000df62c" style:font-name-asian="Arial1" style:font-size-asian="14pt" style:language-asian="zxx" style:country-asian="none" style:font-name-complex="Arial1" style:font-size-complex="14pt" style:language-complex="zxx" style:country-complex="none"/>
96
+ </style:style>
97
+ <style:style style:name="P12" style:family="paragraph" style:parent-style-name="Table_20_Contents">
98
+ <style:paragraph-properties fo:text-align="start" style:justify-single-word="false"/>
99
+ <style:text-properties style:font-name="Arial1" fo:font-size="12pt" officeooo:rsid="000bd2b4" officeooo:paragraph-rsid="000df62c" style:font-name-asian="Arial1" style:font-size-asian="12pt" style:font-name-complex="Arial1" style:font-size-complex="12pt"/>
100
+ </style:style>
101
+ <style:style style:name="Sect1" style:family="section">
102
+ <style:section-properties style:editable="false">
103
+ <style:columns fo:column-count="1" fo:column-gap="0cm"/>
104
+ </style:section-properties>
105
+ </style:style>
106
+ </office:automatic-styles>
107
+ <office:body>
108
+ <office:text text:use-soft-page-breaks="true">
109
+ <text:sequence-decls>
110
+ <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
111
+ <text:sequence-decl text:display-outline-level="0" text:name="Table"/>
112
+ <text:sequence-decl text:display-outline-level="0" text:name="Text"/>
113
+ <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
114
+ </text:sequence-decls>
115
+ <text:p text:style-name="P10">fields_spec.rb</text:p>
116
+ <text:p text:style-name="P10"/>
117
+ <text:p text:style-name="P2"/>
118
+ <text:p text:style-name="P2">Field_01: Smitham, Veum and Funk</text:p>
119
+ <text:p text:style-name="P2">Field_02: Bert Bogan</text:p>
120
+ <text:p text:style-name="P1"/>
121
+ <text:p text:style-name="P1"/>
122
+ <table:table table:name="TABLE_01" table:style-name="TABLE_5f_01">
123
+ <table:table-column table:style-name="TABLE_5f_01.A" table:number-columns-repeated="3"/>
124
+ <table:table-row xmlns:table="table" xmlns:draw="draw" xmlns:xlink="xlink" xmlns:text="text">
125
+ <table:table-cell table:style-name="TABLE_5f_01.A1" office:value-type="string">
126
+ <text:p text:style-name="P5">2063458380</text:p>
127
+ </table:table-cell>
128
+ <table:table-cell table:style-name="TABLE_5f_01.A1" office:value-type="string">
129
+ <text:p text:style-name="P5">Huey Skiles</text:p>
130
+ </table:table-cell>
131
+ <table:table-cell table:style-name="TABLE_5f_01.C1" office:value-type="string">
132
+ <text:p text:style-name="P5">[COLUMN_03]</text:p>
133
+ </table:table-cell>
134
+ </table:table-row>
135
+ <table:table-row xmlns:table="table" xmlns:draw="draw" xmlns:xlink="xlink" xmlns:text="text">
136
+ <table:table-cell table:style-name="TABLE_5f_01.A1" office:value-type="string">
137
+ <text:p text:style-name="P5">2738946152</text:p>
138
+ </table:table-cell>
139
+ <table:table-cell table:style-name="TABLE_5f_01.A1" office:value-type="string">
140
+ <text:p text:style-name="P5">Elfriede Wyman</text:p>
141
+ </table:table-cell>
142
+ <table:table-cell table:style-name="TABLE_5f_01.C1" office:value-type="string">
143
+ <text:p text:style-name="P5">[COLUMN_03]</text:p>
144
+ </table:table-cell>
145
+ </table:table-row>
146
+ <table:table-row xmlns:table="table" xmlns:draw="draw" xmlns:xlink="xlink" xmlns:text="text">
147
+ <table:table-cell table:style-name="TABLE_5f_01.A1" office:value-type="string">
148
+ <text:p text:style-name="P5">7700127050</text:p>
149
+ </table:table-cell>
150
+ <table:table-cell table:style-name="TABLE_5f_01.A1" office:value-type="string">
151
+ <text:p text:style-name="P5">Waldo Ebert</text:p>
152
+ </table:table-cell>
153
+ <table:table-cell table:style-name="TABLE_5f_01.C1" office:value-type="string">
154
+ <text:p text:style-name="P5">[COLUMN_03]</text:p>
155
+ </table:table-cell>
156
+ </table:table-row>
157
+ </table:table>
158
+ <text:p text:style-name="P1"/>
159
+ <text:p text:style-name="P1"/>
160
+ <text:section xmlns:draw="draw" xmlns:xlink="xlink" xmlns:text="text" text:style-name="Sect1" text:name="3944a5de-a0e4-4a00-a1d5-80e5082221f3">
161
+ <text:p text:style-name="P3">7700127050</text:p>
162
+ <text:p text:style-name="P3">Waldo Ebert</text:p>
163
+ </text:section>
164
+ <text:p text:style-name="P1"/>
165
+ <text:p text:style-name="P1"/>
166
+ <text:p text:style-name="P1"/>
167
+ <text:p text:style-name="P1"/>
168
+ <text:p text:style-name="P11">tables_spec.rb</text:p>
169
+ <text:p text:style-name="P10"/>
170
+ <text:p text:style-name="P9"/>
171
+ <table:table table:name="TABLE_02" table:style-name="TABLE_5f_02">
172
+ <table:table-column table:style-name="TABLE_5f_02.A" table:number-columns-repeated="3"/>
173
+ <table:table-row>
174
+ <table:table-cell table:style-name="TABLE_5f_02.A1" office:value-type="string">
175
+ <text:p text:style-name="P12">[COLUMN_01]</text:p>
176
+ </table:table-cell>
177
+ <table:table-cell table:style-name="TABLE_5f_02.A1" office:value-type="string">
178
+ <text:p text:style-name="P12">[COLUMN_02]</text:p>
179
+ </table:table-cell>
180
+ <table:table-cell table:style-name="TABLE_5f_02.C1" office:value-type="string">
181
+ <text:p text:style-name="P12">[COLUMN_03]</text:p>
182
+ </table:table-cell>
183
+ </table:table-row>
184
+ </table:table>
185
+ <text:p text:style-name="P7"/>
186
+ <table:table table:name="TABLE_03" table:style-name="TABLE_5f_03">
187
+ <table:table-column table:style-name="TABLE_5f_03.A" table:number-columns-repeated="3"/>
188
+ <table:table-row>
189
+ <table:table-cell table:style-name="TABLE_5f_03.A1" office:value-type="string">
190
+ <text:p text:style-name="P12">[COLUMN_01]</text:p>
191
+ </table:table-cell>
192
+ <table:table-cell table:style-name="TABLE_5f_03.A1" office:value-type="string">
193
+ <text:p text:style-name="P12">[COLUMN_02]</text:p>
194
+ </table:table-cell>
195
+ <table:table-cell table:style-name="TABLE_5f_03.C1" office:value-type="string">
196
+ <text:p text:style-name="P12">[COLUMN_03]</text:p>
197
+ </table:table-cell>
198
+ </table:table-row>
199
+ </table:table>
200
+ <text:p text:style-name="P7"/>
201
+ <text:p text:style-name="P4">END_OF_DOCUMENT</text:p>
202
+ </office:text>
203
+ </office:body>
204
+ </office:document-content>
205
+ XML
206
+
207
+ tmp = Nokogiri::XML(xml, &:noblanks)
208
+
209
+ puts tmp.at("text|section")
210
+ # tmp.root['xmlns:table'] = "urn:oasis:names:tc:opendocument:xmlns:table:1.0"
211
+ # tmp.root['xmlns:draw'] = "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
212
+ # tmp.root['xmlns:xlink'] = "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
213
+ #
214
+ # # 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"
215
+ #
216
+ # doc = Nokogiri::XML(tmp.to_xml(:save_with => Nokogiri::XML::Node::SaveOptions::AS_XML))
217
+ #
218
+ # puts doc
219
+ #
220
+ # puts "============="
221
+ #
222
+ # nodo = doc.search("//draw:frame[@draw:name='IMAGE_IN_TABLE']/draw:image")
223
+ # puts nodo
224
+ #
225
+ # nodo.attribute('href').content = 'new_href'
226
+ #
227
+ # puts nodo
228
+ #
229
+ # puts "-------------"
230
+ #
231
+ # puts doc
232
+
233
+ # require 'ox'
234
+ #
235
+ # xml = <<-XML
236
+ # <table:table-row table:style-name="IMAGE_5f_TABLE.2">
237
+ # <table:table-cell table:style-name="IMAGE_5f_TABLE.A2" office:value-type="string">
238
+ # <text:p text:style-name="P8">[IMAGE_NAME]</text:p>
239
+ # </table:table-cell>
240
+ # <table:table-cell table:style-name="IMAGE_5f_TABLE.B2" office:value-type="string">
241
+ # <text:p text:style-name="P7">
242
+ # <draw:frame draw:style-name="fr2" draw:name="sf" text:anchor-type="paragraph" svg:width="2.5in" svg:height="1.25in" draw:z-index="2">
243
+ # <draw:image xlink:href="Pictures/C2.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" loext:mime-type="image/jpeg"/>
244
+ # </draw:frame>
245
+ # <draw:frame draw:style-name="fr2" draw:name="IMAGE_IN_TABLE" text:anchor-type="paragraph" svg:width="2.5in" svg:height="1.25in" draw:z-index="2">
246
+ # <draw:image xlink:href="Pictures/10000000000000F00000007807BDCBD66FA37CC2.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" loext:mime-type="image/jpeg"/>
247
+ # </draw:frame>
248
+ # </text:p>
249
+ # </table:table-cell>
250
+ # </table:table-row>
251
+ # XML
252
+ #
253
+ # doc = Ox.parse(xml)
254
+ #
255
+ # frame = doc.locate("*/draw:frame[@draw:name=IMAGE_IN_TABLE]")[0]
256
+ #
257
+ # img = frame.locate('*/draw:image')[0]
258
+ #
259
+ # img[:'xlink:href'] = "picture"
260
+ # frame[:'draw:name'] = "novo nome"
261
+ #
262
+ # puts Ox.dump(doc)
@@ -0,0 +1,56 @@
1
+ require './lib/odf-report'
2
+ require 'faker'
3
+
4
+
5
+ class Item
6
+ attr_accessor :name, :inner_text
7
+ def initialize(_name, _text)
8
+ @name=_name
9
+ @inner_text=_text
10
+ end
11
+ end
12
+
13
+
14
+
15
+ @items = []
16
+ 3.times do
17
+
18
+ text = <<-HTML
19
+ <p>#{Faker::Lorem.sentence} <em>#{Faker::Lorem.sentence}</em> #{Faker::Lorem.sentence}</p>
20
+ <p>#{Faker::Lorem.sentence} <strong>#{Faker::Lorem.paragraph(3)}</strong> NO FORMAT <strong>#{Faker::Lorem.paragraph(2)}</strong> #{Faker::Lorem.sentence}</p>
21
+ <p>#{Faker::Lorem.paragraph}</p>
22
+ <blockquote>
23
+ <p>#{Faker::Lorem.paragraph}</p>
24
+ <p>#{Faker::Lorem.paragraph}</p>
25
+ </blockquote>
26
+ <p style="margin: 150px">#{Faker::Lorem.paragraph}</p>
27
+ <p>#{Faker::Lorem.paragraph}</p>
28
+ HTML
29
+
30
+ @items << Item.new(Faker::Name.name, text)
31
+
32
+ end
33
+
34
+
35
+ item = @items.pop
36
+
37
+ report = ODFReport::Report.new("test/templates/test_text.odt") do |r|
38
+
39
+ r.add_field("TAG_01", Faker::Company.name)
40
+ r.add_field("TAG_02", Faker::Company.catch_phrase)
41
+
42
+ r.add_text(:main_text, item.inner_text)
43
+
44
+ r.add_section("SECTION_01", @items) do |s|
45
+ s.add_field(:name)
46
+ s.add_text(:inner_text) { |i| i.inner_text }
47
+ end
48
+
49
+ r.add_table("TABLE", @items) do |s|
50
+ s.add_field(:field, :name)
51
+ s.add_text(:text, :inner_text)
52
+ end
53
+
54
+ end
55
+
56
+ report.generate("test/result/test_text.odt")
metadata CHANGED
@@ -1,112 +1,197 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: odf-report
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Duarte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-30 00:00:00.000000000 Z
11
+ date: 2020-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.6'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: faker
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
32
60
  - !ruby/object:Gem::Version
33
61
  version: '0'
34
62
  type: :development
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
- - - ! '>='
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: launchy
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
39
81
  - !ruby/object:Gem::Version
40
82
  version: '0'
41
83
  - !ruby/object:Gem::Dependency
42
84
  name: rubyzip
43
85
  requirement: !ruby/object:Gem::Requirement
44
86
  requirements:
45
- - - ~>
87
+ - - ">="
46
88
  - !ruby/object:Gem::Version
47
- version: 1.1.0
89
+ version: 1.3.0
48
90
  type: :runtime
49
91
  prerelease: false
50
92
  version_requirements: !ruby/object:Gem::Requirement
51
93
  requirements:
52
- - - ~>
94
+ - - ">="
53
95
  - !ruby/object:Gem::Version
54
- version: 1.1.0
96
+ version: 1.3.0
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: nokogiri
57
99
  requirement: !ruby/object:Gem::Requirement
58
100
  requirements:
59
- - - ! '>='
101
+ - - ">="
60
102
  - !ruby/object:Gem::Version
61
- version: 1.5.0
103
+ version: 1.10.0
62
104
  type: :runtime
63
105
  prerelease: false
64
106
  version_requirements: !ruby/object:Gem::Requirement
65
107
  requirements:
66
- - - ! '>='
108
+ - - ">="
67
109
  - !ruby/object:Gem::Version
68
- version: 1.5.0
110
+ version: 1.10.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: mime-types
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
69
125
  description: Generates ODF files, given a template (.odt) and data, replacing tags
70
126
  email: sandrods@gmail.com
71
- executables: []
127
+ executables:
128
+ - odt-extract
129
+ - odt-viewer
72
130
  extensions: []
73
131
  extra_rdoc_files: []
74
132
  files:
75
- - .gitignore
133
+ - ".github/workflows/gem-push.yml"
134
+ - ".gitignore"
135
+ - ".rspec"
136
+ - CHANGELOG.md
76
137
  - Gemfile
77
138
  - MIT-LICENSE
78
139
  - Manifest
79
- - README.textile
140
+ - README.md
80
141
  - Rakefile
142
+ - bin/odt-extract
143
+ - bin/odt-viewer
81
144
  - lib/odf-report.rb
145
+ - lib/odf-report/data_source.rb
82
146
  - lib/odf-report/field.rb
83
- - lib/odf-report/fields.rb
84
- - lib/odf-report/file.rb
85
- - lib/odf-report/images.rb
86
- - lib/odf-report/nested.rb
147
+ - lib/odf-report/image.rb
148
+ - lib/odf-report/nestable.rb
87
149
  - lib/odf-report/parser/default.rb
88
150
  - lib/odf-report/report.rb
89
151
  - lib/odf-report/section.rb
90
152
  - lib/odf-report/table.rb
153
+ - lib/odf-report/template.rb
91
154
  - lib/odf-report/text.rb
92
155
  - lib/odf-report/version.rb
93
156
  - odf-report.gemspec
94
- - test/piriapolis.jpg
95
- - test/rails.png
157
+ - spec/fields_spec.rb
158
+ - spec/images/image_1.jpg
159
+ - spec/images/image_2.jpg
160
+ - spec/images/image_3.jpg
161
+ - spec/images/piriapolis.jpg
162
+ - spec/images/placeholder.jpg
163
+ - spec/images/rails.png
164
+ - spec/images_spec.rb
165
+ - spec/sections_spec.rb
166
+ - spec/spec_helper.rb
167
+ - spec/tables_spec.rb
168
+ - spec/template_spec.rb
169
+ - spec/templates/images.odt
170
+ - spec/templates/specs.odt
171
+ - test/fields_inside_text_test.rb
172
+ - test/images_test.rb
173
+ - test/nested_tables_test.rb
174
+ - test/sections_test.rb
175
+ - test/sub_sections_test.rb
176
+ - test/table_headers_test.rb
177
+ - test/tables_test.rb
178
+ - test/templates/images/image_1.jpg
179
+ - test/templates/images/image_2.jpg
180
+ - test/templates/images/image_3.jpg
181
+ - test/templates/images/placeholder.jpg
182
+ - test/templates/images/placeholder.png
183
+ - test/templates/piriapolis.jpg
184
+ - test/templates/rails.png
96
185
  - test/templates/test_fields_inside_text.odt
186
+ - test/templates/test_images.odt
97
187
  - test/templates/test_nested_tables.odt
98
188
  - test/templates/test_sections.odt
99
189
  - test/templates/test_sub_sections.odt
100
190
  - test/templates/test_table_headers.odt
101
191
  - test/templates/test_tables.odt
102
192
  - test/templates/test_text.odt
103
- - test/test_fields_inside_text.rb
104
- - test/test_nested_tables.rb
105
- - test/test_sections.rb
106
- - test/test_sub_sections.rb
107
- - test/test_table_headers.rb
108
- - test/test_tables.rb
109
- - test/test_text.rb
193
+ - test/test.rb
194
+ - test/text_test.rb
110
195
  homepage: http://sandrods.github.com/odf-report/
111
196
  licenses: []
112
197
  metadata: {}
@@ -116,35 +201,55 @@ require_paths:
116
201
  - lib
117
202
  required_ruby_version: !ruby/object:Gem::Requirement
118
203
  requirements:
119
- - - ! '>='
204
+ - - ">="
120
205
  - !ruby/object:Gem::Version
121
206
  version: '0'
122
207
  required_rubygems_version: !ruby/object:Gem::Requirement
123
208
  requirements:
124
- - - ! '>='
209
+ - - ">="
125
210
  - !ruby/object:Gem::Version
126
211
  version: '0'
127
212
  requirements: []
128
- rubyforge_project:
129
- rubygems_version: 2.2.2
213
+ rubygems_version: 3.0.3
130
214
  signing_key:
131
215
  specification_version: 4
132
216
  summary: Generates ODF files, given a template (.odt) and data, replacing tags
133
217
  test_files:
134
- - test/piriapolis.jpg
135
- - test/rails.png
218
+ - spec/fields_spec.rb
219
+ - spec/images/image_1.jpg
220
+ - spec/images/image_2.jpg
221
+ - spec/images/image_3.jpg
222
+ - spec/images/piriapolis.jpg
223
+ - spec/images/placeholder.jpg
224
+ - spec/images/rails.png
225
+ - spec/images_spec.rb
226
+ - spec/sections_spec.rb
227
+ - spec/spec_helper.rb
228
+ - spec/tables_spec.rb
229
+ - spec/template_spec.rb
230
+ - spec/templates/images.odt
231
+ - spec/templates/specs.odt
232
+ - test/fields_inside_text_test.rb
233
+ - test/images_test.rb
234
+ - test/nested_tables_test.rb
235
+ - test/sections_test.rb
236
+ - test/sub_sections_test.rb
237
+ - test/table_headers_test.rb
238
+ - test/tables_test.rb
239
+ - test/templates/images/image_1.jpg
240
+ - test/templates/images/image_2.jpg
241
+ - test/templates/images/image_3.jpg
242
+ - test/templates/images/placeholder.jpg
243
+ - test/templates/images/placeholder.png
244
+ - test/templates/piriapolis.jpg
245
+ - test/templates/rails.png
136
246
  - test/templates/test_fields_inside_text.odt
247
+ - test/templates/test_images.odt
137
248
  - test/templates/test_nested_tables.odt
138
249
  - test/templates/test_sections.odt
139
250
  - test/templates/test_sub_sections.odt
140
251
  - test/templates/test_table_headers.odt
141
252
  - test/templates/test_tables.odt
142
253
  - test/templates/test_text.odt
143
- - test/test_fields_inside_text.rb
144
- - test/test_nested_tables.rb
145
- - test/test_sections.rb
146
- - test/test_sub_sections.rb
147
- - test/test_table_headers.rb
148
- - test/test_tables.rb
149
- - test/test_text.rb
150
- has_rdoc: false
254
+ - test/test.rb
255
+ - test/text_test.rb