parsecs 0.13.1 → 0.14.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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/parsec.rb +1 -1
  3. data/test/test_parsec.rb +19 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73ce5ab42330d07261fea6366c8447a84d42f122fd1e17ed5f5dfe2e5ae1b98a
4
- data.tar.gz: 2fa1abbbd7c774413ba865cc323a8af10aba334ecce37d20253e9d66ddb4044a
3
+ metadata.gz: dcff970a8a22bc17b6529f2f57f463615649317c0e19d31dcdbf1cff4d715c66
4
+ data.tar.gz: cc5851bd3fe8282a0abfea7243712fe5c10bceda40ea9c3ed9bd0860607b84ae
5
5
  SHA512:
6
- metadata.gz: 7651ae914b16c18d89fddd909198139dead5b7bacb90fd7a8e01825785e45cef76cedccc9ea3d4fab937f2928a478fb7c6a526cbfeaeccfe3f1531a00b463139
7
- data.tar.gz: 1fcd74afb483205737096788c793da50158ab610e8a641fa168b5066cb6d34dde928ad6cfacb21ce68cc4e3cd483a32617f252ed5aa59a9b30f8cf99ead69b75
6
+ metadata.gz: 3f4bcf637585092a91fefc44d21b29b4172d353073b8df0887dfd8ca85f8e073b20d75461233ebf5fad2c76d3b036c9b564d43e6e75ea4e741f0a46ea7d9fe32
7
+ data.tar.gz: c2b62470fb930594281368d539cc8d8565b97194c3706c3f0cf4d28bf9f7da5b80b47ddbb0ae277cd9a996c669b53966e9d30f2675a945aa8398f62876634152
data/lib/parsec.rb CHANGED
@@ -6,7 +6,7 @@ module Parsec
6
6
  class Parsec
7
7
  using StringToBooleanRefinements
8
8
 
9
- VERSION = '0.13.1'.freeze
9
+ VERSION = '0.14.0'.freeze
10
10
 
11
11
  # evaluates the equation and returns only the result
12
12
  def self.eval_equation(equation)
data/test/test_parsec.rb CHANGED
@@ -372,4 +372,23 @@ class TestParsec < Minitest::Test
372
372
  assert_equal(52, parsec.eval_equation('weekyear("2027-12-31")'))
373
373
  assert_equal(53, parsec.eval_equation('weekyear("2028-01-01")'))
374
374
  end
375
+
376
+ def test_calculate
377
+ parsec = Parsec::Parsec
378
+ assert_equal('World', parsec.eval_equation('regex("Hello World", "Hello (.*)")'))
379
+ assert_equal('12', parsec.eval_equation('calculate("2+2+2*4")'))
380
+ assert_equal('16', parsec.eval_equation('calculate("(2+2)*4")'))
381
+ assert_equal('16', parsec.eval_equation('calculate("2^4")'))
382
+ assert_equal('3', parsec.eval_equation('calculate("sqrt(9)")'))
383
+ assert_equal('50', parsec.eval_equation('calculate("abs(-50)")'))
384
+ assert_equal('1', parsec.eval_equation('calculate("round(1.123)")'))
385
+ assert_equal('2019-01-04', parsec.eval_equation('calculate("add_days(\"2019-01-01\", 3)")'))
386
+ assert_equal('1', parsec.eval_equation('calculate("daysdiff(\"2019-01-01\", \"2019-01-02\")")'))
387
+ assert_equal('24', parsec.eval_equation('calculate("hoursdiff(\"2019-01-01\", \"2019-01-02\")")'))
388
+ assert_equal('higher', parsec.eval_equation('calculate("3 > 2 ? \"higher\" : \"lower\"")'))
389
+ assert_equal('lower', parsec.eval_equation('calculate("3 < 2 ? \"higher\" : \"lower\"")'))
390
+ assert_equal('One Two Three', parsec.eval_equation('calculate("concat(\"One \", concat(\"Two\", \" Three\"))")'))
391
+ assert_equal('One Two Three', parsec.eval_equation('calculate("\"One\" // \" \" // \"Two\" // \" \" // \"Three\"")'))
392
+ assert_equal('3', parsec.eval_equation('calculate("number(calculate(\"1 + 1\")) + 1")'))
393
+ end
375
394
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parsecs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nilton Vasques
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-07-24 00:00:00.000000000 Z
13
+ date: 2023-11-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: minitest