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 +4 -4
- data/ext/libnativemath/extconf.rb +10 -3
- data/lib/parsec.rb +1 -1
- data/test/test_parsec.rb +36 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e28378b87ca822e69e9a4d48db13bc3431acdb16a9f48093e2e04129764678ec
|
4
|
+
data.tar.gz: f1cad169c966b3fada82a0e8d755f61cd6a5e0eb6edf295475afca6e85b2bbb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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/
|
41
|
-
COMMIT = '
|
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
|
-
|
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
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.
|
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-
|
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:
|
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/
|
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.
|
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
|