parsecs 0.13.1 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73ce5ab42330d07261fea6366c8447a84d42f122fd1e17ed5f5dfe2e5ae1b98a
4
- data.tar.gz: 2fa1abbbd7c774413ba865cc323a8af10aba334ecce37d20253e9d66ddb4044a
3
+ metadata.gz: 905bbac64279b895e489f739d6fc5171445d9a809306641a541688b525466cde
4
+ data.tar.gz: 25572af9b533b844d1f7563ee2f245fde5deab62983e1bb3625609b73654db90
5
5
  SHA512:
6
- metadata.gz: 7651ae914b16c18d89fddd909198139dead5b7bacb90fd7a8e01825785e45cef76cedccc9ea3d4fab937f2928a478fb7c6a526cbfeaeccfe3f1531a00b463139
7
- data.tar.gz: 1fcd74afb483205737096788c793da50158ab610e8a641fa168b5066cb6d34dde928ad6cfacb21ce68cc4e3cd483a32617f252ed5aa59a9b30f8cf99ead69b75
6
+ metadata.gz: 4e401c2f0242f26cb46a97041a172b2ea9e3b7632b68c1c642c8a92750d16d7f2741f9aa080fce180623eee8118c229168fef1a8d0c49115d25a3c6cad76dca3
7
+ data.tar.gz: 6c1d9c4651f4af290337952bc05c7e0625c611a44d965adcffb4c631f4d7fbb7cc85479b939d214843836d4a4b304587180d3ce07a6a6665e29a66f6e7a064ab
@@ -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 = 'b81e50bc4c43556f8d75566bf0f86a2e71a7ac4e'.freeze
41
+ COMMIT = '39d949b5f53d1650eb8f166db3883900f5ce55d4'.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.13.1'.freeze
9
+ VERSION = '0.14.1'.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.1
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-12-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: minitest