odf-report 0.6.1 → 0.7.0
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/.gitignore +1 -0
- data/README.md +27 -19
- data/bin/odt-extract +10 -0
- data/bin/odt-viewer +18 -0
- data/lib/odf-report.rb +11 -8
- data/lib/odf-report/data_source.rb +64 -0
- data/lib/odf-report/field.rb +7 -40
- data/lib/odf-report/image.rb +52 -0
- data/lib/odf-report/nestable.rb +65 -0
- data/lib/odf-report/nested.rb +13 -8
- data/lib/odf-report/report.rb +21 -13
- data/lib/odf-report/section.rb +15 -42
- data/lib/odf-report/table.rb +54 -59
- data/lib/odf-report/template.rb +23 -3
- data/lib/odf-report/text.rb +1 -3
- data/lib/odf-report/version.rb +1 -1
- data/odf-report.gemspec +2 -1
- data/spec/fields_spec.rb +2 -2
- data/spec/images/image_1.jpg +0 -0
- data/spec/images/image_2.jpg +0 -0
- data/spec/images/image_3.jpg +0 -0
- data/spec/images/piriapolis.jpg +0 -0
- data/spec/images/placeholder.jpg +0 -0
- data/spec/images/rails.png +0 -0
- data/spec/images_spec.rb +80 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/tables_spec.rb +1 -1
- data/spec/template_spec.rb +2 -2
- data/spec/templates/images.odt +0 -0
- data/spec/{specs.odt → templates/specs.odt} +0 -0
- data/test/images_test.rb +32 -0
- data/test/templates/images/image_1.jpg +0 -0
- data/test/templates/images/image_2.jpg +0 -0
- data/test/templates/images/image_3.jpg +0 -0
- data/test/templates/images/placeholder.jpg +0 -0
- data/test/templates/images/placeholder.png +0 -0
- data/test/templates/test_images.odt +0 -0
- data/test/test.rb +262 -0
- metadata +61 -12
- data/lib/odf-report/images.rb +0 -44
data/lib/odf-report/images.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
module ODFReport
|
2
|
-
|
3
|
-
module Images
|
4
|
-
|
5
|
-
IMAGE_DIR_NAME = "Pictures"
|
6
|
-
|
7
|
-
def find_image_name_matches(content)
|
8
|
-
|
9
|
-
@images.each_pair do |image_name, path|
|
10
|
-
if node = content.xpath("//draw:frame[@draw:name='#{image_name}']/draw:image").first
|
11
|
-
placeholder_path = node.attribute('href').value
|
12
|
-
@image_names_replacements[path] = ::File.join(IMAGE_DIR_NAME, ::File.basename(placeholder_path))
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
def include_image_files(file)
|
19
|
-
|
20
|
-
return if @images.empty?
|
21
|
-
|
22
|
-
@image_names_replacements.each_pair do |path, template_image|
|
23
|
-
|
24
|
-
file.output_stream.put_next_entry(template_image)
|
25
|
-
file.output_stream.write ::File.read(path)
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end # replace_images
|
30
|
-
|
31
|
-
# newer versions of LibreOffice can't open files with duplicates image names
|
32
|
-
def avoid_duplicate_image_names(content)
|
33
|
-
|
34
|
-
nodes = content.xpath("//draw:frame[@draw:name]")
|
35
|
-
|
36
|
-
nodes.each_with_index do |node, i|
|
37
|
-
node.attribute('name').value = "pic_#{i}"
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|