trmnl_preview 0.34.0 → 0.34.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aac23cfaeb0042d07676cbe75bc8602bc01ccdd170bb4eb27259916d2943f401
4
- data.tar.gz: 788296f57a705b6c8eb05209f6832a7113e7af7d185df0344cce7e423fe39a8a
3
+ metadata.gz: 9080cbf504b4e74dd3f9432cb0375b8aae603c9b1143f0b62d3a3c04ce4acb10
4
+ data.tar.gz: 14e02c7381aa8f78af114a9a360d2fc81bd560300765a571456ac3c2c0823285
5
5
  SHA512:
6
- metadata.gz: 32cffa44ceca8d4417742cb902ad1f2a9bbefef3e59277a0f9b82ebe2235c0155533bbd5ce65c31b76e8c05fe5446b58940fa6b788db2a83b787b5d3148f0418
7
- data.tar.gz: f060f15b6292b85d83b5077a9584789641e28861ed956476cf4a534e8ac4aa258f9a55b4cf9f3eb3e137dc7023d7111f71cdb30be3b81f09726bc77f4f3585a7
6
+ metadata.gz: 0f8913c34e968d85bc8d6d6f5cb8c568ec17e6b9ad372c271658c928e9cac6201cd98a88a88487196aa8577e76c48e8d53a078419110edbd3abe6d2a65d62ca1
7
+ data.tar.gz: 22af8cfa7ecc90847ce83475decb253168883aec90b5368494ddadf351c8a2701d2ac6d4b0f35a6abf5899e57bfd1fc550d198829502cda802389e311383818e
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
 
2
2
  # Changelog
3
3
 
4
+ ## 0.34.1
5
+
6
+ - The `random_number` filter works in `serve`, `build`, `test` and `lint`, as on TRMNL. Before, `{{ 0 | random_number: 1, 20 }}` drew 0 on every screen, so a recipe that picks a random item drew only its first one, and lint called the filter unknown.
7
+
4
8
  ## 0.34.0
5
9
 
6
10
  - `trmnlp test --report` writes `og-vs-x-<view>.png` for the quadrant and half views too, not only `og-vs-x.png` for the full view, when the tests drew that view on TRMNL OG and TRMNL X in landscape.
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'trmnl/liquid'
4
4
 
5
+ require_relative '../../random_number'
5
6
  require_relative '../check'
6
7
 
7
8
  module TRMNLP
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+ require 'trmnl/liquid'
5
+
6
+ module TRMNLP
7
+ # TRMNL's random_number filter, merged in trmnl-liquid but not in the 0.8.2 release trmnlp needs.
8
+ module RandomNumber
9
+ def random_number(_value, min = nil, max = nil)
10
+ lower, upper = if min.nil? then [0, 100]
11
+ elsif max.nil? then [0, min.to_i]
12
+ else [min.to_i, max.to_i].minmax
13
+ end
14
+ lower + SecureRandom.random_number(upper - lower + 1)
15
+ end
16
+ end
17
+ end
18
+
19
+ TRMNL::Liquid::Filters.include(TRMNLP::RandomNumber) unless TRMNL::Liquid::Filters.method_defined?(:random_number)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TRMNLP
4
- VERSION = '0.34.0'
4
+ VERSION = '0.34.1'
5
5
  end
data/lib/trmnlp.rb CHANGED
@@ -4,6 +4,7 @@ module TRMNLP; end
4
4
  require 'oj'
5
5
  require 'trmnl/liquid'
6
6
  require_relative 'trmnlp/qr_code'
7
+ require_relative 'trmnlp/random_number'
7
8
  Oj.mimic_JSON
8
9
  require_relative 'trmnlp/rails_helpers'
9
10
  require_relative 'trmnlp/errors'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trmnl_preview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.34.0
4
+ version: 0.34.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rockwell Schrock
@@ -473,6 +473,7 @@ files:
473
473
  - lib/trmnlp/poller.rb
474
474
  - lib/trmnlp/qr_code.rb
475
475
  - lib/trmnlp/rails_helpers.rb
476
+ - lib/trmnlp/random_number.rb
476
477
  - lib/trmnlp/renderer.rb
477
478
  - lib/trmnlp/reporter.rb
478
479
  - lib/trmnlp/screen.rb