thinreports 0.12.1 → 0.13.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/dependabot.yml +3 -3
- data/.github/workflows/test.yml +28 -36
- data/.gitignore +1 -1
- data/CHANGELOG.md +19 -1
- data/Gemfile +11 -0
- data/README.md +12 -17
- data/Rakefile +17 -11
- data/lib/thinreports/basic_report/core/errors.rb +62 -0
- data/lib/thinreports/basic_report/core/format/base.rb +91 -0
- data/lib/thinreports/basic_report/core/shape/base/interface.rb +42 -0
- data/lib/thinreports/basic_report/core/shape/base/internal.rb +53 -0
- data/lib/thinreports/basic_report/core/shape/basic/block_format.rb +15 -0
- data/lib/thinreports/basic_report/core/shape/basic/block_interface.rb +34 -0
- data/lib/thinreports/basic_report/core/shape/basic/block_internal.rb +36 -0
- data/lib/thinreports/basic_report/core/shape/basic/format.rb +24 -0
- data/lib/thinreports/basic_report/core/shape/basic/interface.rb +87 -0
- data/lib/thinreports/basic_report/core/shape/basic/internal.rb +28 -0
- data/lib/thinreports/{core → basic_report/core}/shape/basic.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/image_block/format.rb +14 -0
- data/lib/thinreports/basic_report/core/shape/image_block/interface.rb +25 -0
- data/lib/thinreports/basic_report/core/shape/image_block/internal.rb +19 -0
- data/lib/thinreports/{core → basic_report/core}/shape/image_block.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/list/format.rb +92 -0
- data/lib/thinreports/basic_report/core/shape/list/manager.rb +231 -0
- data/lib/thinreports/basic_report/core/shape/list/page.rb +112 -0
- data/lib/thinreports/basic_report/core/shape/list/page_state.rb +50 -0
- data/lib/thinreports/basic_report/core/shape/list/section_format.rb +37 -0
- data/lib/thinreports/basic_report/core/shape/list/section_interface.rb +51 -0
- data/lib/thinreports/basic_report/core/shape/list/section_internal.rb +33 -0
- data/lib/thinreports/{core → basic_report/core}/shape/list.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/manager/format.rb +33 -0
- data/lib/thinreports/basic_report/core/shape/manager/internal.rb +109 -0
- data/lib/thinreports/basic_report/core/shape/manager/target.rb +114 -0
- data/lib/thinreports/basic_report/core/shape/page_number/format.rb +32 -0
- data/lib/thinreports/basic_report/core/shape/page_number/interface.rb +31 -0
- data/lib/thinreports/basic_report/core/shape/page_number/internal.rb +57 -0
- data/lib/thinreports/{core → basic_report/core}/shape/page_number.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/stack_view/format.rb +29 -0
- data/lib/thinreports/basic_report/core/shape/stack_view/interface.rb +19 -0
- data/lib/thinreports/basic_report/core/shape/stack_view/internal.rb +24 -0
- data/lib/thinreports/basic_report/core/shape/stack_view/row_format.rb +41 -0
- data/lib/thinreports/{core → basic_report/core}/shape/stack_view.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/style/base.rb +149 -0
- data/lib/thinreports/basic_report/core/shape/style/basic.rb +24 -0
- data/lib/thinreports/basic_report/core/shape/style/graphic.rb +43 -0
- data/lib/thinreports/basic_report/core/shape/style/text.rb +122 -0
- data/lib/thinreports/basic_report/core/shape/text/format.rb +17 -0
- data/lib/thinreports/basic_report/core/shape/text/interface.rb +20 -0
- data/lib/thinreports/basic_report/core/shape/text/internal.rb +24 -0
- data/lib/thinreports/{core → basic_report/core}/shape/text.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/text_block/format.rb +43 -0
- data/lib/thinreports/basic_report/core/shape/text_block/formatter/basic.rb +41 -0
- data/lib/thinreports/basic_report/core/shape/text_block/formatter/datetime.rb +25 -0
- data/lib/thinreports/basic_report/core/shape/text_block/formatter/number.rb +69 -0
- data/lib/thinreports/basic_report/core/shape/text_block/formatter/padding.rb +27 -0
- data/lib/thinreports/basic_report/core/shape/text_block/formatter.rb +38 -0
- data/lib/thinreports/basic_report/core/shape/text_block/interface.rb +37 -0
- data/lib/thinreports/basic_report/core/shape/text_block/internal.rb +75 -0
- data/lib/thinreports/{core → basic_report/core}/shape/text_block.rb +6 -4
- data/lib/thinreports/basic_report/core/shape.rb +44 -0
- data/lib/thinreports/basic_report/core/utils.rb +47 -0
- data/lib/thinreports/basic_report/generator/pdf/document/draw_shape.rb +108 -0
- data/lib/thinreports/basic_report/generator/pdf/document/draw_template_items.rb +71 -0
- data/lib/thinreports/basic_report/generator/pdf/document/font.rb +90 -0
- data/lib/thinreports/basic_report/generator/pdf/document/graphics/attributes.rb +149 -0
- data/lib/thinreports/basic_report/generator/pdf/document/graphics/basic.rb +137 -0
- data/lib/thinreports/basic_report/generator/pdf/document/graphics/image.rb +99 -0
- data/lib/thinreports/basic_report/generator/pdf/document/graphics/text.rb +180 -0
- data/lib/thinreports/basic_report/generator/pdf/document/graphics.rb +42 -0
- data/lib/thinreports/basic_report/generator/pdf/document/page.rb +96 -0
- data/lib/thinreports/basic_report/generator/pdf/document/parse_color.rb +51 -0
- data/lib/thinreports/basic_report/generator/pdf/document.rb +132 -0
- data/lib/thinreports/basic_report/generator/pdf/drawer/base.rb +50 -0
- data/lib/thinreports/basic_report/generator/pdf/drawer/list.rb +65 -0
- data/lib/thinreports/basic_report/generator/pdf/drawer/list_section.rb +51 -0
- data/lib/thinreports/basic_report/generator/pdf/drawer/page.rb +127 -0
- data/lib/thinreports/basic_report/generator/pdf/prawn_ext/calc_image_dimensions.rb +34 -0
- data/lib/thinreports/basic_report/generator/pdf/prawn_ext/width_of.rb +31 -0
- data/lib/thinreports/basic_report/generator/pdf.rb +66 -0
- data/lib/thinreports/basic_report/layout/base.rb +48 -0
- data/lib/thinreports/basic_report/layout/format.rb +67 -0
- data/lib/thinreports/basic_report/layout/legacy_schema.rb +383 -0
- data/lib/thinreports/basic_report/layout/version.rb +41 -0
- data/lib/thinreports/{layout.rb → basic_report/layout.rb} +6 -4
- data/lib/thinreports/basic_report/report/base.rb +173 -0
- data/lib/thinreports/basic_report/report/internal.rb +107 -0
- data/lib/thinreports/basic_report/report/page.rb +97 -0
- data/lib/thinreports/basic_report/report.rb +26 -0
- data/lib/thinreports/basic_report.rb +15 -0
- data/lib/thinreports/config.rb +1 -1
- data/lib/thinreports/section_report.rb +12 -0
- data/lib/thinreports/version.rb +1 -1
- data/lib/thinreports.rb +2 -13
- data/thinreports.gemspec +3 -7
- metadata +97 -154
- data/gemfiles/prawn-2.2.gemfile +0 -5
- data/gemfiles/prawn-2.3.gemfile +0 -5
- data/gemfiles/prawn-2.4.gemfile +0 -5
- data/lib/thinreports/core/errors.rb +0 -60
- data/lib/thinreports/core/format/base.rb +0 -89
- data/lib/thinreports/core/shape/base/interface.rb +0 -40
- data/lib/thinreports/core/shape/base/internal.rb +0 -51
- data/lib/thinreports/core/shape/basic/block_format.rb +0 -13
- data/lib/thinreports/core/shape/basic/block_interface.rb +0 -32
- data/lib/thinreports/core/shape/basic/block_internal.rb +0 -34
- data/lib/thinreports/core/shape/basic/format.rb +0 -22
- data/lib/thinreports/core/shape/basic/interface.rb +0 -85
- data/lib/thinreports/core/shape/basic/internal.rb +0 -26
- data/lib/thinreports/core/shape/image_block/format.rb +0 -12
- data/lib/thinreports/core/shape/image_block/interface.rb +0 -23
- data/lib/thinreports/core/shape/image_block/internal.rb +0 -17
- data/lib/thinreports/core/shape/list/format.rb +0 -90
- data/lib/thinreports/core/shape/list/manager.rb +0 -229
- data/lib/thinreports/core/shape/list/page.rb +0 -110
- data/lib/thinreports/core/shape/list/page_state.rb +0 -48
- data/lib/thinreports/core/shape/list/section_format.rb +0 -35
- data/lib/thinreports/core/shape/list/section_interface.rb +0 -49
- data/lib/thinreports/core/shape/list/section_internal.rb +0 -31
- data/lib/thinreports/core/shape/manager/format.rb +0 -31
- data/lib/thinreports/core/shape/manager/internal.rb +0 -107
- data/lib/thinreports/core/shape/manager/target.rb +0 -112
- data/lib/thinreports/core/shape/page_number/format.rb +0 -30
- data/lib/thinreports/core/shape/page_number/interface.rb +0 -29
- data/lib/thinreports/core/shape/page_number/internal.rb +0 -55
- data/lib/thinreports/core/shape/stack_view/format.rb +0 -27
- data/lib/thinreports/core/shape/stack_view/interface.rb +0 -17
- data/lib/thinreports/core/shape/stack_view/internal.rb +0 -22
- data/lib/thinreports/core/shape/stack_view/row_format.rb +0 -39
- data/lib/thinreports/core/shape/style/base.rb +0 -146
- data/lib/thinreports/core/shape/style/basic.rb +0 -22
- data/lib/thinreports/core/shape/style/graphic.rb +0 -41
- data/lib/thinreports/core/shape/style/text.rb +0 -120
- data/lib/thinreports/core/shape/text/format.rb +0 -15
- data/lib/thinreports/core/shape/text/interface.rb +0 -18
- data/lib/thinreports/core/shape/text/internal.rb +0 -22
- data/lib/thinreports/core/shape/text_block/format.rb +0 -41
- data/lib/thinreports/core/shape/text_block/formatter/basic.rb +0 -39
- data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +0 -23
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +0 -67
- data/lib/thinreports/core/shape/text_block/formatter/padding.rb +0 -25
- data/lib/thinreports/core/shape/text_block/formatter.rb +0 -34
- data/lib/thinreports/core/shape/text_block/interface.rb +0 -35
- data/lib/thinreports/core/shape/text_block/internal.rb +0 -73
- data/lib/thinreports/core/shape.rb +0 -42
- data/lib/thinreports/core/utils.rb +0 -45
- data/lib/thinreports/generate.rb +0 -11
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +0 -106
- data/lib/thinreports/generator/pdf/document/draw_template_items.rb +0 -69
- data/lib/thinreports/generator/pdf/document/font.rb +0 -88
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +0 -147
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +0 -135
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +0 -98
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +0 -178
- data/lib/thinreports/generator/pdf/document/graphics.rb +0 -40
- data/lib/thinreports/generator/pdf/document/page.rb +0 -94
- data/lib/thinreports/generator/pdf/document/parse_color.rb +0 -49
- data/lib/thinreports/generator/pdf/document.rb +0 -130
- data/lib/thinreports/generator/pdf/drawer/base.rb +0 -48
- data/lib/thinreports/generator/pdf/drawer/list.rb +0 -63
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +0 -49
- data/lib/thinreports/generator/pdf/drawer/page.rb +0 -125
- data/lib/thinreports/generator/pdf/prawn_ext/calc_image_dimensions.rb +0 -32
- data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +0 -29
- data/lib/thinreports/generator/pdf.rb +0 -63
- data/lib/thinreports/layout/base.rb +0 -46
- data/lib/thinreports/layout/format.rb +0 -65
- data/lib/thinreports/layout/legacy_schema.rb +0 -381
- data/lib/thinreports/layout/version.rb +0 -39
- data/lib/thinreports/report/base.rb +0 -169
- data/lib/thinreports/report/internal.rb +0 -105
- data/lib/thinreports/report/page.rb +0 -95
- data/lib/thinreports/report.rb +0 -24
- /data/lib/thinreports/{core → basic_report/core}/shape/base.rb +0 -0
- /data/lib/thinreports/{core → basic_report/core}/shape/manager.rb +0 -0
- /data/lib/thinreports/{core → basic_report/core}/shape/style.rb +0 -0
- /data/lib/thinreports/{generator → basic_report/generator}/pdf/prawn_ext.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ec1ca9a25621cae05c4f5933c6a89f7bdf13dff54707fcc4c9c56042adfafa20
|
|
4
|
+
data.tar.gz: 447d3529dcc71e8b76864fe63dca034852d24d6464ba55709bdcd721d5360b9d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f6e53ec1903941f693501393e5ebc07221d9d6a50c287aee7e4219b2ff224747b021c7be671d6b39a758b0add7f9060c67b37f8fa08d4e95c0f9cb1aaa3e8774
|
|
7
|
+
data.tar.gz: 7a32cf28566ae5bdb4766f9c944c4efb2cbfdcc6eb0319f719815cc33a8c1950a43307e131d6e032dfd09cf2340669c9054d39ed632ef46290c4f385df59999b
|
data/.github/dependabot.yml
CHANGED
data/.github/workflows/test.yml
CHANGED
|
@@ -3,48 +3,40 @@ name: Test
|
|
|
3
3
|
on: [push, pull_request]
|
|
4
4
|
|
|
5
5
|
jobs:
|
|
6
|
-
|
|
7
|
-
name:
|
|
6
|
+
setup:
|
|
7
|
+
name: Ruby ${{ matrix.ruby }}
|
|
8
|
+
|
|
8
9
|
runs-on: ubuntu-latest
|
|
10
|
+
|
|
9
11
|
# Run this build only on either pull request or push.
|
|
10
12
|
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
|
|
11
13
|
|
|
12
14
|
strategy:
|
|
13
15
|
matrix:
|
|
14
16
|
ruby:
|
|
15
|
-
- 2.
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
- 3.
|
|
19
|
-
- jruby
|
|
20
|
-
prawn:
|
|
21
|
-
- 2.2
|
|
22
|
-
- 2.3
|
|
23
|
-
- 2.4
|
|
24
|
-
exclude:
|
|
25
|
-
- ruby: 3.0
|
|
26
|
-
prawn: 2.2
|
|
27
|
-
- ruby: 3.0
|
|
28
|
-
prawn: 2.3
|
|
17
|
+
- "2.7"
|
|
18
|
+
- "3.0"
|
|
19
|
+
- "3.1"
|
|
20
|
+
- "3.2"
|
|
29
21
|
|
|
30
22
|
steps:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
bundle exec rake test:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- uses: hidakatsuya/action-setup-diff-pdf@v1
|
|
26
|
+
with:
|
|
27
|
+
diff-pdf-version: "0.5"
|
|
28
|
+
|
|
29
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
|
30
|
+
uses: ruby/setup-ruby@v1
|
|
31
|
+
with:
|
|
32
|
+
ruby-version: ${{ matrix.ruby }}
|
|
33
|
+
bundler-cache: true
|
|
34
|
+
|
|
35
|
+
- name: Run tests for main
|
|
36
|
+
run: bundle exec rake test:main
|
|
37
|
+
|
|
38
|
+
- name: Run tests for basic report
|
|
39
|
+
run: xvfb-run -a bundle exec rake test:basic_report
|
|
40
|
+
|
|
41
|
+
- name: Run tests for section report
|
|
42
|
+
run: xvfb-run -a bundle exec rake test:section_report
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
|
-
##
|
|
1
|
+
## main (Unreleased)
|
|
2
|
+
|
|
3
|
+
## 0.13.0
|
|
4
|
+
|
|
5
|
+
Breaking Changes:
|
|
6
|
+
|
|
7
|
+
* Drop Ruby 2.5,2.6,JRuby support
|
|
8
|
+
* Drop Prawn 2.2, 2.3 support
|
|
9
|
+
* Moved Basic Format implementation to `Thinreports::BasicReport` namespace
|
|
10
|
+
* `Thinreports::Report` and `Thinreports::Layout` are defined as aliases for `Thinreports::BasicReport::Report` and `Thinreports::BasicReport::Layout` respectively, but other than those can be a destructive change if you rely on internal implementations
|
|
11
|
+
|
|
12
|
+
Enhancements:
|
|
13
|
+
|
|
14
|
+
* Allow any string to be set to the title attribute of the PDF document metadata #125
|
|
15
|
+
* Add Ruby 3.1, 3.2 support
|
|
16
|
+
|
|
17
|
+
Notes:
|
|
18
|
+
|
|
19
|
+
* thinreports gem has opted in to the ["MFA required to publish" setting](https://guides.rubygems.org/mfa-requirement-opt-in/) on Rubygems.org
|
|
2
20
|
|
|
3
21
|
## 0.12.1
|
|
4
22
|
|
data/Gemfile
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
source 'https://rubygems.org'
|
|
4
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
4
5
|
|
|
5
6
|
gemspec
|
|
6
7
|
|
|
8
|
+
gem 'rake'
|
|
9
|
+
gem 'minitest'
|
|
10
|
+
gem 'mocha'
|
|
11
|
+
gem 'pdf-inspector'
|
|
12
|
+
gem 'matrix'
|
|
13
|
+
gem 'pdf_matcher-testing'
|
|
14
|
+
|
|
15
|
+
# suppress warning: assigned but unused variable - y1
|
|
16
|
+
# https://github.com/yob/pdf-reader/pull/502
|
|
17
|
+
gem 'pdf-reader', github: 'yob/pdf-reader', ref: 'dc7e6e46e1d842486bd34288df087b590e8a7b38'
|
data/README.md
CHANGED
|
@@ -9,9 +9,8 @@ A Ruby library for [Thinreports](https://github.com/thinreports/thinreports).
|
|
|
9
9
|
|
|
10
10
|
### Supported Versions
|
|
11
11
|
|
|
12
|
-
- Ruby 2.
|
|
13
|
-
-
|
|
14
|
-
- Prawn 2.2, 2.3, 2.4
|
|
12
|
+
- Ruby 2.7, 3.0, 3.1, 3.2
|
|
13
|
+
- Prawn 2.4+
|
|
15
14
|
|
|
16
15
|
## Installation
|
|
17
16
|
|
|
@@ -40,7 +39,7 @@ See [the README](https://github.com/thinreports/thinreports) for usage of the Se
|
|
|
40
39
|
|
|
41
40
|
### Basic Format
|
|
42
41
|
|
|
43
|
-
The template file (`.tlf`) must be created in
|
|
42
|
+
The template file (`.tlf`) must be created in the [Thinreports Basic Editor](https://github.com/thinreports/thinreports-basic-editor/).
|
|
44
43
|
|
|
45
44
|
```ruby
|
|
46
45
|
require 'thinreports'
|
|
@@ -165,7 +164,7 @@ report.on_page_create do |page|
|
|
|
165
164
|
end
|
|
166
165
|
```
|
|
167
166
|
|
|
168
|
-
See also [features/report_callbacks](https://github.com/thinreports/thinreports-generator/tree/
|
|
167
|
+
See also [basic_report/features/report_callbacks](https://github.com/thinreports/thinreports-generator/tree/main/test/basic_report/features/report_callbacks).
|
|
169
168
|
|
|
170
169
|
#### List
|
|
171
170
|
|
|
@@ -214,7 +213,7 @@ report.list do |list|
|
|
|
214
213
|
end
|
|
215
214
|
```
|
|
216
215
|
|
|
217
|
-
See also [features/list_events](https://github.com/thinreports/thinreports-generator/tree/
|
|
216
|
+
See also [basic_report/features/list_events](https://github.com/thinreports/thinreports-generator/tree/main/test/basic_report/features/list_events).
|
|
218
217
|
|
|
219
218
|
#### Page Number
|
|
220
219
|
|
|
@@ -235,7 +234,7 @@ report.start_new_page do |page|
|
|
|
235
234
|
end
|
|
236
235
|
```
|
|
237
236
|
|
|
238
|
-
See also [features/page_number](https://github.com/thinreports/thinreports-generator/blob/
|
|
237
|
+
See also [basic_report/features/page_number](https://github.com/thinreports/thinreports-generator/blob/main/test/basic_report/features/page_number) and [basic_report/features/page_number_with_list](https://github.com/thinreports/thinreports-generator/blob/main/test/basic_report/features/page_number_with_list).
|
|
239
238
|
|
|
240
239
|
#### Configuring fallback fonts
|
|
241
240
|
|
|
@@ -247,21 +246,17 @@ end
|
|
|
247
246
|
Thinreports.config.fallback_fonts = ['/path/to/font_a.ttf', '/path/to/font_b.ttf']
|
|
248
247
|
```
|
|
249
248
|
|
|
250
|
-
See also [features/eudc](https://github.com/thinreports/thinreports-generator/blob/
|
|
249
|
+
See also [basic_report/features/eudc](https://github.com/thinreports/thinreports-generator/blob/main/test/basic_report/features/eudc).
|
|
251
250
|
|
|
252
251
|
## Contributing
|
|
253
252
|
|
|
254
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/thinreports/thinreports-generator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/thinreports/thinreports/blob/
|
|
253
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/thinreports/thinreports-generator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/thinreports/thinreports/blob/main/CODE_OF_CONDUCT.md).
|
|
255
254
|
|
|
256
255
|
## Development
|
|
257
256
|
|
|
258
|
-
###
|
|
257
|
+
### Feature test requires diff-pdf command
|
|
259
258
|
|
|
260
|
-
|
|
261
|
-
$ bundle exec rake test:features
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
In order to run `test:features`, you need to install [diff-pdf](https://github.com/vslavik/diff-pdf) in your environment, or you can run test in the docker container as below.
|
|
259
|
+
In order to run feature test, you need to install [diff-pdf](https://github.com/vslavik/diff-pdf) in your environment, or you can run test in the docker container as below.
|
|
265
260
|
|
|
266
261
|
### How to develop in Docker container
|
|
267
262
|
|
|
@@ -278,7 +273,7 @@ You can run test:
|
|
|
278
273
|
|
|
279
274
|
```
|
|
280
275
|
> /src# bundle install
|
|
281
|
-
> /src# bundle exec rake test
|
|
276
|
+
> /src# bundle exec rake test
|
|
282
277
|
```
|
|
283
278
|
|
|
284
279
|
## Releasing Generator
|
|
@@ -287,7 +282,7 @@ You can run test:
|
|
|
287
282
|
2. Update `CHANGELOG.md` and `README.md` (if needed)
|
|
288
283
|
3. Create the Release PR like #105
|
|
289
284
|
4. Merge the PR
|
|
290
|
-
5. Is the
|
|
285
|
+
5. Is the main CI green? If not, make it green
|
|
291
286
|
6. Run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to rubygems.org
|
|
292
287
|
|
|
293
288
|
## License
|
data/Rakefile
CHANGED
|
@@ -4,19 +4,25 @@ require 'rake/testtask'
|
|
|
4
4
|
task default: :test
|
|
5
5
|
|
|
6
6
|
Rake::TestTask.new do |t|
|
|
7
|
-
t.name = 'test:
|
|
8
|
-
t.description = 'Run
|
|
9
|
-
t.libs << 'test'
|
|
10
|
-
t.test_files = Dir['test/
|
|
7
|
+
t.name = 'test:main'
|
|
8
|
+
t.description = 'Run tests for main'
|
|
9
|
+
t.libs << 'test/main'
|
|
10
|
+
t.test_files = Dir['test/main/**/test_*.rb']
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
Rake::TestTask.new do |t|
|
|
14
|
-
t.name = 'test:
|
|
15
|
-
t.description = 'Run
|
|
16
|
-
t.libs << 'test/
|
|
17
|
-
t.test_files = Dir['test/
|
|
18
|
-
t.warning = false
|
|
14
|
+
t.name = 'test:basic_report'
|
|
15
|
+
t.description = 'Run tests for basic report'
|
|
16
|
+
t.libs << 'test' << 'test/basic_report'
|
|
17
|
+
t.test_files = Dir['test/basic_report/**/test_*.rb']
|
|
19
18
|
end
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
Rake::TestTask.new do |t|
|
|
21
|
+
t.name = 'test:section_report'
|
|
22
|
+
t.description = 'Run tests for section report'
|
|
23
|
+
t.libs << 'test' << 'test/section_report'
|
|
24
|
+
t.test_files = Dir['test/section_report/**/test_*.rb']
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
desc 'Run all tests'
|
|
28
|
+
task test: %i(test:main test:basic_report test:section_report)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Thinreports
|
|
4
|
+
module BasicReport
|
|
5
|
+
module Errors
|
|
6
|
+
class Basic < ::StandardError
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class UnknownShapeStyleName < Basic
|
|
10
|
+
def initialize(style, availables)
|
|
11
|
+
super("The specified style name, '#{style}', cannot be used. " \
|
|
12
|
+
"The available styles are #{availables.map { |s| ":#{s}" }.join(', ')}.")
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class UnknownShapeType < Basic
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class UnknownFormatterType < Basic
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class LayoutFileNotFound < Basic
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class FontFileNotFound < Basic
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class NoRegisteredLayoutFound < Basic
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
class UnknownItemId < Basic
|
|
32
|
+
def initialize(id, item_type = 'Basic')
|
|
33
|
+
super("The layout does not have a #{item_type} Item with id '#{id}'.")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
class DisabledListSection < Basic
|
|
38
|
+
def initialize(section)
|
|
39
|
+
super("The #{section} section is disabled.")
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class UnknownLayoutId < Basic
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
class UnsupportedColorName < Basic
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
class InvalidLayoutFormat < Basic
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
class IncompatibleLayoutFormat < Basic
|
|
53
|
+
def initialize(filename, fileversion, required_rules)
|
|
54
|
+
super("Generator #{Thinreports::VERSION} can not be built this file, " \
|
|
55
|
+
"'#{File.basename(filename)}'. " \
|
|
56
|
+
"This file is updated in the Editor of version '#{fileversion}', " \
|
|
57
|
+
"but Generator requires version #{required_rules}.")
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Thinreports
|
|
4
|
+
module BasicReport
|
|
5
|
+
module Core
|
|
6
|
+
module Format
|
|
7
|
+
# @abstract
|
|
8
|
+
class Base
|
|
9
|
+
class << self
|
|
10
|
+
def config_reader(*configs, &block)
|
|
11
|
+
each_configs(*configs) do |m, location|
|
|
12
|
+
define_read_method(m, location, &block)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def config_checker(check, *configs)
|
|
17
|
+
checker = ->(val) { val == check }
|
|
18
|
+
each_configs(*configs) do |m, location|
|
|
19
|
+
define_read_method(:"#{m}?", location, &checker)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def config_writer(*configs)
|
|
24
|
+
each_configs(*configs) do |m, location|
|
|
25
|
+
define_write_method(m, location)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def config_accessor(*configs, &block)
|
|
30
|
+
config_reader(*configs, &block)
|
|
31
|
+
config_writer(*configs)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def define_read_method(m, location = nil, &block)
|
|
37
|
+
define_method(m) do
|
|
38
|
+
read(*location, &block)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def define_write_method(m, location = nil)
|
|
43
|
+
define_method(:"#{m}=") do |value|
|
|
44
|
+
write(value, *location)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def each_configs(*configs, &block)
|
|
49
|
+
c = configs.first.is_a?(::Hash) ? configs.first : (configs || [])
|
|
50
|
+
c.each do |m, location|
|
|
51
|
+
block.call(m, location || [m.to_s])
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def initialize(config, &block)
|
|
57
|
+
@config = config
|
|
58
|
+
block.call(self) if ::Kernel.block_given?
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def attributes
|
|
62
|
+
@config
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
def find(*keys)
|
|
68
|
+
if keys.empty?
|
|
69
|
+
@config
|
|
70
|
+
else
|
|
71
|
+
keys.inject(@config) do |c, k|
|
|
72
|
+
c.is_a?(::Hash) ? c[k] : (break c)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def write(value, *keys)
|
|
78
|
+
key = keys.pop
|
|
79
|
+
owner = find(*keys)
|
|
80
|
+
owner[key] = value
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def read(*keys, &block)
|
|
84
|
+
value = find(*keys)
|
|
85
|
+
::Kernel.block_given? ? block.call(value) : value
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Thinreports
|
|
4
|
+
module BasicReport
|
|
5
|
+
module Core
|
|
6
|
+
module Shape
|
|
7
|
+
module Base
|
|
8
|
+
# @abstract
|
|
9
|
+
class Interface
|
|
10
|
+
include Utils
|
|
11
|
+
extend Forwardable
|
|
12
|
+
|
|
13
|
+
def self.internal_delegators(*args)
|
|
14
|
+
def_delegators :internal, *args
|
|
15
|
+
end
|
|
16
|
+
private_class_method :internal_delegators
|
|
17
|
+
|
|
18
|
+
attr_reader :internal
|
|
19
|
+
|
|
20
|
+
def initialize(parent, format, internal = nil)
|
|
21
|
+
@internal = internal || init_internal(parent, format)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def copy(parent)
|
|
25
|
+
self.class.new(parent, internal.format, internal.copy(parent))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
# @param [Thinreports::BasicReport::Report::Page, Thinreports::BasicReport::Core::Shape::List::SectionInterface] parent
|
|
31
|
+
# @param [Thinreports::BasicReport::Core::Shape::Basic::Format] format
|
|
32
|
+
# @return [Thinreports::BasicReport::Core::Shape::Basic::Internal]
|
|
33
|
+
# @abstract
|
|
34
|
+
def init_internal(parent, format)
|
|
35
|
+
raise NotImplementedError
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Thinreports
|
|
4
|
+
module BasicReport
|
|
5
|
+
module Core
|
|
6
|
+
module Shape
|
|
7
|
+
module Base
|
|
8
|
+
# @abstract
|
|
9
|
+
class Internal
|
|
10
|
+
include Utils
|
|
11
|
+
extend Forwardable
|
|
12
|
+
|
|
13
|
+
def self.format_delegators(*args)
|
|
14
|
+
def_delegators :format, *args
|
|
15
|
+
end
|
|
16
|
+
private_class_method :format_delegators
|
|
17
|
+
|
|
18
|
+
attr_reader :parent
|
|
19
|
+
attr_reader :format
|
|
20
|
+
attr_writer :style
|
|
21
|
+
attr_accessor :states
|
|
22
|
+
|
|
23
|
+
def initialize(parent, format)
|
|
24
|
+
@parent = parent
|
|
25
|
+
@format = format
|
|
26
|
+
@states = {}
|
|
27
|
+
@style = nil
|
|
28
|
+
|
|
29
|
+
@finalized_attributes = nil
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def style
|
|
33
|
+
raise NotImplementedError
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def copy(new_parent, &block)
|
|
37
|
+
new_internal = self.class.new(new_parent, format)
|
|
38
|
+
new_internal.style = style.copy
|
|
39
|
+
new_internal.states = deep_copy(states)
|
|
40
|
+
|
|
41
|
+
block.call(new_internal) if block_given?
|
|
42
|
+
new_internal
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def type_of?
|
|
46
|
+
raise NotImplementedError
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Thinreports
|
|
4
|
+
module BasicReport
|
|
5
|
+
module Core
|
|
6
|
+
module Shape
|
|
7
|
+
module Basic
|
|
8
|
+
class BlockInterface < Basic::Interface
|
|
9
|
+
# @overload value(val)
|
|
10
|
+
# Set a val
|
|
11
|
+
# @param [Object] val
|
|
12
|
+
# @return [self]
|
|
13
|
+
# @overload value
|
|
14
|
+
# Return the value
|
|
15
|
+
# @return [Object]
|
|
16
|
+
def value(*args)
|
|
17
|
+
if args.empty?
|
|
18
|
+
internal.read_value
|
|
19
|
+
else
|
|
20
|
+
internal.write_value(args.first)
|
|
21
|
+
self
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @param [Object] val
|
|
26
|
+
def value=(val)
|
|
27
|
+
value(val)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Thinreports
|
|
4
|
+
module BasicReport
|
|
5
|
+
module Core
|
|
6
|
+
module Shape
|
|
7
|
+
module Basic
|
|
8
|
+
class BlockInternal < Basic::Internal
|
|
9
|
+
format_delegators :box
|
|
10
|
+
|
|
11
|
+
def style
|
|
12
|
+
@style ||= Style::Basic.new(format)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def read_value
|
|
16
|
+
states.key?(:value) ? states[:value] : format.value.dup
|
|
17
|
+
end
|
|
18
|
+
alias value read_value
|
|
19
|
+
|
|
20
|
+
def write_value(val)
|
|
21
|
+
states[:value] = val
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def real_value
|
|
25
|
+
read_value
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def type_of?(type_name)
|
|
29
|
+
type_name == :block
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Thinreports
|
|
4
|
+
module BasicReport
|
|
5
|
+
module Core
|
|
6
|
+
module Shape
|
|
7
|
+
module Basic
|
|
8
|
+
class Format < Core::Format::Base
|
|
9
|
+
include Utils
|
|
10
|
+
|
|
11
|
+
config_reader :type, :id
|
|
12
|
+
config_reader :style
|
|
13
|
+
config_checker true, :display
|
|
14
|
+
config_reader follow_stretch: %w[follow-stretch]
|
|
15
|
+
|
|
16
|
+
def affect_bottom_margin?
|
|
17
|
+
attributes.fetch('affect-bottom-margin', true)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|