parsecs 0.14.2 → 0.15.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 054f39cf1102392e9a7903764bfa7626aaec090208c9f519d5976e77cd740040
4
- data.tar.gz: 924762e77fe847835dec7791e36f8c3b8ba30bb9d09bbd4a8ea074b037d3927b
3
+ metadata.gz: 708c8a4ef36a74b4387eaae39b32ba1521fcbf0c4eb9745afee00f0f47772e54
4
+ data.tar.gz: 8299e287f8d18fd2683f44b8001150dc3040c511a44f0ef5a57f1eb6e7649a29
5
5
  SHA512:
6
- metadata.gz: a301312a251e8aa72c3292a2f434e0c6be5533f139c0bbdb1bef98c68c9e03daf4688d48bf82b95f4b9d4d19191538d8940039aa3253e5e5ebda2dfbb15ae4c4
7
- data.tar.gz: dd656c5fa68824cd0b83cc25fe8745e42a240088714bbb2a3dd56e6b749bd372cdff9404aa13ff1199e9bc82677eaf2fffb843bc46cd889b30a39cf8598aa878
6
+ metadata.gz: c4c931d2f8af9511b066e208cf3ed901b20e392bc30cfc083a1dfdd544e9c9df106a0dff8b1504ceadbf8c113679e7dc934867f19b41a01edad286c06f7563e5
7
+ data.tar.gz: e605c53da99a29147b6d5ca609179612a40d5b7cb99789efff0b83482a21581ad379fc9309a659211378c7883b87296646580d659104da287c279031a4c3c90b
@@ -38,7 +38,7 @@ libs.each do |lib|
38
38
  end
39
39
 
40
40
  GIT_REPOSITORY = 'https://github.com/oxeanbits/equations-parser.git'.freeze
41
- COMMIT = 'a210f5def5048ddd8e9095adeccfc27f39dd7811'.freeze
41
+ COMMIT = 'ec64e60b8cd11299c2237b13630801f79a1954c1'.freeze
42
42
 
43
43
  Dir.chdir(BASEDIR) do
44
44
  system('git init')
data/lib/parsec.rb CHANGED
@@ -6,7 +6,7 @@ module Parsec
6
6
  class Parsec
7
7
  using StringToBooleanRefinements
8
8
 
9
- VERSION = '0.14.2'.freeze
9
+ VERSION = '0.15.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
@@ -38,6 +38,22 @@ class TestParsec < Minitest::Test
38
38
  assert_equal(4.56, parser.eval_equation('round_decimal(4.559, 2)'))
39
39
  end
40
40
 
41
+ def test_round_with_optional_direction
42
+ parser = Parsec::Parsec
43
+
44
+ assert_equal(10, parser.eval_equation('round(10.1)'))
45
+ assert_equal(11, parser.eval_equation('round(10.1, "up")'))
46
+ assert_equal(10, parser.eval_equation('round(10.9, "down")'))
47
+ assert_equal(-10, parser.eval_equation('round(-10.9, "up")'))
48
+ assert_equal(-11, parser.eval_equation('round(-10.1, "down")'))
49
+
50
+ assert_equal(4.63, parser.eval_equation('round_decimal(4.621, 2, "up")'))
51
+ assert_equal(4.62, parser.eval_equation('round_decimal(4.629, 2, "down")'))
52
+
53
+ assert_raises(SyntaxError) { parser.eval_equation('round(10.5, "invalid")') }
54
+ assert_raises(SyntaxError) { parser.eval_equation('round(10.5, "up", "extra")') }
55
+ end
56
+
41
57
  def test_if_then_else_equations
42
58
  parser = Parsec::Parsec
43
59
  assert_equal('bigger', parser.eval_equation('4 > 2 ? "bigger" : "smaller"'))
@@ -391,4 +407,35 @@ class TestParsec < Minitest::Test
391
407
  assert_equal('One Two Three', parsec.eval_equation('calculate("\"One\" // \" \" // \"Two\" // \" \" // \"Three\"")'))
392
408
  assert_equal('3', parsec.eval_equation('calculate("number(calculate(\"1 + 1\")) + 1")'))
393
409
  end
410
+
411
+ def test_weekday
412
+ parsec = Parsec::Parsec
413
+ assert_equal(0, parsec.eval_equation('weekday("2021-03-21")'))
414
+ assert_equal(1, parsec.eval_equation('weekday("2016-03-21")'))
415
+ assert_equal(2, parsec.eval_equation('weekday("2017-03-21")'))
416
+ assert_equal(3, parsec.eval_equation('weekday("2018-03-21")'))
417
+ assert_equal(4, parsec.eval_equation('weekday("2019-03-21")'))
418
+
419
+ assert_equal(5, parsec.eval_equation('weekday("2014-03-21T21:03")'))
420
+ assert_equal(6, parsec.eval_equation('weekday("2015-03-21T21:03")'))
421
+
422
+ assert_equal('Søndag', parsec.eval_equation('weekday("2021-03-21", "nb")'))
423
+ assert_equal('星期一', parsec.eval_equation('weekday("2016-03-21", "zh-CN")'))
424
+ assert_equal('Mardi', parsec.eval_equation('weekday("2017-03-21", "fr-FR")'))
425
+ assert_equal('วันพุธ', parsec.eval_equation('weekday("2018-03-21", "th-TH")'))
426
+ assert_equal('Quinta-feira', parsec.eval_equation('weekday("2019-03-21", "pt-BR")'))
427
+
428
+ assert_raises(SyntaxError) { parsec.eval_equation('weekday("2019-03-21", "invalidlocale")') }
429
+ assert_raises(SyntaxError) { parsec.eval_equation('weekday("2024-32-21")') }
430
+ assert_raises(SyntaxError) { parsec.eval_equation('weekday("2024-09-17", "en", "one too many params")') }
431
+ end
432
+
433
+ def test_current_time
434
+ parsec = Parsec::Parsec
435
+ assert_raises(SyntaxError) { parsec.eval_equation('current_time("1"))') }
436
+ assert_match(/^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/, parsec.eval_equation('current_time(5)'))
437
+ assert_match(/^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/, parsec.eval_equation('current_time()'))
438
+ assert_match(/^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/, parsec.eval_equation('current_time(-3)'))
439
+ assert_match(/^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/, parsec.eval_equation('current_time(-200)'))
440
+ end
394
441
  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.14.2
4
+ version: 0.15.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: 2025-07-31 00:00:00.000000000 Z
13
+ date: 2026-09-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: minitest
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - swig
83
83
  - cmake
84
- rubygems_version: 3.1.6
84
+ rubygems_version: 3.5.22
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: A gem to evaluate equations using muparserx C++ library