odf-report 0.7.3 → 0.8.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 +4 -4
- data/.github/workflows/gem-push.yml +7 -4
- data/CHANGELOG.md +7 -1
- data/README.md +2 -2
- data/lib/odf-report/parser/default.rb +3 -4
- data/lib/odf-report/version.rb +1 -1
- data/odf-report.gemspec +1 -1
- data/spec/templates/specs.odt +0 -0
- data/spec/texts_spec.rb +48 -0
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14183fe9ba54b5f98cd72cd48aa1277aa9d5b576c7980ae2bbfeef2346c9c49d
|
4
|
+
data.tar.gz: dcf77b2934897f3b490effdd62a1ee1effc2d13898523249b81b4be62be1eea9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7eb665c1fe1f414dac1b5e3ef3714b398d207125b00589573f2e2e9a2d4632355f26bf968fe3eec53c7bdcdff92c3fe24f5216fe18a1e160ddd4c8947804390a
|
7
|
+
data.tar.gz: 237f77a79aa11754aff00d0973c696dc9f62a8ce65b6b57c1c101293b632ee0399025f13b04f9649feaeda1d63310b58ac83ac67d5565cc602c9b2bcd5be127c
|
@@ -8,13 +8,16 @@ jobs:
|
|
8
8
|
build:
|
9
9
|
name: Build + Publish
|
10
10
|
runs-on: ubuntu-latest
|
11
|
+
permissions:
|
12
|
+
contents: read
|
13
|
+
packages: write
|
11
14
|
|
12
15
|
steps:
|
13
|
-
- uses: actions/checkout@
|
14
|
-
-
|
15
|
-
uses: actions/setup-ruby@v1
|
16
|
+
- uses: actions/checkout@v4
|
17
|
+
- uses: ruby/setup-ruby@v1
|
16
18
|
with:
|
17
|
-
version: 2
|
19
|
+
ruby-version: '3.2'
|
20
|
+
bundler-cache: true
|
18
21
|
|
19
22
|
# - name: Publish to GPR
|
20
23
|
# run: |
|
data/CHANGELOG.md
CHANGED
@@ -18,10 +18,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
18
18
|
|
19
19
|
- None
|
20
20
|
|
21
|
+
## 0.8.0
|
22
|
+
|
23
|
+
### Dependencies
|
24
|
+
|
25
|
+
- nokogiri >= 1.12.0 (was >= 1.10.0)
|
26
|
+
|
21
27
|
## 0.7.3
|
22
28
|
|
23
29
|
### Fixed
|
24
|
-
- newer versions (> 1.
|
30
|
+
- newer versions (> 1.13.0) of Nokogiri where presenting "Nokogiri::CSS::SyntaxError: unexpected '|'" #120
|
25
31
|
- prevent unnecessary memory expensive operations with missing placeholders #117
|
26
32
|
|
27
33
|
## 0.7.2
|
data/README.md
CHANGED
@@ -56,7 +56,7 @@ report = ODFReport::Report.new("Users/john/my_template.odt") do |r|
|
|
56
56
|
r.add_field "USER_NAME", @user.nome
|
57
57
|
r.add_field "ADDRESS", @user.address
|
58
58
|
|
59
|
-
r.add_table("TABLE_1", @
|
59
|
+
r.add_table("TABLE_1", @list_of_items, :header=>true) do |t|
|
60
60
|
t.add_column(:item_id, :id)
|
61
61
|
t.add_column(:description) { |item| "==> #{item.description}" }
|
62
62
|
end
|
@@ -71,7 +71,7 @@ and considering you have a table like this in your template
|
|
71
71
|
| [ITEM_ID] | [DESCRIPTION] |
|
72
72
|
|
73
73
|
|
74
|
-
and a collection `@
|
74
|
+
and a collection `@list_of_items`, it will create one row for each item in the collection, and the replacement will take place accordingly.
|
75
75
|
|
76
76
|
Any format applied to the fields in the template will be preserved.
|
77
77
|
|
@@ -34,11 +34,9 @@ module Parser
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def parse
|
37
|
+
html = Nokogiri::HTML5.fragment(@text)
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
xml.css("p", "h1", "h2").each do |p|
|
41
|
-
|
39
|
+
html.css("p", "h1", "h2").each do |p|
|
42
40
|
style = check_style(p)
|
43
41
|
text = parse_formatting(p.inner_html)
|
44
42
|
|
@@ -63,6 +61,7 @@ module Parser
|
|
63
61
|
text.gsub!(/<strong.*?>(.+?)<\/strong>/) { "<text:span text:style-name=\"bold\">#{$1}<\/text:span>" }
|
64
62
|
text.gsub!(/<em.*?>(.+?)<\/em>/) { "<text:span text:style-name=\"italic\">#{$1}<\/text:span>" }
|
65
63
|
text.gsub!(/<u.*?>(.+?)<\/u>/) { "<text:span text:style-name=\"underline\">#{$1}<\/text:span>" }
|
64
|
+
text.gsub!("<br\/?>", "<text:line-break/>")
|
66
65
|
text.gsub!("\n", "")
|
67
66
|
text
|
68
67
|
end
|
data/lib/odf-report/version.rb
CHANGED
data/odf-report.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_development_dependency "launchy"
|
26
26
|
|
27
27
|
s.add_runtime_dependency('rubyzip', ">= 1.3.0")
|
28
|
-
s.add_runtime_dependency('nokogiri', ">= 1.
|
28
|
+
s.add_runtime_dependency('nokogiri', ">= 1.12.0")
|
29
29
|
s.add_runtime_dependency('mime-types')
|
30
30
|
|
31
31
|
end
|
data/spec/templates/specs.odt
CHANGED
Binary file
|
data/spec/texts_spec.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
RSpec.describe "Texts" do
|
2
|
+
before(:context) do
|
3
|
+
|
4
|
+
@text1 = <<-HTML
|
5
|
+
<p>This is some text in a paragraph</p>
|
6
|
+
HTML
|
7
|
+
|
8
|
+
@text2 = <<-HTML
|
9
|
+
<p>Text before line break <br> text after line break</p>
|
10
|
+
HTML
|
11
|
+
|
12
|
+
@text3 = <<-HTML
|
13
|
+
<p>Text before entities
|
14
|
+
Maurício
|
15
|
+
Text after entities</p>
|
16
|
+
HTML
|
17
|
+
|
18
|
+
|
19
|
+
report = ODFReport::Report.new("spec/templates/specs.odt") do |r|
|
20
|
+
|
21
|
+
r.add_text(:text1, @text1)
|
22
|
+
r.add_text(:text2, @text2)
|
23
|
+
r.add_text(:text3, @text3)
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
report.generate("spec/result/specs.odt")
|
28
|
+
|
29
|
+
@data = Inspector.new("spec/result/specs.odt")
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
it "simple text replacement" do
|
34
|
+
expect(@data.text).to include "This is some text in a paragraph"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "text replacement with <br>" do
|
38
|
+
expect(@data.text).to include "Text before line break"
|
39
|
+
expect(@data.text).to include "text after line break"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "text replacement with html entities" do
|
43
|
+
expect(@data.text).to include "Text before entities"
|
44
|
+
expect(@data.text).to include "Maurício"
|
45
|
+
expect(@data.text).to include "Text after entities"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: odf-report
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sandro Duarte
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
103
|
+
version: 1.12.0
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.
|
110
|
+
version: 1.12.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: mime-types
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,6 +169,7 @@ files:
|
|
169
169
|
- spec/template_spec.rb
|
170
170
|
- spec/templates/images.odt
|
171
171
|
- spec/templates/specs.odt
|
172
|
+
- spec/texts_spec.rb
|
172
173
|
- test/fields_inside_text_test.rb
|
173
174
|
- test/images_test.rb
|
174
175
|
- test/nested_tables_test.rb
|
@@ -211,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
212
|
- !ruby/object:Gem::Version
|
212
213
|
version: '0'
|
213
214
|
requirements: []
|
214
|
-
rubygems_version: 3.
|
215
|
+
rubygems_version: 3.4.19
|
215
216
|
signing_key:
|
216
217
|
specification_version: 4
|
217
218
|
summary: Generates ODF files, given a template (.odt) and data, replacing tags
|
@@ -230,6 +231,7 @@ test_files:
|
|
230
231
|
- spec/template_spec.rb
|
231
232
|
- spec/templates/images.odt
|
232
233
|
- spec/templates/specs.odt
|
234
|
+
- spec/texts_spec.rb
|
233
235
|
- test/fields_inside_text_test.rb
|
234
236
|
- test/images_test.rb
|
235
237
|
- test/nested_tables_test.rb
|