thinreports 0.10.2 → 0.12.1

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 (178) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CONTRIBUTING.md +2 -2
  3. data/.github/dependabot.yml +11 -0
  4. data/.github/workflows/test.yml +50 -0
  5. data/.gitignore +1 -0
  6. data/CHANGELOG.md +43 -0
  7. data/Gemfile +2 -1
  8. data/{MIT-LICENSE → LICENSE.txt} +2 -0
  9. data/README.md +70 -56
  10. data/Rakefile +12 -25
  11. data/gemfiles/prawn-2.2.gemfile +5 -0
  12. data/gemfiles/prawn-2.3.gemfile +5 -0
  13. data/gemfiles/prawn-2.4.gemfile +5 -0
  14. data/lib/thinreports/core/shape/basic/format.rb +5 -0
  15. data/lib/thinreports/core/shape/image_block.rb +1 -1
  16. data/lib/thinreports/core/shape/list.rb +1 -1
  17. data/lib/thinreports/core/shape/page_number.rb +1 -1
  18. data/lib/thinreports/core/shape/stack_view/format.rb +27 -0
  19. data/lib/thinreports/core/shape/stack_view/interface.rb +17 -0
  20. data/lib/thinreports/core/shape/stack_view/internal.rb +22 -0
  21. data/lib/thinreports/core/shape/stack_view/row_format.rb +39 -0
  22. data/lib/thinreports/core/shape/stack_view.rb +17 -0
  23. data/lib/thinreports/core/shape/style/basic.rb +4 -1
  24. data/lib/thinreports/core/shape/text.rb +1 -1
  25. data/lib/thinreports/core/shape/text_block/formatter/number.rb +6 -1
  26. data/lib/thinreports/core/shape/text_block/internal.rb +0 -2
  27. data/lib/thinreports/core/shape/text_block.rb +1 -1
  28. data/lib/thinreports/core/shape.rb +2 -0
  29. data/lib/thinreports/generate.rb +11 -0
  30. data/lib/thinreports/generator/pdf/document/draw_shape.rb +31 -10
  31. data/lib/thinreports/generator/pdf/document/draw_template_items.rb +1 -1
  32. data/lib/thinreports/generator/pdf/document/graphics/image.rb +19 -1
  33. data/lib/thinreports/generator/pdf/document/graphics/text.rb +10 -5
  34. data/lib/thinreports/generator/pdf/document/page.rb +12 -0
  35. data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +7 -7
  36. data/lib/thinreports/layout/base.rb +1 -1
  37. data/lib/thinreports/layout/legacy_schema.rb +1 -0
  38. data/lib/thinreports/layout/version.rb +1 -1
  39. data/lib/thinreports/report/internal.rb +2 -0
  40. data/lib/thinreports/report.rb +2 -2
  41. data/lib/thinreports/section_report/build.rb +32 -0
  42. data/lib/thinreports/section_report/builder/item_builder.rb +49 -0
  43. data/lib/thinreports/section_report/builder/report_builder.rb +82 -0
  44. data/lib/thinreports/section_report/builder/report_data.rb +13 -0
  45. data/lib/thinreports/section_report/builder/stack_view_builder.rb +53 -0
  46. data/lib/thinreports/section_report/builder/stack_view_data.rb +11 -0
  47. data/lib/thinreports/section_report/generate.rb +26 -0
  48. data/lib/thinreports/section_report/pdf/render.rb +23 -0
  49. data/lib/thinreports/section_report/pdf/renderer/draw_item.rb +68 -0
  50. data/lib/thinreports/section_report/pdf/renderer/group_renderer.rb +57 -0
  51. data/lib/thinreports/section_report/pdf/renderer/section_height.rb +100 -0
  52. data/lib/thinreports/section_report/pdf/renderer/section_renderer.rb +39 -0
  53. data/lib/thinreports/section_report/pdf/renderer/stack_view_renderer.rb +55 -0
  54. data/lib/thinreports/section_report/pdf/renderer/stack_view_row_renderer.rb +38 -0
  55. data/lib/thinreports/section_report/schema/loader.rb +28 -0
  56. data/lib/thinreports/section_report/schema/parser.rb +52 -0
  57. data/lib/thinreports/section_report/schema/report.rb +30 -0
  58. data/lib/thinreports/section_report/schema/section.rb +47 -0
  59. data/lib/thinreports/version.rb +1 -1
  60. data/lib/thinreports.rb +5 -0
  61. data/thinreports.gemspec +11 -10
  62. metadata +48 -150
  63. data/.travis.yml +0 -16
  64. data/examples/character_spacing/character_spacing.rb +0 -8
  65. data/examples/character_spacing/character_spacing.tlf +0 -293
  66. data/examples/dynamic_image/dynamic_image.rb +0 -31
  67. data/examples/dynamic_image/dynamic_image.tlf +0 -661
  68. data/examples/dynamic_image/img200x100.png +0 -0
  69. data/examples/dynamic_image/img50x50.png +0 -0
  70. data/examples/dynamic_style/dynamic_style.rb +0 -150
  71. data/examples/dynamic_style/dynamic_style.tlf +0 -1835
  72. data/examples/dynamic_style/dynamic_style_in_list.tlf +0 -344
  73. data/examples/dynamic_style/image.png +0 -0
  74. data/examples/eudc/eudc.rb +0 -20
  75. data/examples/eudc/eudc.tlf +0 -180
  76. data/examples/eudc/eudc.ttf +0 -0
  77. data/examples/helper.rb +0 -50
  78. data/examples/hidden_shapes/hidden_shapes.rb +0 -9
  79. data/examples/hidden_shapes/hidden_shapes.tlf +0 -449
  80. data/examples/list_events/list_events.rb +0 -32
  81. data/examples/list_events/list_events.tlf +0 -361
  82. data/examples/list_manual_generation/list_manual_generation.rb +0 -22
  83. data/examples/list_manual_generation/list_manual_generation.tlf +0 -132
  84. data/examples/list_page_number/list_page_number.rb +0 -17
  85. data/examples/list_page_number/list_page_number.tlf +0 -254
  86. data/examples/page_number/page_number.rb +0 -33
  87. data/examples/page_number/page_number.tlf +0 -215
  88. data/examples/palleted_png/palleted_png.png +0 -0
  89. data/examples/palleted_png/palleted_png.rb +0 -9
  90. data/examples/palleted_png/palleted_png.tlf +0 -47
  91. data/examples/password_setting/password_setting.rb +0 -10
  92. data/examples/password_setting/password_setting.tlf +0 -45
  93. data/examples/report_callbacks/report_callbacks.rb +0 -14
  94. data/examples/report_callbacks/report_callbacks.tlf +0 -147
  95. data/examples/single_line_tblock/single_line_tblock.rb +0 -13
  96. data/examples/single_line_tblock/single_line_tblock.tlf +0 -170
  97. data/examples/tblock_overflow/tblock_overflow.rb +0 -20
  98. data/examples/tblock_overflow/tblock_overflow.tlf +0 -538
  99. data/examples/tblock_styles/font_size.tlf +0 -383
  100. data/examples/tblock_styles/tblock_styles.rb +0 -43
  101. data/examples/tblock_styles/tblock_styles.tlf +0 -889
  102. data/examples/text_align/text_align.rb +0 -8
  103. data/examples/text_align/text_align.tlf +0 -241
  104. data/examples/typeB_page_size/B4_ISO.tlf +0 -45
  105. data/examples/typeB_page_size/B4_JIS.tlf +0 -45
  106. data/examples/typeB_page_size/typeB_page_size.rb +0 -17
  107. data/examples/word_wrap/word_wrap.rb +0 -26
  108. data/examples/word_wrap/word_wrap.tlf +0 -297
  109. data/test/data/font.ttf +0 -0
  110. data/test/data/image_normal.jpg +0 -0
  111. data/test/data/image_normal.png +0 -0
  112. data/test/data/image_normal_jpg_noext +0 -0
  113. data/test/data/image_normal_png_noext +0 -0
  114. data/test/data/image_pallete_based.png +0 -0
  115. data/test/data/legacy_layout/all-items.tlf +0 -1
  116. data/test/schema_helper.rb +0 -122
  117. data/test/test_helper.rb +0 -48
  118. data/test/tmp/.gitkeep +0 -0
  119. data/test/unit/core/format/test_base.rb +0 -152
  120. data/test/unit/core/shape/base/test_internal.rb +0 -87
  121. data/test/unit/core/shape/basic/test_block_format.rb +0 -23
  122. data/test/unit/core/shape/basic/test_block_interface.rb +0 -29
  123. data/test/unit/core/shape/basic/test_block_internal.rb +0 -55
  124. data/test/unit/core/shape/basic/test_format.rb +0 -37
  125. data/test/unit/core/shape/basic/test_interface.rb +0 -108
  126. data/test/unit/core/shape/basic/test_internal.rb +0 -55
  127. data/test/unit/core/shape/image_block/test_interface.rb +0 -24
  128. data/test/unit/core/shape/image_block/test_internal.rb +0 -31
  129. data/test/unit/core/shape/list/test_format.rb +0 -111
  130. data/test/unit/core/shape/list/test_manager.rb +0 -67
  131. data/test/unit/core/shape/list/test_page.rb +0 -156
  132. data/test/unit/core/shape/list/test_page_state.rb +0 -31
  133. data/test/unit/core/shape/list/test_section_format.rb +0 -36
  134. data/test/unit/core/shape/list/test_section_interface.rb +0 -75
  135. data/test/unit/core/shape/list/test_section_internal.rb +0 -50
  136. data/test/unit/core/shape/manager/test_format.rb +0 -38
  137. data/test/unit/core/shape/manager/test_internal.rb +0 -132
  138. data/test/unit/core/shape/manager/test_target.rb +0 -140
  139. data/test/unit/core/shape/page_number/test_format.rb +0 -55
  140. data/test/unit/core/shape/page_number/test_interface.rb +0 -33
  141. data/test/unit/core/shape/page_number/test_internal.rb +0 -81
  142. data/test/unit/core/shape/styles/test_base.rb +0 -191
  143. data/test/unit/core/shape/styles/test_basic.rb +0 -24
  144. data/test/unit/core/shape/styles/test_graphic.rb +0 -50
  145. data/test/unit/core/shape/styles/test_text.rb +0 -97
  146. data/test/unit/core/shape/text/test_format.rb +0 -44
  147. data/test/unit/core/shape/text/test_internal.rb +0 -20
  148. data/test/unit/core/shape/text_block/formatter/test_basic.rb +0 -24
  149. data/test/unit/core/shape/text_block/formatter/test_datetime.rb +0 -49
  150. data/test/unit/core/shape/text_block/formatter/test_number.rb +0 -76
  151. data/test/unit/core/shape/text_block/formatter/test_padding.rb +0 -77
  152. data/test/unit/core/shape/text_block/test_format.rb +0 -169
  153. data/test/unit/core/shape/text_block/test_formatter.rb +0 -28
  154. data/test/unit/core/shape/text_block/test_interface.rb +0 -63
  155. data/test/unit/core/shape/text_block/test_internal.rb +0 -128
  156. data/test/unit/core/test_shape.rb +0 -52
  157. data/test/unit/core/test_utils.rb +0 -68
  158. data/test/unit/generator/pdf/document/graphics/test_attributes.rb +0 -135
  159. data/test/unit/generator/pdf/document/graphics/test_basic.rb +0 -46
  160. data/test/unit/generator/pdf/document/graphics/test_image.rb +0 -46
  161. data/test/unit/generator/pdf/document/graphics/test_text.rb +0 -171
  162. data/test/unit/generator/pdf/document/test_font.rb +0 -110
  163. data/test/unit/generator/pdf/document/test_graphics.rb +0 -42
  164. data/test/unit/generator/pdf/document/test_page.rb +0 -122
  165. data/test/unit/generator/pdf/document/test_parse_color.rb +0 -30
  166. data/test/unit/generator/pdf/prawn_ext/test_calc_image_dimensions.rb +0 -41
  167. data/test/unit/generator/pdf/prawn_ext/test_width_of.rb +0 -22
  168. data/test/unit/generator/pdf/test_document.rb +0 -22
  169. data/test/unit/generator/test_pdf.rb +0 -26
  170. data/test/unit/layout/test_base.rb +0 -41
  171. data/test/unit/layout/test_format.rb +0 -100
  172. data/test/unit/layout/test_legacy_schema.rb +0 -574
  173. data/test/unit/layout/test_version.rb +0 -26
  174. data/test/unit/report/test_base.rb +0 -248
  175. data/test/unit/report/test_internal.rb +0 -206
  176. data/test/unit/test_config.rb +0 -36
  177. data/test/unit/test_layout.rb +0 -12
  178. data/test/unit/test_report.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4474cfbc0c46ee058fe7c39e3a6b927f6095ca471696c119e306c1cf9aa7e67
4
- data.tar.gz: ef944d6dc314c13c8c983af7fc9ccec2a949f7c59e113978b1626daaea3bee54
3
+ metadata.gz: 3abf53b7bac12b336d4ef9b4af7dd4400081eeb632f8ece362e60f6cca47c2b4
4
+ data.tar.gz: 4461aca74ccae200d234715a06bbc60e753a7694053116c58ef2d031b8f01047
5
5
  SHA512:
6
- metadata.gz: eb722605ed4c420f4eaca8880be300e3dbed0817b3c0eaac6fe8c34cd52f55b097dfec1a691e26c996f46405fec10db2f3caace17a8d7a1b248338f92b3e9cca
7
- data.tar.gz: fb5756fdf71f6ccf23f75102b4e94c362e0959e50e79f84f6dc33f116e3ca758a38471c49499132cebc17da58c8ca2ae6e492bb9ca40690a5d3371fc865742bb
6
+ metadata.gz: 8ebae61bcd5ce2524bc8c09eff3f2fa047de632a250dfce9390a4db78b806d945ed32ea563c1063836d938e139b433b53c595592ec741a3a0c719bb74d7ffb1b
7
+ data.tar.gz: ef7d77b8edaf345b546cc42bb4f2ac98d23e2e74fe62921a181976ff38f11c6f4a6ef875ede3bcb40dfd0fa02ddc42cfe532df7c7bad633efe4f8cfd056a32ca
@@ -1,2 +1,2 @@
1
- **We only accept bug reports and pull requests in GitHub**.
2
- If you have a support question about how to use thinreports, please [ask on Google Group](https://groups.google.com/forum/?hl=ja#!forum/thinreports).
1
+ We only accept bug reports and pull requests in GitHub.
2
+ If you have a support question about how to use thinreports, please [ask on GitHub Discussions](https://github.com/thinreports/thinreports/discussions).
@@ -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: "bundler"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "daily"
@@ -0,0 +1,50 @@
1
+ name: Test
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ name: Test against ruby ${{ matrix.ruby }} and prawn ${{ matrix.prawn }}
8
+ runs-on: ubuntu-latest
9
+ # Run this build only on either pull request or push.
10
+ if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
11
+
12
+ strategy:
13
+ matrix:
14
+ ruby:
15
+ - 2.5
16
+ - 2.6
17
+ - 2.7
18
+ - 3.0
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
29
+
30
+ steps:
31
+ - uses: actions/checkout@v2
32
+
33
+ - uses: hidakatsuya/setup-diff-pdf@v1
34
+ with:
35
+ diff-pdf-version: 0.5
36
+
37
+ - name: Set up Ruby ${{ matrix.ruby }}
38
+ uses: ruby/setup-ruby@v1
39
+ with:
40
+ ruby-version: ${{ matrix.ruby }}
41
+
42
+ - name: Install dependencies
43
+ run: |
44
+ gem install bundler
45
+ bundle install --gemfile gemfiles/prawn-${{ matrix.prawn }}.gemfile --jobs 4 --retry 3
46
+
47
+ - name: Run tests
48
+ run: |
49
+ bundle exec rake test:units
50
+ bundle exec rake test:features
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ Gemfile.lock
4
4
  .bundle
5
5
  .yardoc
6
6
  doc
7
+ !/test/features/*/expect.pdf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,46 @@
1
+ ## master (Unreleased)
2
+
3
+ ## 0.12.1
4
+
5
+ Bug Fixes:
6
+
7
+ * Fix argument of Thinreports::Report.generate in Ruby 3.0 #116 [@sada]
8
+
9
+ ## 0.12.0
10
+
11
+ Breaking Changes:
12
+
13
+ * Drop Ruby 2.4 support #108, #109
14
+
15
+ Enhancements:
16
+
17
+ * Ruby 3.0 support #108, #109
18
+ * Prawn 2.4 support #108, #109
19
+
20
+ ## 0.11.0
21
+
22
+ Breaking Changes:
23
+
24
+ * Dropped Ruby 2.1 support
25
+ * Dropped Ruby 2.2 support
26
+ * Dropped Ruby 2.3 support
27
+ * Formatter of a text-block works even with multiple-line (#95)
28
+
29
+ Enhancements:
30
+
31
+ * Ruby 2.7.0 support
32
+ * Support Pathname layout option on `Thinreports::Report` #99 [@meganemura]
33
+
34
+ Bug Fixes:
35
+
36
+ * Fixed: thousands separation is applied to decimal part #95
37
+
38
+ ## 0.10.3
39
+
40
+ Bug Fixes:
41
+
42
+ * Fixed: corner-radius of Rect is not applied correctly #93
43
+
1
44
  ## 0.10.2
2
45
 
3
46
  Bug Fixes:
data/Gemfile CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'http://rubygems.org'
3
+ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
+
@@ -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
@@ -1,34 +1,46 @@
1
1
  # Thinreports Generator
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/thinreports.svg)](http://badge.fury.io/rb/thinreports)
4
- [![](http://img.shields.io/travis/thinreports/thinreports-generator.svg?style=flat)](http://travis-ci.org/thinreports/thinreports-generator)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/054b400031608957ec4a/maintainability)](https://codeclimate.com/github/thinreports/thinreports-generator/maintainability)
6
- [![](http://img.shields.io/gemnasium/thinreports/thinreports-generator.svg?style=flat)](https://gemnasium.com/thinreports/thinreports-generator)
4
+ [![Test](https://github.com/thinreports/thinreports-generator/workflows/Test/badge.svg)](https://github.com/thinreports/thinreports-generator/actions)
7
5
 
8
- [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).
9
7
 
10
- * Thinreports Editor (GUI Designer)
11
- * Thinreports Generator (Report Generator for Ruby)
8
+ ## Prerequisites
12
9
 
13
- ## Getting Started
10
+ ### Supported Versions
11
+
12
+ - Ruby 2.5, 2.6, 2.7, 3.0
13
+ - JRuby 9.2
14
+ - Prawn 2.2, 2.3, 2.4
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem 'thinreports'
22
+ ```
23
+
24
+ And then execute:
25
+
26
+ $ bundle install
14
27
 
15
- * [Installation Guide](http://www.thinreports.org/documentation/getting-started/installation.html)
16
- * [Quick Start Guide](http://www.thinreports.org/documentation/getting-started/quickstart.html)
17
- * [Examples](https://github.com/thinreports/thinreports-examples)
18
- * [Rails5 Example](https://github.com/thinreports/thinreports-rails5-example)
19
- * [Changelog](https://github.com/thinreports/thinreports-generator/blob/master/CHANGELOG.md)
20
- * [Discussion Group](https://groups.google.com/forum/#!forum/thinreports)
28
+ Or install it yourself as:
21
29
 
22
- ## Supported versions
30
+ $ gem install thinreports
31
+
32
+
33
+ ## Getting Started
23
34
 
24
- * Ruby 2.1, 2.2, 2.3, 2.4, 2.5
25
- * JRuby 9.1.15.0
35
+ 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.
26
36
 
27
- ## Quick Reference
37
+ ## Usage
28
38
 
29
- **NOTE:** You need to create a layout file `.tlf` using [Thinreports Editor](http://www.thinreports.org/features/editor/).
39
+ See [the README](https://github.com/thinreports/thinreports) for usage of the Section Format.
30
40
 
31
- ### Basic Objects and Basic Usage
41
+ ### Basic Format
42
+
43
+ The template file (`.tlf`) must be created in [the Basic Editor of the Thinreports Editor](https://github.com/thinreports/thinreports-editor/tree/master/basic-editor).
32
44
 
33
45
  ```ruby
34
46
  require 'thinreports'
@@ -103,7 +115,7 @@ Thinreports::Report.generate(filename: 'report.pdf', layout: 'report.tlf') do |r
103
115
  end
104
116
  ```
105
117
 
106
- ### Report and Page
118
+ #### Report and Page
107
119
 
108
120
  ```ruby
109
121
  report = Thinreports::Report.new layout: 'foo.tlf'
@@ -121,7 +133,7 @@ report.add_blank_page
121
133
  report.pages.last # => Report::BlankPage
122
134
  ```
123
135
 
124
- ### Using multiple layouts
136
+ #### Using multiple layouts
125
137
 
126
138
  ```ruby
127
139
  report = Thinreports::Report.new
@@ -142,7 +154,7 @@ report.start_new_page layout: '/path/to/other2.tlf' do |page|
142
154
  end
143
155
  ```
144
156
 
145
- ### Callbacks
157
+ #### Callbacks
146
158
 
147
159
  ```ruby
148
160
  report = Thinreports::Report.new layout: 'foo.tlf'
@@ -153,9 +165,9 @@ report.on_page_create do |page|
153
165
  end
154
166
  ```
155
167
 
156
- See also [examples/report_callbacks](https://github.com/thinreports/thinreports-generator/tree/master/examples/report_callbacks).
168
+ See also [features/report_callbacks](https://github.com/thinreports/thinreports-generator/tree/master/test/features/report_callbacks).
157
169
 
158
- ### List
170
+ #### List
159
171
 
160
172
  ```ruby
161
173
  report = Thinreports::Report.new layout: 'list.tlf'
@@ -202,9 +214,9 @@ report.list do |list|
202
214
  end
203
215
  ```
204
216
 
205
- See also [examples/list_events](https://github.com/thinreports/thinreports-generator/tree/master/examples/list_events).
217
+ See also [features/list_events](https://github.com/thinreports/thinreports-generator/tree/master/test/features/list_events).
206
218
 
207
- ### Page Number
219
+ #### Page Number
208
220
 
209
221
  ```ruby
210
222
  # Setting starting number of page
@@ -223,9 +235,9 @@ report.start_new_page do |page|
223
235
  end
224
236
  ```
225
237
 
226
- See also [examples/page_number](https://github.com/thinreports/thinreports-generator/blob/master/examples/page_number) and [examples/list_page_number](https://github.com/thinreports/thinreports-generator/blob/master/examples/list_page_number).
238
+ 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).
227
239
 
228
- ### Configuring fallback fonts
240
+ #### Configuring fallback fonts
229
241
 
230
242
  ```ruby
231
243
  Thinreports.configure do |config|
@@ -235,51 +247,53 @@ end
235
247
  Thinreports.config.fallback_fonts = ['/path/to/font_a.ttf', '/path/to/font_b.ttf']
236
248
  ```
237
249
 
238
- See also [examples/eudc](https://github.com/thinreports/thinreports-generator/blob/master/examples/eudc).
239
-
240
- ## Features
241
-
242
- Features of Editor is [here](http://www.thinreports.org/features/editor/).
250
+ See also [features/eudc](https://github.com/thinreports/thinreports-generator/blob/master/test/features/eudc).
243
251
 
244
- ### Easy to generate PDF
252
+ ## Contributing
245
253
 
246
- Design layout using Editor, then embed values to text field in layout.
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/master/CODE_OF_CONDUCT.md).
247
255
 
248
- ### Simple runtime environment
256
+ ## Development
249
257
 
250
- Ruby, RubyGems, Prawn and Generator.
258
+ ### How to run feature tests
251
259
 
252
- ### Dynamic operation
260
+ ```
261
+ $ bundle exec rake test:features
262
+ ```
253
263
 
254
- Generator can dynamically:
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.
255
265
 
256
- * change value of TextBlock and ImageBlock
257
- * change style (border, fill, visibility, position, color, font) of Shape
266
+ ### How to develop in Docker container
258
267
 
259
- ### Others
268
+ You can use the Docker container for development. This container contains the libraries required for testing, such as diff-pdf.
260
269
 
261
- * External characters (Gaiji) for Japanese
270
+ ```
271
+ $ docker pull ghcr.io/hidakatsuya/ruby-with-diff-pdf:latest
272
+ $ docker run -v $PWD:/src:cached -it ghcr.io/hidakatsuya/ruby-with-diff-pdf bash
262
273
 
263
- ## Contributing
274
+ > /src#
275
+ ```
264
276
 
265
- ### Report bug, post your suggestion
277
+ You can run test:
266
278
 
267
- If you find bugs or improvements for the Editor, please report it [here](https://github.com/thinreports/thinreports-generator/issues/new).
279
+ ```
280
+ > /src# bundle install
281
+ > /src# bundle exec rake test:features
282
+ ```
268
283
 
269
- ### Sending a Pull Request
284
+ ## Releasing Generator
270
285
 
271
- 1. Fork it
272
- 2. Clone your forked repository
273
- 3. Create your feature branch: `git checkout -b my-new-feature`
274
- 4. Fix your feature
275
- 5. Commit your changes: `git commit -am 'Fixed some bugs or features'`
276
- 6. Push to the branch: `git push origin my-new-feature`
277
- 7. Create new Pull Request
286
+ 1. Update the version number in `version.rb`
287
+ 2. Update `CHANGELOG.md` and `README.md` (if needed)
288
+ 3. Create the Release PR like #105
289
+ 4. Merge the PR
290
+ 5. Is the master CI green? If not, make it green
291
+ 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
278
292
 
279
293
  ## License
280
294
 
281
- Thinreports Generator is licensed under the [MIT-License](https://github.com/thinreports/thinreports-generator/blob/master/MIT-LICENSE).
295
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
282
296
 
283
297
  ## Copyright
284
298
 
285
- © 2010-2015 [Matsukei Co.,Ltd](http://www.matsukei.co.jp).
299
+ (c) 2021 [Matsukei Co.,Ltd](http://www.matsukei.co.jp).
data/Rakefile CHANGED
@@ -1,35 +1,22 @@
1
+ require 'bundler/gem_tasks'
1
2
  require 'rake/testtask'
2
- require 'yard'
3
3
 
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'
7
9
  t.libs << 'test'
8
- t.test_files = Dir['test/unit/**/test_*.rb']
10
+ t.test_files = Dir['test/units/**/test_*.rb']
9
11
  end
10
12
 
11
- namespace :examples do
12
- desc 'Run all examples'
13
- task :all do
14
- require_relative 'examples/helper'
15
- Dir['examples/*/*.rb'].each { |f| require_relative f }
16
- end
17
-
18
- Dir['examples/*/*.rb'].each do |f|
19
- casename = File.basename(File.dirname(f))
20
-
21
- desc "Run example: #{casename}"
22
- task casename.to_sym => :_init do
23
- require_relative 'examples/helper'
24
- require_relative "examples/#{casename}/#{casename}"
25
- end
26
- end
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
27
19
  end
28
20
 
29
- desc 'Run all examples'
30
- task examples: :'examples:all'
31
-
32
- YARD::Rake::YardocTask.new :doc do |yard|
33
- yard.files = Dir['lib/**/*.rb']
34
- yard.options = ['--readme', 'README.md']
35
- end
21
+ desc 'Run unit and feature tests'
22
+ task test: %i( test:units test:features )
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'prawn', '~> 2.2.0'
4
+
5
+ gemspec path: '../'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'prawn', '~> 2.3.0'
4
+
5
+ gemspec path: '../'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'prawn', '~> 2.4.0'
4
+
5
+ gemspec path: '../'
@@ -10,6 +10,11 @@ module Thinreports
10
10
  config_reader :type, :id
11
11
  config_reader :style
12
12
  config_checker true, :display
13
+ config_reader follow_stretch: %w[follow-stretch]
14
+
15
+ def affect_bottom_margin?
16
+ attributes.fetch('affect-bottom-margin', true)
17
+ end
13
18
  end
14
19
  end
15
20
  end
@@ -4,7 +4,7 @@ module Thinreports
4
4
  module Core
5
5
  module Shape
6
6
  module ImageBlock
7
- TYPE_NAME = 'image-block'.freeze
7
+ TYPE_NAME = 'image-block'
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module Thinreports
4
4
  module Core
5
5
  module Shape
6
6
  module List
7
- TYPE_NAME = 'list'.freeze
7
+ TYPE_NAME = 'list'
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module Thinreports
4
4
  module Core
5
5
  module Shape
6
6
  module PageNumber
7
- TYPE_NAME = 'page-number'.freeze
7
+ TYPE_NAME = 'page-number'
8
8
  end
9
9
  end
10
10
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Thinreports
4
+ module Core
5
+ module Shape
6
+ module StackView
7
+ class Format < Basic::Format
8
+ attr_reader :rows
9
+
10
+ def initialize(*)
11
+ super
12
+ initialize_rows
13
+ end
14
+
15
+ private
16
+
17
+ def initialize_rows
18
+ @rows = []
19
+ attributes['rows'].each do |row|
20
+ @rows << StackView::RowFormat.new(row)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Thinreports
4
+ module Core
5
+ module Shape
6
+ module StackView
7
+ class Interface < Basic::Interface
8
+ private
9
+
10
+ def init_internal(parent, format)
11
+ StackView::Internal.new(parent, format)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Thinreports
4
+ module Core
5
+ module Shape
6
+ module StackView
7
+ class Internal < Basic::Internal
8
+ def initialize(parent, format)
9
+ super
10
+ @rows = []
11
+ end
12
+
13
+ attr_accessor :rows
14
+
15
+ def type_of?(type_name)
16
+ type_name == StackView::TYPE_NAME
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Thinreports
4
+ module Core
5
+ module Shape
6
+ module StackView
7
+ class RowFormat < Core::Format::Base
8
+ config_reader :id
9
+ config_reader :height
10
+ config_checker true, :display
11
+ config_checker true, auto_stretch: 'auto-stretch'
12
+
13
+ attr_reader :items
14
+
15
+ def initialize(*)
16
+ super
17
+ @items = []
18
+ @item_with_ids = {}
19
+ initialize_items(attributes['items'])
20
+ end
21
+
22
+ def find_item(id)
23
+ @item_with_ids[id.to_sym]
24
+ end
25
+
26
+ private
27
+
28
+ def initialize_items(item_schemas)
29
+ item_schemas.each do |item_schema|
30
+ item = Core::Shape::Format(item_schema['type']).new(item_schema)
31
+ @items << item
32
+ @item_with_ids[item.id.to_sym] = item unless item.id.empty?
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Thinreports
4
+ module Core
5
+ module Shape
6
+ module StackView
7
+ TYPE_NAME = 'stack-view'.freeze
8
+ end
9
+ end
10
+ end
11
+ end
12
+
13
+ require_relative 'stack_view/format'
14
+ require_relative 'stack_view/interface'
15
+ require_relative 'stack_view/internal'
16
+
17
+ require_relative 'stack_view/row_format'
@@ -5,9 +5,12 @@ module Thinreports
5
5
  module Shape
6
6
  module Style
7
7
  class Basic < Style::Base
8
- style_accessible :visible
8
+ style_accessible :visible, :offset_x, :offset_y
9
9
  attr_accessor :visible
10
10
 
11
+ style_accessor :offset_x, 'offset-x'
12
+ style_accessor :offset_y, 'offset-y'
13
+
11
14
  def initialize(*args)
12
15
  super
13
16
  @visible = @format.display?
@@ -4,7 +4,7 @@ module Thinreports
4
4
  module Core
5
5
  module Shape
6
6
  module Text
7
- TYPE_NAME = 'text'.freeze
7
+ TYPE_NAME = 'text'
8
8
  end
9
9
  end
10
10
  end
@@ -35,7 +35,12 @@ module Thinreports
35
35
  end
36
36
 
37
37
  def number_with_delimiter(value, delimiter = ',')
38
- value.to_s.gsub(/(\d)(?=(\d{3})+(?!\d))/) { "#{$1}#{delimiter}" }
38
+ value_int, value_float = value.to_s.split('.')
39
+
40
+ [
41
+ value_int.gsub(/(\d)(?=(\d{3})+(?!\d))/) { "#{$1}#{delimiter}" },
42
+ value_float
43
+ ].compact.join('.')
39
44
  end
40
45
 
41
46
  def number_with_precision(value, precision = 3)
@@ -50,8 +50,6 @@ module Thinreports
50
50
  end
51
51
 
52
52
  def format_enabled?
53
- return false if multiple?
54
-
55
53
  if states.key?(:format_enabled)
56
54
  states[:format_enabled]
57
55
  else
@@ -4,7 +4,7 @@ module Thinreports
4
4
  module Core
5
5
  module Shape
6
6
  module TextBlock
7
- TYPE_NAME = 'text-block'.freeze
7
+ TYPE_NAME = 'text-block'
8
8
  end
9
9
  end
10
10
  end