repolho 0.1.2 → 0.1.3

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: 3e44c3e92b2bf34c0785294e65149968cc4f8ce0c5dd1eabd4eebdb9f200340e
4
- data.tar.gz: 4ec8fc094c8da9d07d1cac32ef07ab41908c47cb95419db424c4d8a1c9dc611a
3
+ metadata.gz: 7315e78763de32bb1edec0e9ad337fd3ce360d189bee8ad978b4305120b181bd
4
+ data.tar.gz: 50f94f0d3227d78d60da48b6e808161aae2a6445a9dbc911f3e6c4b300fb97e5
5
5
  SHA512:
6
- metadata.gz: b422a100451181e9b6bf1f96cf1fa4255be8c854677e6cb214f1149a175f464990d3b3064e3512c682cad13a8d63f191d347cac92850c5ad62bed1e458584bd9
7
- data.tar.gz: f73bc63146708f0ec37c71f5e402c39c0eadec437d6a70f784e23e1bd5b36d46f98b3b011a01f09f995ed8eca3f06ce3cd8aebfa927fe9925c16ac9ce1532fd5
6
+ metadata.gz: 6e77ee42e3d53fd9cbab4183159810e54ec3f5422ed224ec74c4e6302bdf3f41b878046e393ec5e4df536aba9322d552a20a29aa4802402224892a716a85f8c2
7
+ data.tar.gz: aa3025ab2b9e9437b0bd56307deb39215c068b65857926a1fddac26d72e87243665812e34c7ede99fea32c12f8c450246e3d5b7e1edc9af0d446dcf4a2a77eb7
checksums.yaml.gz.sig CHANGED
@@ -1 +1,3 @@
1
- ��è��ÿ��Zmj>����*O%Ɲ��X��SK�<�4X���:U H!8{;�4�)�A@�!iR3T���<c
1
+ w����9��E�=�w���"����zb����+�m�� D���ЕWm�9
2
+ ?y��U"�Ņi�&f���lft��ߌj�6%��F98��H�ljQ���Ե�J�ٍ�"�﨣�5� ??F��nE;P�
3
+ �ň�=�0H�uø��
data/README.md CHANGED
@@ -230,8 +230,62 @@ To preview the structure, rename the file to `.html` and open it in a browser
230
230
  | `count(:field)` | Number of values |
231
231
  | `number` | Current page or group number |
232
232
 
233
+ ## Rails helpers
234
+
235
+ You can make Rails view helpers available inside the ERB templates by calling
236
+ `Repolho.include_rails_helpers!`. By default it includes
237
+ `ActionView::Helpers::NumberHelper` (so you get `number_to_currency`,
238
+ `number_with_precision`, etc.).
239
+
240
+ ### Inside a Rails application
241
+
242
+ ```ruby
243
+ # config/initializers/repolho.rb
244
+ Repolho.include_rails_helpers!
245
+ ```
246
+
247
+ After that you can use the helpers normally in any template:
248
+
249
+ ```erb
250
+ <td class="text-end"><%= number_to_currency(attr(:value)) %></td>
251
+ <td><%= number_with_precision(sum(:value), precision: 2) %></td>
252
+ ```
253
+
254
+ You can also pass extra modules:
255
+
256
+ ```ruby
257
+ Repolho.include_rails_helpers!(
258
+ ActionView::Helpers::NumberHelper,
259
+ ActionView::Helpers::TextHelper
260
+ )
261
+ ```
262
+
263
+ ### Outside Rails
264
+
265
+ You need the corresponding gems and must require them before calling the method:
266
+
267
+ ```ruby
268
+ # Gemfile
269
+ gem "actionview"
270
+ # or, if you prefer the lower-level helpers:
271
+ # gem "activesupport"
272
+
273
+ require "action_view/helpers/number_helper"
274
+ Repolho.include_rails_helpers!
275
+ ```
276
+
277
+ Instance variables from the Rails view (such as `@current_template`) are not
278
+ automatically copied. Pass them explicitly through the `locals` hash:
279
+
280
+ ```ruby
281
+ Repolho::Main.new(path, data, current_template: @current_template, user: current_user)
282
+ ```
283
+
284
+ They become `@current_template` and `@user` inside the templates.
285
+
233
286
  ## Signing
234
287
 
288
+
235
289
  This gem is cryptographically signed. To verify the signature on install:
236
290
 
237
291
  ```bash
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Repolho
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/repolho.rb CHANGED
@@ -8,4 +8,17 @@ require_relative "repolho/report"
8
8
  require_relative "repolho/main"
9
9
 
10
10
  module Repolho
11
+ # Includes Rails helper modules into Container so they become available
12
+ # in ERB templates (headers, footers, rows, previous and after).
13
+ #
14
+ # By default includes ActionView::Helpers::NumberHelper.
15
+ # Pass additional modules if needed.
16
+ #
17
+ # Example:
18
+ # Repolho.include_rails_helpers!
19
+ # Repolho.include_rails_helpers!(ActionView::Helpers::NumberHelper, ActionView::Helpers::TextHelper)
20
+ def self.include_rails_helpers!(*modules)
21
+ modules = [ActionView::Helpers::NumberHelper] if modules.empty?
22
+ modules.each { |mod| Container.include(mod) }
23
+ end
11
24
  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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eustáquio Rangel
metadata.gz.sig CHANGED
Binary file