parsecs 0.11.8 → 0.12.0

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: 3a0df3c2ed8d2fa27bd7a7ce5c5e22731fcfb2c73b8c01deb9d1f4c091bf82b5
4
- data.tar.gz: 50ceb63aff90ee7b0d0b5d4246f848c85483703fca61ffae802bc02dbd65dec9
3
+ metadata.gz: e28378b87ca822e69e9a4d48db13bc3431acdb16a9f48093e2e04129764678ec
4
+ data.tar.gz: f1cad169c966b3fada82a0e8d755f61cd6a5e0eb6edf295475afca6e85b2bbb1
5
5
  SHA512:
6
- metadata.gz: c1f5c106772992da64362a542f8cff3476ce395445d3a187e13caba4827b45e28990291fdff3a4fa96d9c86ed9261c6b56862db60d8836044c1da11b9b45eac5
7
- data.tar.gz: 8ff45afe12a9a67abd5d562ba860c9b0ebfa4da284bbdcaa4bd4d61629c1815914f1ed73308d0306cb9dc99f7e9cf9879b379dd861543cc875a674b0787db323
6
+ metadata.gz: d05f4661a50c11d978292731897d993797c9bccc1900633980f891758ce4562fbab528b7b90491c9f3cebd209dd3f0d9b3574186c267b8aec3e2a1aa9eb1b437
7
+ data.tar.gz: ea4b8885920feaefe1fc631f30a7253c30bf99c5ee0b141c6c1c62a6ff257eec8b126efd0cd61866297783f0751b9c3a0ed9342e76b868eb75cefa9ea91e1c0d
@@ -37,8 +37,8 @@ libs.each do |lib|
37
37
  $LOCAL_LIBS << "#{lib} "
38
38
  end
39
39
 
40
- GIT_REPOSITORY = 'https://github.com/niltonvasques/equations-parser.git'.freeze
41
- COMMIT = '8c4fab5b8949704cf4d80d4a4a898f451cbb3890'.freeze
40
+ GIT_REPOSITORY = 'https://github.com/oxeanbits/equations-parser.git'.freeze
41
+ COMMIT = '8769175390cafd9c40b52477f1c97184266c4a68'.freeze
42
42
 
43
43
  Dir.chdir(BASEDIR) do
44
44
  system('git init')
@@ -64,10 +64,17 @@ unless File.exist?("#{MUPARSER_LIB}/libmuparserx.a")
64
64
  abort 'libmuparserx.a is missing.'
65
65
  end
66
66
 
67
- create_makefile('ext/libnativemath/libnativemath')
67
+ if RUBY_VERSION >= '3.2'
68
+ create_makefile('../ext/libnativemath')
69
+ else
70
+ create_makefile('ext/libnativemath/libnativemath')
71
+ end
68
72
 
69
73
  Dir.chdir(BASEDIR) do
70
74
  Dir.chdir('ext/libnativemath/') do
71
75
  system('make')
76
+ if RUBY_VERSION >= '3.2'
77
+ FileUtils.cp('libnativemath.so', '../../lib/')
78
+ end
72
79
  end
73
80
  end
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.8'.freeze
9
+ VERSION = '0.11.9'.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
@@ -302,4 +302,40 @@ class TestParsec < Minitest::Test
302
302
  assert_raises(SyntaxError) { parsec.eval_equation('timediff("02:00:00", "02:30:62")') }
303
303
  assert_raises(SyntaxError) { parsec.eval_equation('timediff("24:00:00", "02:30:59")') }
304
304
  end
305
+
306
+ def test_regex
307
+ parsec = Parsec::Parsec
308
+ assert_equal('World', parsec.eval_equation('regex("Hello World", "Hello (.*)")'))
309
+ assert_equal('71', parsec.eval_equation('regex("71 123456789", "([0-9]{2}) [0-9]{9}")'))
310
+ assert_equal('ISSUE-123', parsec.eval_equation('regex("ISSUE-123 Fix bug", "(ISSUE-[0-9]+) (.*)")'))
311
+ assert_equal('2019-01-01', parsec.eval_equation('regex("2019-01-01T:08:30", "([0-9]{4}-[0-9]{2}-[0-9]{2})T:[0-9]{2}:[0-9]{2}")'))
312
+ assert_equal('2019-01', parsec.eval_equation('regex("2019-01-01T:08:30", "([0-9]{4}-[0-9]{2})-[0-9]{2}T:[0-9]{2}:[0-9]{2}")'))
313
+ assert_equal('2019', parsec.eval_equation('regex("2019-01-01T:08:30", "([0-9]{4})-[0-9]{2}-[0-9]{2}T:[0-9]{2}:[0-9]{2}")'))
314
+ # Regex tests with no capture group
315
+ assert_equal('', parsec.eval_equation('regex("Hello World", "Hello .*")'))
316
+
317
+ # Regex tests with optional groups
318
+ assert_equal('1234', parsec.eval_equation('regex("Product 1234 (color: red)", "Product ([0-9]+)( \\\\(color: (.*)\\\\))?")'))
319
+ assert_equal('1234', parsec.eval_equation('regex("Product 1234", "Product ([0-9]+)( \\\\(color: (.*)\\\\))?")'))
320
+
321
+ # Regex tests with alternation
322
+ assert_equal('Green', parsec.eval_equation('regex("Green Apple", "(Green|Red) Apple")'))
323
+ assert_equal('Red', parsec.eval_equation('regex("Red Apple", "(Green|Red) Apple")'))
324
+
325
+ # Regex tests with character classes
326
+ assert_equal('A123', parsec.eval_equation('regex("BoxA123", "Box([A-Za-z][0-9]+)")'))
327
+ assert_equal('C456', parsec.eval_equation('regex("BoxC456", "Box([A-Za-z][0-9]+)")'))
328
+
329
+ # Regex tests with positive lookaheads
330
+ assert_equal('apple', parsec.eval_equation('regex("apple123banana", "([a-z]+)(?=\\\\d+)")'))
331
+
332
+ assert_equal('456', parsec.eval_equation('regex("123red456blue", "(\\\\d+)(?=blue)")'))
333
+
334
+ # Regex tests with negative lookaheads
335
+ assert_equal('123', parsec.eval_equation('regex("123red456blue", "(\\\\d+)(?!blue)")'))
336
+
337
+ # Regex tests with nested lookaheads
338
+ assert_equal('apple', parsec.eval_equation('regex("apple123redbanana", "(?=apple)([a-z]+)(?=\\\\d+red)")'))
339
+ assert_equal('apple', parsec.eval_equation('regex("apple123red456banana", "(?=apple)([a-z]+)(?=(\\\\d+red)\\\\d+banana)")'))
340
+ end
305
341
  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.11.8
4
+ version: 0.12.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: 2023-01-20 00:00:00.000000000 Z
13
+ date: 2023-04-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: minitest
@@ -40,7 +40,7 @@ dependencies:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '12.1'
43
- description: ParseCs is a gem to evaluate equations using a lighter and extented version
43
+ description: Parsecs is a gem to evaluate equations using a lighter and extented version
44
44
  of the muparserx C++ library
45
45
  email:
46
46
  - nilton.vasques@gmail.com
@@ -58,7 +58,7 @@ files:
58
58
  - lib/parsec.rb
59
59
  - lib/string_to_boolean_refinements.rb
60
60
  - test/test_parsec.rb
61
- homepage: https://github.com/niltonvasques/parsec
61
+ homepage: https://github.com/oxeanbits/parsec
62
62
  licenses:
63
63
  - MIT
64
64
  metadata: {}
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - swig
83
83
  - cmake
84
- rubygems_version: 3.0.9
84
+ rubygems_version: 3.4.10
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: A gem to evaluate equations using muparserx C++ library