odf-report 0.5.1 → 0.7.1

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.
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
@@ -1,39 +0,0 @@
1
- require '../lib/odf-report'
2
- require 'ostruct'
3
-
4
- class Item
5
- attr_accessor :name, :sid, :children
6
- def initialize(_name, _sid, _children=[])
7
- @name=_name
8
- @sid=_sid
9
- @children=_children
10
- end
11
- end
12
-
13
- items = []
14
- items << Item.new("LOST", '007', %w(sawyer juliet hurley locke jack freckles))
15
- items << Item.new("ALIAS", '302', %w(sidney sloane jack michael marshal))
16
- items << Item.new("GREY'S ANATOMY", '220', %w(meredith christina izzie alex george))
17
- items << Item.new("BREAKING BAD", '556', %w(pollos gus mike heisenberg))
18
-
19
- report = ODFReport::Report.new("./templates/test_sections.odt") do |r|
20
-
21
- r.add_field("TAG_01", Time.now)
22
- r.add_field("TAG_02", "TAG-2 -> New tag")
23
-
24
- r.add_section("SECTION_01", items) do |s|
25
-
26
- s.add_field('NAME') { |i| i.name }
27
-
28
- s.add_field('SID', :sid)
29
-
30
- s.add_table('TABLE_S1', :children, :header=>true) do |t|
31
- t.add_column('NAME1') { |item| "-> #{item}" }
32
- t.add_column('INV') { |item| item.to_s.reverse.upcase }
33
- end
34
-
35
- end
36
-
37
- end
38
-
39
- report.generate("./result/test_sections.odt")
@@ -1,57 +0,0 @@
1
- require '../lib/odf-report'
2
- require 'ostruct'
3
-
4
- class Item
5
- attr_accessor :name, :sid, :children, :subs
6
- def initialize(_name, _sid, _children=[], _subs=[])
7
- @name=_name
8
- @sid=_sid
9
- @children=_children
10
- @subs=_subs
11
- end
12
- end
13
-
14
- subs1 = []
15
- subs1 << Item.new("SAWYER", 1, %w(Your bones don't break))
16
- subs1 << Item.new("HURLEY", 2, %w(Your cells react to bacteria and viruses))
17
- subs1 << Item.new("LOCKE", 3, %W(Do you see any Teletubbies in here))
18
-
19
- subs2 = []
20
- subs2 << Item.new("SLOANE", 21, %w(Praesent hendrerit lectus sit amet))
21
- subs2 << Item.new("JACK", 22, %w(Donec nec est eget dolor laoreet))
22
- subs2 << Item.new("MICHAEL", 23, %W(Integer elementum massa at nulla placerat varius))
23
-
24
- items = []
25
- items << Item.new("LOST", '007', %w(sawyer juliet hurley locke jack freckles), subs1)
26
- items << Item.new("ALIAS", '302', %w(sidney sloane jack michael marshal))
27
- items << Item.new("GREY'S ANATOMY", '220', %w(meredith christina izzie alex george), subs2)
28
- items << Item.new("BREAKING BAD", '556', %w(pollos gus mike heisenberg))
29
-
30
- report = ODFReport::Report.new("./templates/test_sub_sections.odt") do |r|
31
-
32
- r.add_field("TAG_01", Time.now)
33
- r.add_field("TAG_02", "TAG-2 -> New tag")
34
-
35
- r.add_section("SECTION_01", items) do |s|
36
-
37
- s.add_field('NAME') { |i| i.name }
38
-
39
- s.add_field('SID', :sid)
40
-
41
- s.add_table('TABLE_S1', :children, :header=>true) do |t|
42
- t.add_column('NAME1') { |item| "-> #{item}" }
43
- t.add_column('INV') { |item| item.to_s.reverse.upcase }
44
- end
45
-
46
- s.add_section('SUB_01', :subs) do |r|
47
- r.add_field("FIRST_NAME", :name)
48
- r.add_table('IPSUM_TABLE', :children, :header => true) do |t|
49
- t.add_column('IPSUM_ITEM') { |i| i }
50
- end
51
- end
52
-
53
- end
54
-
55
- end
56
-
57
- report.generate("./result/test_sub_sections.odt")
@@ -1,39 +0,0 @@
1
- require '../lib/odf-report'
2
- require 'ostruct'
3
- require 'faker'
4
-
5
- class Item
6
- attr_accessor :name, :mail
7
- def initialize(_name, _mail)
8
- @name=_name
9
- @mail=_mail
10
- end
11
- end
12
-
13
- items = []
14
- 50.times do
15
-
16
- items << Item.new(Faker::Name.name, Faker::Internet.email)
17
-
18
- end
19
-
20
- report = ODFReport::Report.new("./templates/test_table_headers.odt") do |r|
21
-
22
- r.add_table("TABLE_01", items, :header => true) do |s|
23
- s.add_column(:name)
24
- s.add_column(:mail)
25
- end
26
-
27
- r.add_table("TABLE_02", items, :header => true) do |s|
28
- s.add_column(:name)
29
- s.add_column(:mail)
30
- end
31
-
32
- r.add_table("TABLE_03", items) do |s|
33
- s.add_column(:name)
34
- s.add_column(:mail)
35
- end
36
-
37
- end
38
-
39
- report.generate("./result/test_table_headers.odt")
@@ -1,62 +0,0 @@
1
- require '../lib/odf-report'
2
- require 'ostruct'
3
-
4
- col1 = []
5
- (1..40).each do |i|
6
- col1 << {:name=>"name #{i}", :idx=>i, :address=>"this is address #{i}"}
7
- end
8
-
9
-
10
- col2 = []
11
- col2 << OpenStruct.new({:name=>"josh harnet", :idx=>"02", :address=>"testing <&> ", :phone=>99025668, :zip=>"90420-002"})
12
- col2 << OpenStruct.new({:name=>"sandro duarte", :idx=>"45", :address=>"address with &", :phone=>88774451, :zip=>"90490-002"})
13
- col2 << OpenStruct.new({:name=>"ellen bicca", :idx=>"77", :address=>"<address with escaped html>", :phone=>77025668, :zip=>"94420-002"})
14
- col2 << OpenStruct.new({:name=>"luiz garcia", 'idx'=>"88", :address=>"address with\nlinebreak", :phone=>27025668, :zip=>"94520-025"})
15
-
16
- col3, col4, col5 = [], [], []
17
-
18
- report = ODFReport::Report.new("./templates/test_tables.odt") do |r|
19
-
20
- r.add_field("HEADER_FIELD", "This field was in the HEADER")
21
-
22
- r.add_field("TAG_01", "New tag")
23
- r.add_field("TAG_02", "TAG-2 -> New tag")
24
-
25
- r.add_table("TABLE_01", col1, :header=>true) do |t|
26
- t.add_column(:field_01, :idx)
27
- t.add_column(:field_02, :name)
28
- t.add_column(:address)
29
- end
30
-
31
- r.add_table("TABLE_02", col2) do |t|
32
- t.add_column(:field_04, :idx)
33
- t.add_column(:field_05, :name)
34
- t.add_column(:field_06, 'address')
35
- t.add_column(:field_07, :phone)
36
- t.add_column(:field_08, :zip)
37
- end
38
-
39
- r.add_table("TABLE_03", col3, :header=>true) do |t|
40
- t.add_column(:field_01, :idx)
41
- t.add_column(:field_02, :name)
42
- t.add_column(:field_03, :address)
43
- end
44
-
45
- r.add_table("TABLE_04", col4, :header=>true, :skip_if_empty => true) do |t|
46
- t.add_column(:field_01, :idx)
47
- t.add_column(:field_02, :name)
48
- t.add_column(:field_03, :address)
49
- end
50
-
51
- r.add_table("TABLE_05", col5) do |t|
52
- t.add_column(:field_01, :idx)
53
- t.add_column(:field_02, :name)
54
- t.add_column(:field_03, :address)
55
- end
56
-
57
- r.add_image("graphics1", File.join(Dir.pwd, 'piriapolis.jpg'))
58
- r.add_image("graphics2", File.join(Dir.pwd, 'rails.png'))
59
-
60
- end
61
-
62
- report.generate("./result/test_tables.odt")
@@ -1,48 +0,0 @@
1
- require '../lib/odf-report'
2
- require 'ostruct'
3
- require 'faker'
4
-
5
- class Item
6
- attr_accessor :name, :text
7
- def initialize(_name, _text)
8
- @name=_name
9
- @text=_text
10
- end
11
- end
12
-
13
- items = []
14
- 4.times do
15
-
16
- text = <<-HTML
17
- <p>#{Faker::Lorem.sentence} <em>#{Faker::Lorem.sentence}</em> #{Faker::Lorem.sentence}</p>
18
- <p>#{Faker::Lorem.sentence} <strong>#{Faker::Lorem.paragraph}</strong> #{Faker::Lorem.paragraph}</p>
19
- <p>#{Faker::Lorem.paragraph}</p>
20
- <blockquote>
21
- <p>#{Faker::Lorem.paragraph(10)}</p>
22
- <p>#{Faker::Lorem.paragraph}</p>
23
- </blockquote>
24
- <p style="margin: 150px">#{Faker::Lorem.paragraph(15)}</p>
25
- <p>#{Faker::Lorem.paragraph}</p>
26
- HTML
27
-
28
- items << Item.new(Faker::Name.name, text)
29
-
30
- end
31
-
32
- item = items.pop
33
-
34
- report = ODFReport::Report.new("./templates/test_text.odt") do |r|
35
-
36
- r.add_field("TAG_01", Faker::Company.name)
37
- r.add_field("TAG_02", Faker::Company.catch_phrase)
38
-
39
- r.add_text(:main_text, item.text)
40
-
41
- r.add_section("SECTION_01", items) do |s|
42
- s.add_field(:name)
43
- s.add_text(:text)
44
- end
45
-
46
- end
47
-
48
- report.generate("./result/test_text.odt")