repolho 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3e4934d30d047214771997a27514e112e4fdeb21f7eed8aacb708780faef774
4
- data.tar.gz: 0c3a81c167092259ca264d0b79187223686ad1057a42bd09c619539d8822f2a4
3
+ metadata.gz: 60d2951254acb9e8431cbda5c6710c74959759ddbeadff1b2d2f1e60fe4d9da6
4
+ data.tar.gz: 8b98f398503e47af413bfc9d4d5dc5a32c287946920b9be75cfd8db7f8f1cef2
5
5
  SHA512:
6
- metadata.gz: 628f99c9f6b261d09197974030b9d9e733914fe531762bed01ec524ed1c7f803d84efb5726dd67965aa7fbf3e3e87b80677eede46e941e7ef12e25a6f5046114
7
- data.tar.gz: 891ede10e5b285ac7bd809b805fc7a3cbaecf432f5ed9c737cf63a986ef59ced396fa35b6172128d50bc696e13bbabdf580ef77210733ea120311a4572147314
6
+ metadata.gz: f5b1f71c5f938aac694b6788d025e6965acea778c06f83c99f0159b093c562a2c10977f3987236b39f8c93918d780fe5500f04e34d5b88da484eccda7f931fe5
7
+ data.tar.gz: 76d0fabef7c98d14940ae9e9c0cbd1e9a5d5cbe396cc12412ed12d5748a2944c81b2c52db26df8801f653ab3ae7e761bb48f0596a85a0befa721dced04b0f17e
checksums.yaml.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -58,7 +58,7 @@ sections). Everything inside the custom elements is processed as ERB.
58
58
 
59
59
  | Element | Purpose | Attributes |
60
60
  |---------|---------|------------|
61
- | `<report>` | Root container of the report | `pagination` (optional, `"true"`): enables client-side page navigation. Also accepts `pagination-first`, `pagination-prev`, `pagination-next`, `pagination-last` for custom labels. |
61
+ | `<report>` | Root container of the report | `pagination` (optional, `"true"`): enables client-side page navigation. Also accepts `pagination-first`, `pagination-prev`, `pagination-next`, `pagination-last` for custom labels.<br>`orientation` (optional, `"portrait"` or `"landscape"`): page orientation for print.<br>`paper` (optional, e.g. `"A4"`, `"Letter"`): paper size for print. If either is present, a `@media print` style is injected at the end of `<body>`. |
62
62
  | `<report-page>` | Defines a page (required, only one) | `rows` (required): max data rows per page |
63
63
  | `<report-group>` | Nested grouping | `id` (required), `attr` (required), `reprint-header-on-page-break` (optional, `"true"`) |
64
64
  | `<report-header>` | Header of the current container | — |
data/lib/repolho/main.rb CHANGED
@@ -77,6 +77,8 @@ module Repolho
77
77
  @after = ""
78
78
  @body = ""
79
79
  @pagination = false
80
+ @orientation = nil
81
+ @paper = nil
80
82
  @pagination_labels = {
81
83
  first: "First",
82
84
  prev: "<",
@@ -124,6 +126,15 @@ module Repolho
124
126
  end
125
127
  end
126
128
 
129
+ css = print_css
130
+ if css
131
+ if after_content =~ /<\/body>/i
132
+ after_content = after_content.sub(/<\/body>/i, "#{css}</body>")
133
+ else
134
+ after_content += css
135
+ end
136
+ end
137
+
127
138
  @page.append_raw(after_content)
128
139
  end
129
140
 
@@ -136,6 +147,25 @@ module Repolho
136
147
  @page.instance_variable_set(:@pagination_last, @pagination_labels[:last])
137
148
  end
138
149
 
150
+ def print_css
151
+ return nil unless @orientation || @paper
152
+
153
+ size_parts = []
154
+ size_parts << @paper if @paper
155
+ size_parts << @orientation if @orientation
156
+ size = size_parts.join(" ")
157
+
158
+ <<~HTML
159
+ <style>
160
+ @media print {
161
+ @page {
162
+ size: #{size};
163
+ }
164
+ }
165
+ </style>
166
+ HTML
167
+ end
168
+
139
169
  def make_columns
140
170
  return [] if @data.empty?
141
171
 
@@ -199,6 +229,8 @@ module Repolho
199
229
 
200
230
  report_node = report.first
201
231
  @pagination = report_node["pagination"] == "true"
232
+ @orientation = report_node["orientation"]&.downcase
233
+ @paper = report_node["paper"]
202
234
 
203
235
  if @pagination
204
236
  @pagination_labels[:first] = report_node["pagination-first"] if report_node["pagination-first"]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Repolho
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repolho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eustáquio Rangel
metadata.gz.sig CHANGED
@@ -1,5 +1 @@
1
- {�A���2VVQ���u��3�j�r����c=ed)A�h�rqs��d�|�3�a:|�Ck�v�r�z��0�g18\�)�d��b�Aۻ�rrk'ٞ/;yB��-�n){\�zd��b�O�H�ZN��������q��~R���0��� 2���|h�/�~�KY�ڍI�Rx��/d�����f�x&�I�3)����x��?�z�������?�6^�
2
- f����i��Ĕ�6;h�K���1Y'����
3
- ��8s<NB|��
4
- �X�0��q|��� c�.0P8����
5
- �/
1
+ �i��tٗ.U�ג���Έ+{��Ws�����N���pX��U�s\̴ڈa�@s|.����%���LT$|�\��J�[+3�\A����MV��(�����y��۫�uv����-�2��(�:��KdKRZf��hʹ���8[�ό���'����q6��� �Wt#'!5���E��,I.Zo_7����vO�A��B�h��e���u�.ȟ��*%�zɳ��O I�#^��Ӥ(~Fӗ�.�:[F�L���:�`��Ld�!θ���y��\hø�(�[}G�?���p��eST�2��?���E�t�T�^�2v? ����������G`M ������/�}Ce�a��fz���<>]��_�����{���je�����/AH�7*