parsecs 0.6.2 → 0.6.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10d47b41fa674a87e82389eb1b269e54c4c64ad02a6682708c2d2b8c970c9f29
4
- data.tar.gz: e5691c43532a99952c5e12d5f191a3f27382936b35b94f082edb087095d5938a
3
+ metadata.gz: 7e50265b6776233a62be0fc29e04ae1a74e59352fb40338b7493debc49d8debf
4
+ data.tar.gz: 3272ffdb8a3f9a31b2bb74853f0f672943a4812b729058b65c92311039fc7000
5
5
  SHA512:
6
- metadata.gz: d8ab0c269d1051285d9d562edd6a7a525278a2317c932b42033b559034420e474e72ffa9818074ea5f091e7f6e7369d63cabb8991d34a5c30c7b79d9ac3a8da4
7
- data.tar.gz: 9cf6c8c8c994f33e7c4add7f1ee86de4347512910b41cf59790aed42730d43ad369e862b11d440dc034800f0654382172fb4594bceae4e44fcb6f13b9bd31d14
6
+ metadata.gz: 202a869978505c0ba7f46528e6414bac4c157ff1343f766c6ead677690cb06a75c74e3c6fc29616bd5f8224d57657895295bfc832b24acd2c53fa1467da6e7db
7
+ data.tar.gz: 4b1318018190be70d492686f85877a2d9cf507a836e3bc8a5818c04807567581e6241ec54f12b7cdb8a5acb67601dbf59f0b3288819495759ef238322f57f7aa
@@ -38,7 +38,7 @@ libs.each do |lib|
38
38
  end
39
39
 
40
40
  GIT_REPOSITORY = 'https://github.com/niltonvasques/equations-parser.git'.freeze
41
- COMMIT = 'eae00acfc8c4ea9fb7ff16dff11e51bdd260035f'.freeze
41
+ COMMIT = '3d6c854dfd3c0ce96a4ed5464fd7139ef1f62fb9'.freeze
42
42
 
43
43
  Dir.chdir(BASEDIR) do
44
44
  system('git init')
@@ -6,7 +6,7 @@ module Parsec
6
6
  class Parsec
7
7
  using StringToBooleanRefinements
8
8
 
9
- VERSION = '0.6.2'.freeze
9
+ VERSION = '0.6.4'.freeze
10
10
 
11
11
  # evaluates the equation and returns only the result
12
12
  def self.eval_equation(equation)
@@ -116,6 +116,7 @@ class TestParsec < Minitest::Test
116
116
  def test_date_functions
117
117
  parsec = Parsec::Parsec
118
118
  assert_equal(Date.today, Date.parse(parsec.eval_equation("current_date()")))
119
+ assert_match(/^\d{4}-\d{2}-\d{2}$/, parsec.eval_equation("current_date()"))
119
120
  assert_equal(364, parsec.eval_equation('daysdiff("2018-01-01", "2018-12-31")'))
120
121
  assert_equal(365, parsec.eval_equation('daysdiff("2016-01-01", "2016-12-31")'))
121
122
  assert_equal(365, parsec.eval_equation('daysdiff("2000-01-01", "2000-12-31")'))
@@ -126,10 +127,19 @@ class TestParsec < Minitest::Test
126
127
  def test_datetime_functions
127
128
  parsec = Parsec::Parsec
128
129
  assert_equal(24, parsec.eval_equation('hoursdiff("2018-01-01", "2018-01-02")'))
130
+ assert_equal(24, parsec.eval_equation('hoursdiff("2018-01-01", "2018-1-02")'))
131
+ assert_equal(24, parsec.eval_equation('hoursdiff("2018-1-01", "2018-01-02")'))
132
+ assert_equal(24, parsec.eval_equation('hoursdiff("2018-1-01", "2018-1-02")'))
133
+ assert_equal(24, parsec.eval_equation('hoursdiff("2018-01-01", "2018-01-2")'))
134
+ assert_equal(24, parsec.eval_equation('hoursdiff("2018-01-1", "2018-01-02")'))
135
+ assert_equal(24, parsec.eval_equation('hoursdiff("2018-01-1", "2018-01-2")'))
136
+ assert_equal(24, parsec.eval_equation('hoursdiff("2018-1-1", "2018-1-2")'))
129
137
  assert_equal(288, parsec.eval_equation('hoursdiff("2019-02-01", "2019-02-13")'))
130
138
  assert_equal(4, parsec.eval_equation('hoursdiff("2019-02-01T08:00", "2019-02-01T12:00")'))
131
139
  assert_equal(28, parsec.eval_equation('hoursdiff("2019-02-01T08:00", "2019-02-02T12:00")'))
132
140
  assert_equal(3.67, parsec.eval_equation('hoursdiff("2019-02-01T08:20", "2019-02-01T12:00")'))
141
+ assert_equal(0, parsec.eval_equation('hoursdiff(current_date(), current_date())'))
142
+ assert_operator(parsec.eval_equation('hoursdiff(current_date(), "2000-01-01")'), :<, 0)
133
143
  assert_equal(0, parsec.eval_equation('hoursdiff("2018-01-01", "2018-01-01")'))
134
144
  assert_equal(-20, parsec.eval_equation('hoursdiff("2018-01-02T08:00", "2018-01-01T12:00")'))
135
145
  assert_raises(SyntaxError) { parsec.eval_equation('hoursdiff("2018-01-01", "INVALID2")') }
@@ -138,6 +148,7 @@ class TestParsec < Minitest::Test
138
148
  assert_raises(SyntaxError) { parsec.eval_equation('hoursdiff(2, 3)') }
139
149
  assert_raises(SyntaxError) { parsec.eval_equation('hoursdiff("2018-01-01", "2018-01-01T12:00")') }
140
150
  assert_raises(SyntaxError) { parsec.eval_equation('hoursdiff("2018-01-01T12:00", "2018-01-01")') }
151
+ assert_raises(SyntaxError) { parsec.eval_equation('hoursdiff(current_date(), "2010-01-01T08:30")') }
141
152
  end
142
153
 
143
154
  def test_eval_equation_with_type
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.6.2
4
+ version: 0.6.4
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: 2019-03-14 00:00:00.000000000 Z
13
+ date: 2019-03-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: minitest