thinreports 0.12.0 → 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 +11 -0
- data/.github/workflows/test.yml +31 -40
- data/.gitignore +1 -1
- data/CHANGELOG.md +25 -1
- data/Gemfile +11 -0
- data/{MIT-LICENSE → LICENSE.txt} +2 -0
- data/README.md +50 -66
- 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/builder/stack_view_builder.rb +0 -2
- 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 +99 -157
- data/Dockerfile +0 -12
- 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/section_report/pdf/renderer/headers_renderer.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
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: github-actions
|
|
9
|
+
directory: /
|
|
10
|
+
schedule:
|
|
11
|
+
interval: daily
|
data/.github/workflows/test.yml
CHANGED
|
@@ -3,49 +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
|
+
|
|
11
|
+
# Run this build only on either pull request or push.
|
|
12
|
+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
|
|
13
|
+
|
|
9
14
|
strategy:
|
|
10
15
|
matrix:
|
|
11
16
|
ruby:
|
|
12
|
-
- 2.
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
- 3.
|
|
16
|
-
- jruby
|
|
17
|
-
prawn:
|
|
18
|
-
- 2.2
|
|
19
|
-
- 2.3
|
|
20
|
-
- 2.4
|
|
21
|
-
exclude:
|
|
22
|
-
- ruby: 3.0
|
|
23
|
-
prawn: 2.2
|
|
24
|
-
- ruby: 3.0
|
|
25
|
-
prawn: 2.3
|
|
17
|
+
- "2.7"
|
|
18
|
+
- "3.0"
|
|
19
|
+
- "3.1"
|
|
20
|
+
- "3.2"
|
|
26
21
|
|
|
27
22
|
steps:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- name: Run tests
|
|
49
|
-
run: |
|
|
50
|
-
bundle exec rake test:units
|
|
51
|
-
bundle exec rake test:features
|
|
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,28 @@
|
|
|
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
|
|
20
|
+
|
|
21
|
+
## 0.12.1
|
|
22
|
+
|
|
23
|
+
Bug Fixes:
|
|
24
|
+
|
|
25
|
+
* Fix argument of Thinreports::Report.generate in Ruby 3.0 #116 [@sada]
|
|
2
26
|
|
|
3
27
|
## 0.12.0
|
|
4
28
|
|
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/{MIT-LICENSE → LICENSE.txt}
RENAMED
data/README.md
CHANGED
|
@@ -2,33 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
[](http://badge.fury.io/rb/thinreports)
|
|
4
4
|
[](https://github.com/thinreports/thinreports-generator/actions)
|
|
5
|
-
[](https://codeclimate.com/github/thinreports/thinreports-generator/maintainability)
|
|
6
5
|
|
|
7
|
-
[Thinreports](
|
|
6
|
+
A Ruby library for [Thinreports](https://github.com/thinreports/thinreports).
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
* Thinreports Generator (Report Generator for Ruby)
|
|
8
|
+
## Prerequisites
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
### Supported Versions
|
|
11
|
+
|
|
12
|
+
- Ruby 2.7, 3.0, 3.1, 3.2
|
|
13
|
+
- Prawn 2.4+
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Add this line to your application's Gemfile:
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
gem 'thinreports'
|
|
21
|
+
```
|
|
13
22
|
|
|
14
|
-
|
|
15
|
-
* [Quick Start Guide](http://www.thinreports.org/documentation/getting-started/quickstart.html)
|
|
16
|
-
* [Examples](https://github.com/thinreports/thinreports-examples)
|
|
17
|
-
* [Changelog](https://github.com/thinreports/thinreports-generator/blob/master/CHANGELOG.md)
|
|
18
|
-
* [Discussion Group (GitHub Discussions)](https://github.com/thinreports/thinreports/discussions)
|
|
19
|
-
* [Discussion Group (Google Groups)](https://groups.google.com/forum/#!forum/thinreports)
|
|
23
|
+
And then execute:
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
$ bundle install
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
* Prawn 2.2, 2.3, 2.4
|
|
25
|
-
* JRuby 9.2
|
|
27
|
+
Or install it yourself as:
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
$ gem install thinreports
|
|
28
30
|
|
|
29
|
-
**NOTE:** You need to create a layout file `.tlf` using [Thinreports Editor](http://www.thinreports.org/features/editor/).
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
## Getting Started
|
|
33
|
+
|
|
34
|
+
First of all, check out [the README](https://github.com/thinreports/thinreports#getting-started) for an overview of Thinreports, its features, the two template formats available, and a complete example with template files and Ruby code.
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
See [the README](https://github.com/thinreports/thinreports) for usage of the Section Format.
|
|
39
|
+
|
|
40
|
+
### Basic Format
|
|
41
|
+
|
|
42
|
+
The template file (`.tlf`) must be created in the [Thinreports Basic Editor](https://github.com/thinreports/thinreports-basic-editor/).
|
|
32
43
|
|
|
33
44
|
```ruby
|
|
34
45
|
require 'thinreports'
|
|
@@ -103,7 +114,7 @@ Thinreports::Report.generate(filename: 'report.pdf', layout: 'report.tlf') do |r
|
|
|
103
114
|
end
|
|
104
115
|
```
|
|
105
116
|
|
|
106
|
-
|
|
117
|
+
#### Report and Page
|
|
107
118
|
|
|
108
119
|
```ruby
|
|
109
120
|
report = Thinreports::Report.new layout: 'foo.tlf'
|
|
@@ -121,7 +132,7 @@ report.add_blank_page
|
|
|
121
132
|
report.pages.last # => Report::BlankPage
|
|
122
133
|
```
|
|
123
134
|
|
|
124
|
-
|
|
135
|
+
#### Using multiple layouts
|
|
125
136
|
|
|
126
137
|
```ruby
|
|
127
138
|
report = Thinreports::Report.new
|
|
@@ -142,7 +153,7 @@ report.start_new_page layout: '/path/to/other2.tlf' do |page|
|
|
|
142
153
|
end
|
|
143
154
|
```
|
|
144
155
|
|
|
145
|
-
|
|
156
|
+
#### Callbacks
|
|
146
157
|
|
|
147
158
|
```ruby
|
|
148
159
|
report = Thinreports::Report.new layout: 'foo.tlf'
|
|
@@ -153,9 +164,9 @@ report.on_page_create do |page|
|
|
|
153
164
|
end
|
|
154
165
|
```
|
|
155
166
|
|
|
156
|
-
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).
|
|
157
168
|
|
|
158
|
-
|
|
169
|
+
#### List
|
|
159
170
|
|
|
160
171
|
```ruby
|
|
161
172
|
report = Thinreports::Report.new layout: 'list.tlf'
|
|
@@ -202,9 +213,9 @@ report.list do |list|
|
|
|
202
213
|
end
|
|
203
214
|
```
|
|
204
215
|
|
|
205
|
-
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).
|
|
206
217
|
|
|
207
|
-
|
|
218
|
+
#### Page Number
|
|
208
219
|
|
|
209
220
|
```ruby
|
|
210
221
|
# Setting starting number of page
|
|
@@ -223,9 +234,9 @@ report.start_new_page do |page|
|
|
|
223
234
|
end
|
|
224
235
|
```
|
|
225
236
|
|
|
226
|
-
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).
|
|
227
238
|
|
|
228
|
-
|
|
239
|
+
#### Configuring fallback fonts
|
|
229
240
|
|
|
230
241
|
```ruby
|
|
231
242
|
Thinreports.configure do |config|
|
|
@@ -235,61 +246,34 @@ end
|
|
|
235
246
|
Thinreports.config.fallback_fonts = ['/path/to/font_a.ttf', '/path/to/font_b.ttf']
|
|
236
247
|
```
|
|
237
248
|
|
|
238
|
-
See also [features/eudc](https://github.com/thinreports/thinreports-generator/blob/
|
|
239
|
-
|
|
240
|
-
## Features
|
|
241
|
-
|
|
242
|
-
Features of Editor is [here](http://www.thinreports.org/features/editor/).
|
|
243
|
-
|
|
244
|
-
### Easy to generate PDF
|
|
245
|
-
|
|
246
|
-
Design layout using Editor, then embed values to text field in layout.
|
|
247
|
-
|
|
248
|
-
### Simple runtime environment
|
|
249
|
-
|
|
250
|
-
Ruby, RubyGems, Prawn and Generator.
|
|
251
|
-
|
|
252
|
-
### Dynamic operation
|
|
253
|
-
|
|
254
|
-
Generator can dynamically:
|
|
255
|
-
|
|
256
|
-
* change value of TextBlock and ImageBlock
|
|
257
|
-
* change style (border, fill, visibility, position, color, font) of Shape
|
|
258
|
-
|
|
259
|
-
### Others
|
|
260
|
-
|
|
261
|
-
* External characters (Gaiji) for Japanese
|
|
249
|
+
See also [basic_report/features/eudc](https://github.com/thinreports/thinreports-generator/blob/main/test/basic_report/features/eudc).
|
|
262
250
|
|
|
263
251
|
## Contributing
|
|
264
252
|
|
|
265
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/thinreports/thinreports-generator.
|
|
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).
|
|
266
254
|
|
|
267
255
|
## Development
|
|
268
256
|
|
|
269
|
-
###
|
|
270
|
-
|
|
271
|
-
```
|
|
272
|
-
$ bundle exec rake test:features
|
|
273
|
-
```
|
|
257
|
+
### Feature test requires diff-pdf command
|
|
274
258
|
|
|
275
|
-
In order to run
|
|
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.
|
|
276
260
|
|
|
277
261
|
### How to develop in Docker container
|
|
278
262
|
|
|
279
263
|
You can use the Docker container for development. This container contains the libraries required for testing, such as diff-pdf.
|
|
280
264
|
|
|
281
265
|
```
|
|
282
|
-
$ docker
|
|
283
|
-
$ docker run -v $PWD:/
|
|
266
|
+
$ docker pull ghcr.io/hidakatsuya/ruby-with-diff-pdf:latest
|
|
267
|
+
$ docker run -v $PWD:/src:cached -it ghcr.io/hidakatsuya/ruby-with-diff-pdf bash
|
|
284
268
|
|
|
285
|
-
> /
|
|
269
|
+
> /src#
|
|
286
270
|
```
|
|
287
271
|
|
|
288
272
|
You can run test:
|
|
289
273
|
|
|
290
274
|
```
|
|
291
|
-
> /
|
|
292
|
-
> /
|
|
275
|
+
> /src# bundle install
|
|
276
|
+
> /src# bundle exec rake test
|
|
293
277
|
```
|
|
294
278
|
|
|
295
279
|
## Releasing Generator
|
|
@@ -298,13 +282,13 @@ You can run test:
|
|
|
298
282
|
2. Update `CHANGELOG.md` and `README.md` (if needed)
|
|
299
283
|
3. Create the Release PR like #105
|
|
300
284
|
4. Merge the PR
|
|
301
|
-
5. Is the
|
|
285
|
+
5. Is the main CI green? If not, make it green
|
|
302
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
|
|
303
287
|
|
|
304
288
|
## License
|
|
305
289
|
|
|
306
|
-
|
|
290
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
307
291
|
|
|
308
292
|
## Copyright
|
|
309
293
|
|
|
310
|
-
|
|
294
|
+
(c) 2021 [Matsukei Co.,Ltd](http://www.matsukei.co.jp).
|
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
|