parsecs 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/parsec.rb +6 -6
- data/test/test_parsec.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95191e497a3b1574f7a3e20a500d302624ded3f11717af0cf5300c556d5e31cc
|
4
|
+
data.tar.gz: 983d7ac08769c875431ca5486ca9a349684c55042f779a91b83db60bf47a09a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff7a5a611816c7b0f7056158b1096ab69526191223cf702a738226a869db78d3992667b1c8c55f9d61e80147e5c924e5879cff518e840eab6c8408d6fb71d5d4
|
7
|
+
data.tar.gz: 6f43c0e08aea7114bb9216ac4de1528dc2aceeabc80017138ea21e6e8159585736545021b7f1e9671748279937f0822c6b08dc88097f0b17fce8332e3f4bf03b
|
data/lib/parsec.rb
CHANGED
@@ -6,7 +6,7 @@ module Parsec
|
|
6
6
|
class Parsec
|
7
7
|
using StringToBooleanRefinements
|
8
8
|
|
9
|
-
VERSION = '0.3.
|
9
|
+
VERSION = '0.3.1'.freeze
|
10
10
|
|
11
11
|
# evaluates the equation
|
12
12
|
def self.eval_equation(equation)
|
@@ -57,14 +57,14 @@ module Parsec
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def self.error_check(output)
|
60
|
-
raise SyntaxError, output.sub(
|
61
|
-
output
|
60
|
+
raise SyntaxError, output.sub(/^Error: /, '') if output.match?(/^Error:/)
|
61
|
+
output
|
62
62
|
end
|
63
63
|
|
64
64
|
def self.validate(ans, raise_error)
|
65
|
-
if (ans['type'] == 'string') && ans['value'].
|
66
|
-
raise SyntaxError, ans['value'].sub(
|
67
|
-
return ans['value'].sub(
|
65
|
+
if (ans['type'] == 'string') && ans['value'].match?(/^Error:/)
|
66
|
+
raise SyntaxError, ans['value'].sub(/^Error: /, '') if raise_error
|
67
|
+
return ans['value'].sub(/^Error: /, '')
|
68
68
|
end
|
69
69
|
true
|
70
70
|
end
|
data/test/test_parsec.rb
CHANGED
@@ -63,6 +63,7 @@ class TestParsec < Minitest::Test
|
|
63
63
|
|
64
64
|
def test_complex_string_manipulation
|
65
65
|
parser = Parsec::Parsec
|
66
|
+
assert_equal('string with quote"', parser.eval_equation('"string with quote\""'))
|
66
67
|
assert_equal('HELLO WORLD', parser.eval_equation('toupper(concat("hello ", "world"))'))
|
67
68
|
assert_equal('test lowercase', parser.eval_equation('tolower("TEST LOWERCASE")'))
|
68
69
|
assert_equal('Hello', parser.eval_equation('left("Hello World", 5)'))
|
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.3.
|
4
|
+
version: 0.3.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:
|
13
|
+
date: 2019-02-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: minitest
|
@@ -82,7 +82,7 @@ requirements:
|
|
82
82
|
- swig
|
83
83
|
- cmake
|
84
84
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.7.
|
85
|
+
rubygems_version: 2.7.7
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: A gem to evaluate equations using muparserx C++ library
|