parsecs 0.3.0 → 0.3.1

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 +6 -6
  3. data/test/test_parsec.rb +1 -0
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c5932197c66e314ab693098dafac733c00e90a09ae6c66b3a7844442f44ac45
4
- data.tar.gz: 0faf4c2409610597a83a926cec68368f136ffe5bba7e3e6ea77b37a77e8565bd
3
+ metadata.gz: 95191e497a3b1574f7a3e20a500d302624ded3f11717af0cf5300c556d5e31cc
4
+ data.tar.gz: 983d7ac08769c875431ca5486ca9a349684c55042f779a91b83db60bf47a09a7
5
5
  SHA512:
6
- metadata.gz: 84bd18f908d650b0ef144d5ecf1e8718ce427347fff25366362074c9f79bc9301e41c2875e00f8fd8a2d0779a0cfe89fa12f978c67f4d40000a2af03931a4f0c
7
- data.tar.gz: 3b76fbb9f486ea46bdd803c49313355938c23f12e6775359a19ff21cbfe0e8e6652df68b042474c8d6e10ddc3b8a94bfe8842e7b8b8355367702966da9512d5c
6
+ metadata.gz: ff7a5a611816c7b0f7056158b1096ab69526191223cf702a738226a869db78d3992667b1c8c55f9d61e80147e5c924e5879cff518e840eab6c8408d6fb71d5d4
7
+ data.tar.gz: 6f43c0e08aea7114bb9216ac4de1528dc2aceeabc80017138ea21e6e8159585736545021b7f1e9671748279937f0822c6b08dc88097f0b17fce8332e3f4bf03b
@@ -6,7 +6,7 @@ module Parsec
6
6
  class Parsec
7
7
  using StringToBooleanRefinements
8
8
 
9
- VERSION = '0.3.0'.freeze
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('Error: ', '') if output.include?('Error')
61
- output.delete('\"')
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'].include?('Error: ')
66
- raise SyntaxError, ans['value'].sub('Error: ', '') if raise_error
67
- return ans['value'].sub('Error: ', '')
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
@@ -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.0
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: 2018-10-04 00:00:00.000000000 Z
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.6
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