parsecs 0.11.9 → 0.13.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: 27bb96b53f0a4c2da464056a9c3f50acd53d3e00d315e960d08286a19a4d398a
4
- data.tar.gz: 174c608b61872c0d3417324a7053377826f3b679e8b80fed10519be12e32221b
3
+ metadata.gz: 5abfe818972ad4f07089bc1d4a481a7c72bc8b5afb80ee490b3b7f5150f71e49
4
+ data.tar.gz: 6a10b41f9ebf29ce4a4d4acedee12bfd09695ecea764b597b7d9b8ef40c7d1a0
5
5
  SHA512:
6
- metadata.gz: d192592844f0e597ba28ec9a8b5e3a93436731b330048fff1b235a4e9f6237174949d25f1bf7d71ba646930257b9c4bef876f7a685678b3b35b3da5575e4af2c
7
- data.tar.gz: 7452c90667c7edac02ce61c2b9f6063d64c3daf49917d4d340a38be3e33f2d13e32451ac8e39b51ca1936be1464e21d51e7be9479b1da13acf73b84b88df0442
6
+ metadata.gz: f2a8d47fa873fb8e8841cea8829d468ff06d7defeb5fb87d06e5432084b2609698550f483296252b11ae6de390cc40fe1cae842a963a293c76502af45e3e5d62
7
+ data.tar.gz: b5e0a321445cdddd9b771f7496490cd76c2a51e687b74fc0b83685eb98c4dc369b9958ff4925a41cb8331ff93f8f7e955d907764336223da9d8290627688eba6
@@ -38,7 +38,7 @@ libs.each do |lib|
38
38
  end
39
39
 
40
40
  GIT_REPOSITORY = 'https://github.com/oxeanbits/equations-parser.git'.freeze
41
- COMMIT = '8c4fab5b8949704cf4d80d4a4a898f451cbb3890'.freeze
41
+ COMMIT = 'b81e50bc4c43556f8d75566bf0f86a2e71a7ac4e'.freeze
42
42
 
43
43
  Dir.chdir(BASEDIR) do
44
44
  system('git init')
data/test/test_parsec.rb CHANGED
@@ -302,4 +302,74 @@ 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
341
+
342
+ def test_weekyear
343
+ parsec = Parsec::Parsec
344
+
345
+ # Week number of the year when 1st of January is a Sunday
346
+ assert_equal(1, parsec.eval_equation('weekyear("2023-01-01")'))
347
+ assert_equal(1, parsec.eval_equation('weekyear("2023-01-07")'))
348
+ assert_equal(2, parsec.eval_equation('weekyear("2023-01-08")'))
349
+
350
+ assert_equal(17, parsec.eval_equation('weekyear("2023-04-25")'))
351
+ assert_equal(17, parsec.eval_equation('weekyear("2023-04-29")'))
352
+ assert_equal(18, parsec.eval_equation('weekyear("2023-04-30")'))
353
+ assert_equal(18, parsec.eval_equation('weekyear("2023-05-06")'))
354
+
355
+ assert_equal(52, parsec.eval_equation('weekyear("2023-12-24")'))
356
+ assert_equal(53, parsec.eval_equation('weekyear("2023-12-31")'))
357
+
358
+ # Week number of the year a leap year
359
+ assert_equal(1, parsec.eval_equation('weekyear("2024-01-01")'))
360
+ assert_equal(1, parsec.eval_equation('weekyear("2024-01-06")'))
361
+ assert_equal(2, parsec.eval_equation('weekyear("2024-01-07")'))
362
+
363
+ assert_equal(52, parsec.eval_equation('weekyear("2024-12-22")'))
364
+ assert_equal(53, parsec.eval_equation('weekyear("2024-12-29")'))
365
+
366
+ # Week number of the year when 1st of January is friday
367
+ assert_equal(53, parsec.eval_equation('weekyear("2027-01-01")'))
368
+ assert_equal(53, parsec.eval_equation('weekyear("2027-01-02")'))
369
+ assert_equal(1, parsec.eval_equation('weekyear("2027-01-03")'))
370
+
371
+ assert_equal(52, parsec.eval_equation('weekyear("2027-12-27")'))
372
+ assert_equal(52, parsec.eval_equation('weekyear("2027-12-31")'))
373
+ assert_equal(53, parsec.eval_equation('weekyear("2028-01-01")'))
374
+ end
305
375
  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.9
4
+ version: 0.13.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-04-12 00:00:00.000000000 Z
13
+ date: 2023-04-25 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: {}