cure-odf-report 0.5.1b

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/.rspec +4 -0
  4. data/Gemfile +4 -0
  5. data/MIT-LICENSE +20 -0
  6. data/Manifest +12 -0
  7. data/README.textile +223 -0
  8. data/Rakefile +9 -0
  9. data/lib/odf-report.rb +16 -0
  10. data/lib/odf-report/actions/remove_section.rb +22 -0
  11. data/lib/odf-report/field.rb +88 -0
  12. data/lib/odf-report/file.rb +50 -0
  13. data/lib/odf-report/images.rb +44 -0
  14. data/lib/odf-report/nested.rb +62 -0
  15. data/lib/odf-report/parser/default.rb +91 -0
  16. data/lib/odf-report/report.rb +103 -0
  17. data/lib/odf-report/section.rb +64 -0
  18. data/lib/odf-report/table.rb +88 -0
  19. data/lib/odf-report/text.rb +43 -0
  20. data/lib/odf-report/version.rb +3 -0
  21. data/odf-report.gemspec +31 -0
  22. data/spec/fields_spec.rb +77 -0
  23. data/spec/result/specs.odt +0 -0
  24. data/spec/result/tables.rb +38 -0
  25. data/spec/spec_helper.rb +45 -0
  26. data/spec/specs.odt +0 -0
  27. data/spec/tables_spec.rb +39 -0
  28. data/test/fields_inside_text_test.rb +38 -0
  29. data/test/nested_tables_test.rb +43 -0
  30. data/test/sections_test.rb +44 -0
  31. data/test/sub_sections_test.rb +58 -0
  32. data/test/table_headers_test.rb +41 -0
  33. data/test/tables_test.rb +67 -0
  34. data/test/templates/piriapolis.jpg +0 -0
  35. data/test/templates/rails.png +0 -0
  36. data/test/templates/test_fields_inside_text.odt +0 -0
  37. data/test/templates/test_nested_tables.odt +0 -0
  38. data/test/templates/test_sections.odt +0 -0
  39. data/test/templates/test_sub_sections.odt +0 -0
  40. data/test/templates/test_table_headers.odt +0 -0
  41. data/test/templates/test_tables.odt +0 -0
  42. data/test/templates/test_text.odt +0 -0
  43. data/test/text_test.rb +56 -0
  44. metadata +204 -0
@@ -0,0 +1,41 @@
1
+ require './lib/odf-report'
2
+ require 'ostruct'
3
+ require 'faker'
4
+ require 'launchy'
5
+
6
+
7
+ class Item
8
+ attr_accessor :name, :mail
9
+ def initialize(_name, _mail)
10
+ @name=_name
11
+ @mail=_mail
12
+ end
13
+ end
14
+
15
+
16
+
17
+ @items = []
18
+ 50.times { @items << Item.new(Faker::Name.name, Faker::Internet.email) }
19
+
20
+
21
+
22
+ report = ODFReport::Report.new("test/templates/test_table_headers.odt") do |r|
23
+
24
+ r.add_table("TABLE_01", @items, :header => true) do |s|
25
+ s.add_column(:name)
26
+ s.add_column(:mail)
27
+ end
28
+
29
+ r.add_table("TABLE_02", @items, :header => true) do |s|
30
+ s.add_column(:name)
31
+ s.add_column(:mail)
32
+ end
33
+
34
+ r.add_table("TABLE_03", @items) do |s|
35
+ s.add_column(:name)
36
+ s.add_column(:mail)
37
+ end
38
+
39
+ end
40
+
41
+ report.generate("test/result/test_table_headers.odt")
@@ -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
@@ -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> #{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 ADDED
@@ -0,0 +1,204 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cure-odf-report
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.1b
5
+ platform: ruby
6
+ authors:
7
+ - Sandro Duarte
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
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
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
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
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubyzip
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.1.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: nokogiri
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 1.5.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 1.5.0
111
+ description: Generates ODF files, given a template (.odt) and data, replacing tags
112
+ email: sandrods@gmail.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - ".gitignore"
118
+ - ".rspec"
119
+ - Gemfile
120
+ - MIT-LICENSE
121
+ - Manifest
122
+ - README.textile
123
+ - Rakefile
124
+ - lib/odf-report.rb
125
+ - lib/odf-report/actions/remove_section.rb
126
+ - lib/odf-report/field.rb
127
+ - lib/odf-report/file.rb
128
+ - lib/odf-report/images.rb
129
+ - lib/odf-report/nested.rb
130
+ - lib/odf-report/parser/default.rb
131
+ - lib/odf-report/report.rb
132
+ - lib/odf-report/section.rb
133
+ - lib/odf-report/table.rb
134
+ - lib/odf-report/text.rb
135
+ - lib/odf-report/version.rb
136
+ - odf-report.gemspec
137
+ - spec/fields_spec.rb
138
+ - spec/result/specs.odt
139
+ - spec/result/tables.rb
140
+ - spec/spec_helper.rb
141
+ - spec/specs.odt
142
+ - spec/tables_spec.rb
143
+ - test/fields_inside_text_test.rb
144
+ - test/nested_tables_test.rb
145
+ - test/sections_test.rb
146
+ - test/sub_sections_test.rb
147
+ - test/table_headers_test.rb
148
+ - test/tables_test.rb
149
+ - test/templates/piriapolis.jpg
150
+ - test/templates/rails.png
151
+ - test/templates/test_fields_inside_text.odt
152
+ - test/templates/test_nested_tables.odt
153
+ - test/templates/test_sections.odt
154
+ - test/templates/test_sub_sections.odt
155
+ - test/templates/test_table_headers.odt
156
+ - test/templates/test_tables.odt
157
+ - test/templates/test_text.odt
158
+ - test/text_test.rb
159
+ homepage: http://sandrods.github.com/odf-report/
160
+ licenses: []
161
+ metadata: {}
162
+ post_install_message:
163
+ rdoc_options: []
164
+ require_paths:
165
+ - lib
166
+ required_ruby_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">"
174
+ - !ruby/object:Gem::Version
175
+ version: 1.3.1
176
+ requirements: []
177
+ rubyforge_project:
178
+ rubygems_version: 2.4.8
179
+ signing_key:
180
+ specification_version: 4
181
+ summary: Generates ODF files, given a template (.odt) and data, replacing tags
182
+ test_files:
183
+ - spec/fields_spec.rb
184
+ - spec/result/specs.odt
185
+ - spec/result/tables.rb
186
+ - spec/spec_helper.rb
187
+ - spec/specs.odt
188
+ - spec/tables_spec.rb
189
+ - test/fields_inside_text_test.rb
190
+ - test/nested_tables_test.rb
191
+ - test/sections_test.rb
192
+ - test/sub_sections_test.rb
193
+ - test/table_headers_test.rb
194
+ - test/tables_test.rb
195
+ - test/templates/piriapolis.jpg
196
+ - test/templates/rails.png
197
+ - test/templates/test_fields_inside_text.odt
198
+ - test/templates/test_nested_tables.odt
199
+ - test/templates/test_sections.odt
200
+ - test/templates/test_sub_sections.odt
201
+ - test/templates/test_table_headers.odt
202
+ - test/templates/test_tables.odt
203
+ - test/templates/test_text.odt
204
+ - test/text_test.rb