parsecs 0.11.0 → 0.11.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/libnativemath/extconf.rb +1 -1
- data/lib/parsec.rb +3 -3
- data/test/test_parsec.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 947ae28755ab81d9d6c25880d3cde3c7c8e9bc2ed78bd5fbc00a170c4a8bb20a
|
4
|
+
data.tar.gz: 8ee93d06d2c715f5a3c7fdee925dd4a4a4e70c790de67674198bac3bf24ec9b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1beebe569ab892ae60faba0d8cbeaafb4ac4cc37275c6f7b46f0f9814856ff6d4b63deb6dc3ab87746edf9122861a6c68ba501e0349c2197e5276005383abcea
|
7
|
+
data.tar.gz: f8f34384386a8efac5c718e079effaef6dee23595e32c5408325d0c9c46289bfba17f7c7adf971d62af1c611d6bc127c88c3dbf6e422fcb86e88f76b6f7e20ee
|
@@ -38,7 +38,7 @@ libs.each do |lib|
|
|
38
38
|
end
|
39
39
|
|
40
40
|
GIT_REPOSITORY = 'https://github.com/niltonvasques/equations-parser.git'.freeze
|
41
|
-
COMMIT = '
|
41
|
+
COMMIT = 'b011ace5697fa65eade579f1c85aa38fd1fb816d'.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.11.
|
9
|
+
VERSION = '0.11.3'.freeze
|
10
10
|
|
11
11
|
# evaluates the equation and returns only the result
|
12
12
|
def self.eval_equation(equation)
|
@@ -49,7 +49,7 @@ module Parsec
|
|
49
49
|
|
50
50
|
# The following regex remove all spaces that are not between quot marks
|
51
51
|
# https://tinyurl.com/ybc7bng3
|
52
|
-
equation = equation.gsub(/( |(".*?"))/, '\\2') if new_line == true
|
52
|
+
equation = equation.gsub(/( |(".*?[^\\]"))/, '\\2') if new_line == true
|
53
53
|
|
54
54
|
equation
|
55
55
|
end
|
@@ -65,7 +65,7 @@ module Parsec
|
|
65
65
|
when 'int' then return ans['value'].to_i
|
66
66
|
when 'float' then return ans['value'].to_f
|
67
67
|
when 'boolean' then return ans['value'].to_bool
|
68
|
-
when 'string' then return error_check(ans['value'])
|
68
|
+
when 'string' then return error_check(ans['value'].force_encoding(Encoding::UTF_8))
|
69
69
|
when 'complex' then return 'complex number' # Maybe future implementation
|
70
70
|
when 'matrix' then return 'matrix value' # Maybe future implementation
|
71
71
|
end
|
data/test/test_parsec.rb
CHANGED
@@ -56,6 +56,7 @@ class TestParsec < Minitest::Test
|
|
56
56
|
assert_equal('TEST STRING', parser.eval_equation('toupper("test string")'))
|
57
57
|
assert_equal('test string', parser.eval_equation('tolower("TEST STRING")'))
|
58
58
|
assert_equal('Hello World', parser.eval_equation('concat("Hello ", "World")'))
|
59
|
+
assert_equal('tes t "str \" " ing equa " tion', parser.eval_equation('concat(concat("tes t", " \\"str \\\\\" \\" ing "),string("equa \\" tion"))'))
|
59
60
|
assert_equal(5, parser.eval_equation('str2number("5")'))
|
60
61
|
assert_equal(5, parser.eval_equation('number("5")'))
|
61
62
|
assert_equal('Hello', parser.eval_equation('left("Hello World", 5)'))
|
@@ -70,6 +71,7 @@ class TestParsec < Minitest::Test
|
|
70
71
|
assert_equal(false, parser.eval_equation('contains("1234567", "789")'))
|
71
72
|
assert_equal(true, parser.eval_equation('contains("2019-01-01T:08:30", "2019-01-01")'))
|
72
73
|
assert_equal(false, parser.eval_equation('contains("2019-01-01T:08:30", "2021-01-01")'))
|
74
|
+
assert_equal('Maçã', parser.eval_equation('"Maçã"'))
|
73
75
|
assert_raises(SyntaxError) { parser.eval_equation('contains(1234567, "789")') }
|
74
76
|
assert_raises(SyntaxError) { parser.eval_equation('contains("hello", 2.2)') }
|
75
77
|
assert_raises(SyntaxError) { parser.eval_equation_with_type('link()') }
|
@@ -84,6 +86,7 @@ class TestParsec < Minitest::Test
|
|
84
86
|
assert_equal('test lowercase', parser.eval_equation('tolower("TEST LOWERCASE")'))
|
85
87
|
assert_equal('Hello', parser.eval_equation('left("Hello World", 5)'))
|
86
88
|
assert_equal('World', parser.eval_equation('right("Hello World", 5)'))
|
89
|
+
assert_equal('Hello World', parser.eval_equation('right("Hello World", 20)'))
|
87
90
|
end
|
88
91
|
|
89
92
|
def test_general_equations
|
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.11.
|
4
|
+
version: 0.11.3
|
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:
|
13
|
+
date: 2022-09-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: minitest
|