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.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +11 -0
  3. data/.github/workflows/test.yml +31 -40
  4. data/.gitignore +1 -1
  5. data/CHANGELOG.md +25 -1
  6. data/Gemfile +11 -0
  7. data/{MIT-LICENSE → LICENSE.txt} +2 -0
  8. data/README.md +50 -66
  9. data/Rakefile +17 -11
  10. data/lib/thinreports/basic_report/core/errors.rb +62 -0
  11. data/lib/thinreports/basic_report/core/format/base.rb +91 -0
  12. data/lib/thinreports/basic_report/core/shape/base/interface.rb +42 -0
  13. data/lib/thinreports/basic_report/core/shape/base/internal.rb +53 -0
  14. data/lib/thinreports/basic_report/core/shape/basic/block_format.rb +15 -0
  15. data/lib/thinreports/basic_report/core/shape/basic/block_interface.rb +34 -0
  16. data/lib/thinreports/basic_report/core/shape/basic/block_internal.rb +36 -0
  17. data/lib/thinreports/basic_report/core/shape/basic/format.rb +24 -0
  18. data/lib/thinreports/basic_report/core/shape/basic/interface.rb +87 -0
  19. data/lib/thinreports/basic_report/core/shape/basic/internal.rb +28 -0
  20. data/lib/thinreports/{core → basic_report/core}/shape/basic.rb +6 -4
  21. data/lib/thinreports/basic_report/core/shape/image_block/format.rb +14 -0
  22. data/lib/thinreports/basic_report/core/shape/image_block/interface.rb +25 -0
  23. data/lib/thinreports/basic_report/core/shape/image_block/internal.rb +19 -0
  24. data/lib/thinreports/{core → basic_report/core}/shape/image_block.rb +6 -4
  25. data/lib/thinreports/basic_report/core/shape/list/format.rb +92 -0
  26. data/lib/thinreports/basic_report/core/shape/list/manager.rb +231 -0
  27. data/lib/thinreports/basic_report/core/shape/list/page.rb +112 -0
  28. data/lib/thinreports/basic_report/core/shape/list/page_state.rb +50 -0
  29. data/lib/thinreports/basic_report/core/shape/list/section_format.rb +37 -0
  30. data/lib/thinreports/basic_report/core/shape/list/section_interface.rb +51 -0
  31. data/lib/thinreports/basic_report/core/shape/list/section_internal.rb +33 -0
  32. data/lib/thinreports/{core → basic_report/core}/shape/list.rb +6 -4
  33. data/lib/thinreports/basic_report/core/shape/manager/format.rb +33 -0
  34. data/lib/thinreports/basic_report/core/shape/manager/internal.rb +109 -0
  35. data/lib/thinreports/basic_report/core/shape/manager/target.rb +114 -0
  36. data/lib/thinreports/basic_report/core/shape/page_number/format.rb +32 -0
  37. data/lib/thinreports/basic_report/core/shape/page_number/interface.rb +31 -0
  38. data/lib/thinreports/basic_report/core/shape/page_number/internal.rb +57 -0
  39. data/lib/thinreports/{core → basic_report/core}/shape/page_number.rb +6 -4
  40. data/lib/thinreports/basic_report/core/shape/stack_view/format.rb +29 -0
  41. data/lib/thinreports/basic_report/core/shape/stack_view/interface.rb +19 -0
  42. data/lib/thinreports/basic_report/core/shape/stack_view/internal.rb +24 -0
  43. data/lib/thinreports/basic_report/core/shape/stack_view/row_format.rb +41 -0
  44. data/lib/thinreports/{core → basic_report/core}/shape/stack_view.rb +6 -4
  45. data/lib/thinreports/basic_report/core/shape/style/base.rb +149 -0
  46. data/lib/thinreports/basic_report/core/shape/style/basic.rb +24 -0
  47. data/lib/thinreports/basic_report/core/shape/style/graphic.rb +43 -0
  48. data/lib/thinreports/basic_report/core/shape/style/text.rb +122 -0
  49. data/lib/thinreports/basic_report/core/shape/text/format.rb +17 -0
  50. data/lib/thinreports/basic_report/core/shape/text/interface.rb +20 -0
  51. data/lib/thinreports/basic_report/core/shape/text/internal.rb +24 -0
  52. data/lib/thinreports/{core → basic_report/core}/shape/text.rb +6 -4
  53. data/lib/thinreports/basic_report/core/shape/text_block/format.rb +43 -0
  54. data/lib/thinreports/basic_report/core/shape/text_block/formatter/basic.rb +41 -0
  55. data/lib/thinreports/basic_report/core/shape/text_block/formatter/datetime.rb +25 -0
  56. data/lib/thinreports/basic_report/core/shape/text_block/formatter/number.rb +69 -0
  57. data/lib/thinreports/basic_report/core/shape/text_block/formatter/padding.rb +27 -0
  58. data/lib/thinreports/basic_report/core/shape/text_block/formatter.rb +38 -0
  59. data/lib/thinreports/basic_report/core/shape/text_block/interface.rb +37 -0
  60. data/lib/thinreports/basic_report/core/shape/text_block/internal.rb +75 -0
  61. data/lib/thinreports/{core → basic_report/core}/shape/text_block.rb +6 -4
  62. data/lib/thinreports/basic_report/core/shape.rb +44 -0
  63. data/lib/thinreports/basic_report/core/utils.rb +47 -0
  64. data/lib/thinreports/basic_report/generator/pdf/document/draw_shape.rb +108 -0
  65. data/lib/thinreports/basic_report/generator/pdf/document/draw_template_items.rb +71 -0
  66. data/lib/thinreports/basic_report/generator/pdf/document/font.rb +90 -0
  67. data/lib/thinreports/basic_report/generator/pdf/document/graphics/attributes.rb +149 -0
  68. data/lib/thinreports/basic_report/generator/pdf/document/graphics/basic.rb +137 -0
  69. data/lib/thinreports/basic_report/generator/pdf/document/graphics/image.rb +99 -0
  70. data/lib/thinreports/basic_report/generator/pdf/document/graphics/text.rb +180 -0
  71. data/lib/thinreports/basic_report/generator/pdf/document/graphics.rb +42 -0
  72. data/lib/thinreports/basic_report/generator/pdf/document/page.rb +96 -0
  73. data/lib/thinreports/basic_report/generator/pdf/document/parse_color.rb +51 -0
  74. data/lib/thinreports/basic_report/generator/pdf/document.rb +132 -0
  75. data/lib/thinreports/basic_report/generator/pdf/drawer/base.rb +50 -0
  76. data/lib/thinreports/basic_report/generator/pdf/drawer/list.rb +65 -0
  77. data/lib/thinreports/basic_report/generator/pdf/drawer/list_section.rb +51 -0
  78. data/lib/thinreports/basic_report/generator/pdf/drawer/page.rb +127 -0
  79. data/lib/thinreports/basic_report/generator/pdf/prawn_ext/calc_image_dimensions.rb +34 -0
  80. data/lib/thinreports/basic_report/generator/pdf/prawn_ext/width_of.rb +31 -0
  81. data/lib/thinreports/basic_report/generator/pdf.rb +66 -0
  82. data/lib/thinreports/basic_report/layout/base.rb +48 -0
  83. data/lib/thinreports/basic_report/layout/format.rb +67 -0
  84. data/lib/thinreports/basic_report/layout/legacy_schema.rb +383 -0
  85. data/lib/thinreports/basic_report/layout/version.rb +41 -0
  86. data/lib/thinreports/{layout.rb → basic_report/layout.rb} +6 -4
  87. data/lib/thinreports/basic_report/report/base.rb +173 -0
  88. data/lib/thinreports/basic_report/report/internal.rb +107 -0
  89. data/lib/thinreports/basic_report/report/page.rb +97 -0
  90. data/lib/thinreports/basic_report/report.rb +26 -0
  91. data/lib/thinreports/basic_report.rb +15 -0
  92. data/lib/thinreports/config.rb +1 -1
  93. data/lib/thinreports/section_report/builder/stack_view_builder.rb +0 -2
  94. data/lib/thinreports/section_report.rb +12 -0
  95. data/lib/thinreports/version.rb +1 -1
  96. data/lib/thinreports.rb +2 -13
  97. data/thinreports.gemspec +3 -7
  98. metadata +99 -157
  99. data/Dockerfile +0 -12
  100. data/gemfiles/prawn-2.2.gemfile +0 -5
  101. data/gemfiles/prawn-2.3.gemfile +0 -5
  102. data/gemfiles/prawn-2.4.gemfile +0 -5
  103. data/lib/thinreports/core/errors.rb +0 -60
  104. data/lib/thinreports/core/format/base.rb +0 -89
  105. data/lib/thinreports/core/shape/base/interface.rb +0 -40
  106. data/lib/thinreports/core/shape/base/internal.rb +0 -51
  107. data/lib/thinreports/core/shape/basic/block_format.rb +0 -13
  108. data/lib/thinreports/core/shape/basic/block_interface.rb +0 -32
  109. data/lib/thinreports/core/shape/basic/block_internal.rb +0 -34
  110. data/lib/thinreports/core/shape/basic/format.rb +0 -22
  111. data/lib/thinreports/core/shape/basic/interface.rb +0 -85
  112. data/lib/thinreports/core/shape/basic/internal.rb +0 -26
  113. data/lib/thinreports/core/shape/image_block/format.rb +0 -12
  114. data/lib/thinreports/core/shape/image_block/interface.rb +0 -23
  115. data/lib/thinreports/core/shape/image_block/internal.rb +0 -17
  116. data/lib/thinreports/core/shape/list/format.rb +0 -90
  117. data/lib/thinreports/core/shape/list/manager.rb +0 -229
  118. data/lib/thinreports/core/shape/list/page.rb +0 -110
  119. data/lib/thinreports/core/shape/list/page_state.rb +0 -48
  120. data/lib/thinreports/core/shape/list/section_format.rb +0 -35
  121. data/lib/thinreports/core/shape/list/section_interface.rb +0 -49
  122. data/lib/thinreports/core/shape/list/section_internal.rb +0 -31
  123. data/lib/thinreports/core/shape/manager/format.rb +0 -31
  124. data/lib/thinreports/core/shape/manager/internal.rb +0 -107
  125. data/lib/thinreports/core/shape/manager/target.rb +0 -112
  126. data/lib/thinreports/core/shape/page_number/format.rb +0 -30
  127. data/lib/thinreports/core/shape/page_number/interface.rb +0 -29
  128. data/lib/thinreports/core/shape/page_number/internal.rb +0 -55
  129. data/lib/thinreports/core/shape/stack_view/format.rb +0 -27
  130. data/lib/thinreports/core/shape/stack_view/interface.rb +0 -17
  131. data/lib/thinreports/core/shape/stack_view/internal.rb +0 -22
  132. data/lib/thinreports/core/shape/stack_view/row_format.rb +0 -39
  133. data/lib/thinreports/core/shape/style/base.rb +0 -146
  134. data/lib/thinreports/core/shape/style/basic.rb +0 -22
  135. data/lib/thinreports/core/shape/style/graphic.rb +0 -41
  136. data/lib/thinreports/core/shape/style/text.rb +0 -120
  137. data/lib/thinreports/core/shape/text/format.rb +0 -15
  138. data/lib/thinreports/core/shape/text/interface.rb +0 -18
  139. data/lib/thinreports/core/shape/text/internal.rb +0 -22
  140. data/lib/thinreports/core/shape/text_block/format.rb +0 -41
  141. data/lib/thinreports/core/shape/text_block/formatter/basic.rb +0 -39
  142. data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +0 -23
  143. data/lib/thinreports/core/shape/text_block/formatter/number.rb +0 -67
  144. data/lib/thinreports/core/shape/text_block/formatter/padding.rb +0 -25
  145. data/lib/thinreports/core/shape/text_block/formatter.rb +0 -34
  146. data/lib/thinreports/core/shape/text_block/interface.rb +0 -35
  147. data/lib/thinreports/core/shape/text_block/internal.rb +0 -73
  148. data/lib/thinreports/core/shape.rb +0 -42
  149. data/lib/thinreports/core/utils.rb +0 -45
  150. data/lib/thinreports/generate.rb +0 -11
  151. data/lib/thinreports/generator/pdf/document/draw_shape.rb +0 -106
  152. data/lib/thinreports/generator/pdf/document/draw_template_items.rb +0 -69
  153. data/lib/thinreports/generator/pdf/document/font.rb +0 -88
  154. data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +0 -147
  155. data/lib/thinreports/generator/pdf/document/graphics/basic.rb +0 -135
  156. data/lib/thinreports/generator/pdf/document/graphics/image.rb +0 -98
  157. data/lib/thinreports/generator/pdf/document/graphics/text.rb +0 -178
  158. data/lib/thinreports/generator/pdf/document/graphics.rb +0 -40
  159. data/lib/thinreports/generator/pdf/document/page.rb +0 -94
  160. data/lib/thinreports/generator/pdf/document/parse_color.rb +0 -49
  161. data/lib/thinreports/generator/pdf/document.rb +0 -130
  162. data/lib/thinreports/generator/pdf/drawer/base.rb +0 -48
  163. data/lib/thinreports/generator/pdf/drawer/list.rb +0 -63
  164. data/lib/thinreports/generator/pdf/drawer/list_section.rb +0 -49
  165. data/lib/thinreports/generator/pdf/drawer/page.rb +0 -125
  166. data/lib/thinreports/generator/pdf/prawn_ext/calc_image_dimensions.rb +0 -32
  167. data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +0 -29
  168. data/lib/thinreports/generator/pdf.rb +0 -63
  169. data/lib/thinreports/layout/base.rb +0 -46
  170. data/lib/thinreports/layout/format.rb +0 -65
  171. data/lib/thinreports/layout/legacy_schema.rb +0 -381
  172. data/lib/thinreports/layout/version.rb +0 -39
  173. data/lib/thinreports/report/base.rb +0 -169
  174. data/lib/thinreports/report/internal.rb +0 -105
  175. data/lib/thinreports/report/page.rb +0 -95
  176. data/lib/thinreports/report.rb +0 -24
  177. data/lib/thinreports/section_report/pdf/renderer/headers_renderer.rb +0 -24
  178. /data/lib/thinreports/{core → basic_report/core}/shape/base.rb +0 -0
  179. /data/lib/thinreports/{core → basic_report/core}/shape/manager.rb +0 -0
  180. /data/lib/thinreports/{core → basic_report/core}/shape/style.rb +0 -0
  181. /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: 9713f8331c7d6c97d17f0b30ba84124148f48ed40d3fde29f884503146415ed0
4
- data.tar.gz: 0617cb86495f89090b6f751334aed7fd69c42b79357683992ac65d3ee0dc72e0
3
+ metadata.gz: ec1ca9a25621cae05c4f5933c6a89f7bdf13dff54707fcc4c9c56042adfafa20
4
+ data.tar.gz: 447d3529dcc71e8b76864fe63dca034852d24d6464ba55709bdcd721d5360b9d
5
5
  SHA512:
6
- metadata.gz: 37bd09438b27f1147c9803b0236bac461c0d5c08844bff920e7a183bd3f09912f157bf66c6ad246ece7a8c8041fd559a18495c56a22550459e15e357b60355c9
7
- data.tar.gz: 43fd24534374c1c63162cece99c12622c5bdab0fce12c9f8c7b9e82d985ec50fc0b1fa388f1b67658ae3892e6b9d97350fada88ef6c48021c4dedecff128e910
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
@@ -3,49 +3,40 @@ name: Test
3
3
  on: [push, pull_request]
4
4
 
5
5
  jobs:
6
- test:
7
- name: Test against ruby ${{ matrix.ruby }} and prawn ${{ matrix.prawn }}
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.5
13
- - 2.6
14
- - 2.7
15
- - 3.0
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
- - uses: actions/checkout@v1
29
-
30
- - name: Set up diff-pdf
31
- run: |
32
- sudo apt-get update
33
- sudo apt-get install make automake g++ libpoppler-glib-dev poppler-utils libwxgtk3.0-dev
34
- git clone https://github.com/vslavik/diff-pdf.git -b v0.4.1 --depth 1 /tmp/diff-pdf-src
35
- cd /tmp/diff-pdf-src
36
- ./bootstrap && ./configure && make && sudo make install
37
-
38
- - name: Set up Ruby ${{ matrix.ruby }}
39
- uses: ruby/setup-ruby@v1
40
- with:
41
- ruby-version: ${{ matrix.ruby }}
42
-
43
- - name: Install dependencies
44
- run: |
45
- gem install bundler
46
- bundle install --gemfile gemfiles/prawn-${{ matrix.prawn }}.gemfile --jobs 4 --retry 3
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
@@ -4,4 +4,4 @@ Gemfile.lock
4
4
  .bundle
5
5
  .yardoc
6
6
  doc
7
- !/test/features/*/expect.pdf
7
+ !/test/**/*/expect.pdf
data/CHANGELOG.md CHANGED
@@ -1,4 +1,28 @@
1
- ## master (Unreleased)
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'
@@ -1,3 +1,5 @@
1
+ The MIT License (MIT)
2
+
1
3
  Copyright (c) 2015 Matsukei Co.,Ltd.
2
4
 
3
5
  Permission is hereby granted, free of charge, to any person obtaining
data/README.md CHANGED
@@ -2,33 +2,44 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/thinreports.svg)](http://badge.fury.io/rb/thinreports)
4
4
  [![Test](https://github.com/thinreports/thinreports-generator/workflows/Test/badge.svg)](https://github.com/thinreports/thinreports-generator/actions)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/054b400031608957ec4a/maintainability)](https://codeclimate.com/github/thinreports/thinreports-generator/maintainability)
6
5
 
7
- [Thinreports](http://www.thinreports.org) is an open source report generating tool for Ruby.
6
+ A Ruby library for [Thinreports](https://github.com/thinreports/thinreports).
8
7
 
9
- * Thinreports Editor (GUI Designer)
10
- * Thinreports Generator (Report Generator for Ruby)
8
+ ## Prerequisites
11
9
 
12
- ## Getting Started
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
- * [Installation Guide](http://www.thinreports.org/documentation/getting-started/installation.html)
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
- ## Supported versions
25
+ $ bundle install
22
26
 
23
- * Ruby 2.5, 2.6, 2.7, 3.0
24
- * Prawn 2.2, 2.3, 2.4
25
- * JRuby 9.2
27
+ Or install it yourself as:
26
28
 
27
- ## Quick Reference
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
- ### Basic Objects and Basic Usage
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
- ### Report and Page
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
- ### Using multiple layouts
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
- ### Callbacks
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/master/test/features/report_callbacks).
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
- ### List
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/master/test/features/list_events).
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
- ### Page Number
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/master/test/features/page_number) and [features/page_number_with_list](https://github.com/thinreports/thinreports-generator/blob/master/test/features/page_number_with_list).
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
- ### Configuring fallback fonts
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/master/test/features/eudc).
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
- ### How to run feature tests
270
-
271
- ```
272
- $ bundle exec rake test:features
273
- ```
257
+ ### Feature test requires diff-pdf command
274
258
 
275
- 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.
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 build -t thinreports-dev .
283
- $ docker run -v $PWD:/thinreports:cached -it thinreports-dev bash
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
- > /thinreports#
269
+ > /src#
286
270
  ```
287
271
 
288
272
  You can run test:
289
273
 
290
274
  ```
291
- > /thinreports# bundle install
292
- > /thinreports# bundle exec rake test:features
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 master CI green? If not, make it green
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
- Thinreports Generator is licensed under the [MIT-License](https://github.com/thinreports/thinreports-generator/blob/master/MIT-LICENSE).
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
- © 2010-2015 [Matsukei Co.,Ltd](http://www.matsukei.co.jp).
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:units'
8
- t.description = 'Run unit tests'
9
- t.libs << 'test'
10
- t.test_files = Dir['test/units/**/test_*.rb']
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:features'
15
- t.description = 'Run feature tests'
16
- t.libs << 'test/features'
17
- t.test_files = Dir['test/features/*/test_*.rb']
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
- desc 'Run unit and feature tests'
22
- task test: %i( test:units test:features )
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