dentaku 3.3.3 → 3.3.4

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: 3028783062dbbe592ef71ed7bc388e57fb3af383e8cb897893dc858c4b772f63
4
- data.tar.gz: c940b16dcfdc9e0d1658a6b38b7521e7a17882c9519a1771d4117600a614100a
3
+ metadata.gz: 59795943c781e4fff4c3ea5a33a0035e6c9ac2cf3a4671ac9105201301601b3e
4
+ data.tar.gz: cfc61c4b4e522b54754dd6c960a82bc0cddcedebe160ed111d8d68e4334b5752
5
5
  SHA512:
6
- metadata.gz: 7e9633152d5e43e11b52db3a91e8c012816c2cf956e5e3906ce2c058c44d5733fc2668d57049dbc3c44d07155c12bd3bcd8f416e4012986ddcd937bd46cae49c
7
- data.tar.gz: bf89bf9096af4720832a7c904ce981a98beb69388996a1d29b190ce279fb8248eddc56175c5cc77646a36c65a0acc78dcd6c98fffb04ad0773cae22630eb3fdd
6
+ metadata.gz: c3d96b80d7a90ecbf946311743f92ce84e04d77bbb7e0c6ac44724e0f0b479b3ce27d19d6b191381c46c27b12bd352dd8881d786500c5c666eef923126c7e577
7
+ data.tar.gz: 93a8ab932fda06e5121c98c39a8561b728da48fef9501127a218776c18d18cfd4086b5d3db938e6f8bc1bbdad59e8c3ba258b84e4d22c0ffcdd39d0d8aa20d54
@@ -1,6 +1,9 @@
1
1
  # Change Log
2
2
 
3
- ## [Unreleased]
3
+ ## [v3.3.4] 2019-11-21
4
+ - bugfix release
5
+
6
+ ## [v3.3.3] 2019-11-20
4
7
  - date / duration addition and subtraction
5
8
  - validate arity for custom functions with variable arity
6
9
  - make AST serializable with Marshal.dump
@@ -184,7 +187,8 @@
184
187
  ## [v0.1.0] 2012-01-20
185
188
  - initial release
186
189
 
187
- [Unreleased]: https://github.com/rubysolo/dentaku/compare/v3.3.2...HEAD
190
+ [v3.3.4]: https://github.com/rubysolo/dentaku/compare/v3.3.3...v3.3.4
191
+ [v3.3.3]: https://github.com/rubysolo/dentaku/compare/v3.3.2...v3.3.3
188
192
  [v3.3.2]: https://github.com/rubysolo/dentaku/compare/v3.3.1...v3.3.2
189
193
  [v3.3.1]: https://github.com/rubysolo/dentaku/compare/v3.3.0...v3.3.1
190
194
  [v3.3.0]: https://github.com/rubysolo/dentaku/compare/v3.2.1...v3.3.0
data/README.md CHANGED
@@ -284,7 +284,7 @@ using Calculator#add_functions.
284
284
  FUNCTION ALIASES
285
285
  ----------------
286
286
 
287
- Every function can be aliased by synonyms. For example, it can be useful if
287
+ Every function can be aliased by synonyms. For example, it can be useful if
288
288
  your application is multilingual.
289
289
 
290
290
  ```ruby
@@ -321,7 +321,7 @@ LICENSE
321
321
 
322
322
  (The MIT License)
323
323
 
324
- Copyright © 2012-2018 Solomon White
324
+ Copyright © 2012-2019 Solomon White
325
325
 
326
326
  Permission is hereby granted, free of charge, to any person obtaining a copy of
327
327
  this software and associated documentation files (the ‘Software’), to deal in
@@ -1,10 +1,6 @@
1
1
  module Dentaku
2
2
  module AST
3
3
  class CaseElse < Node
4
- def self.arity
5
- 1
6
- end
7
-
8
4
  def initialize(node)
9
5
  @node = node
10
6
  end
@@ -16,6 +12,18 @@ module Dentaku
16
12
  def dependencies(context = {})
17
13
  @node.dependencies(context)
18
14
  end
15
+
16
+ def self.arity
17
+ 1
18
+ end
19
+
20
+ def self.min_param_count
21
+ 1
22
+ end
23
+
24
+ def self.max_param_count
25
+ 1
26
+ end
19
27
  end
20
28
  end
21
29
  end
@@ -16,6 +16,14 @@ module Dentaku
16
16
  def self.arity
17
17
  1
18
18
  end
19
+
20
+ def self.min_param_count
21
+ 1
22
+ end
23
+
24
+ def self.max_param_count
25
+ 1
26
+ end
19
27
  end
20
28
  end
21
29
  end
@@ -1,10 +1,6 @@
1
1
  module Dentaku
2
2
  module AST
3
3
  class CaseThen < Node
4
- def self.arity
5
- 1
6
- end
7
-
8
4
  def initialize(node)
9
5
  @node = node
10
6
  end
@@ -16,6 +12,18 @@ module Dentaku
16
12
  def dependencies(context = {})
17
13
  @node.dependencies(context)
18
14
  end
15
+
16
+ def self.arity
17
+ 1
18
+ end
19
+
20
+ def self.min_param_count
21
+ 1
22
+ end
23
+
24
+ def self.max_param_count
25
+ 1
26
+ end
19
27
  end
20
28
  end
21
29
  end
@@ -1,10 +1,6 @@
1
1
  module Dentaku
2
2
  module AST
3
3
  class CaseWhen < Operation
4
- def self.arity
5
- 1
6
- end
7
-
8
4
  def initialize(node)
9
5
  @node = node
10
6
  end
@@ -16,6 +12,18 @@ module Dentaku
16
12
  def dependencies(context = {})
17
13
  @node.dependencies(context)
18
14
  end
15
+
16
+ def self.arity
17
+ 1
18
+ end
19
+
20
+ def self.min_param_count
21
+ 1
22
+ end
23
+
24
+ def self.max_param_count
25
+ 1
26
+ end
19
27
  end
20
28
  end
21
29
  end
@@ -39,6 +39,14 @@ module Dentaku
39
39
  end
40
40
 
41
41
  class Right < Base
42
+ def self.min_param_count
43
+ 2
44
+ end
45
+
46
+ def self.max_param_count
47
+ 2
48
+ end
49
+
42
50
  def initialize(*args)
43
51
  super
44
52
  @string, @length = *@args
@@ -53,6 +61,14 @@ module Dentaku
53
61
  end
54
62
 
55
63
  class Mid < Base
64
+ def self.min_param_count
65
+ 3
66
+ end
67
+
68
+ def self.max_param_count
69
+ 3
70
+ end
71
+
56
72
  def initialize(*args)
57
73
  super
58
74
  @string, @offset, @length = *@args
@@ -69,6 +85,14 @@ module Dentaku
69
85
  end
70
86
 
71
87
  class Len < Base
88
+ def self.min_param_count
89
+ 1
90
+ end
91
+
92
+ def self.max_param_count
93
+ 1
94
+ end
95
+
72
96
  def initialize(*args)
73
97
  super
74
98
  @string = @args[0]
@@ -85,6 +109,14 @@ module Dentaku
85
109
  end
86
110
 
87
111
  class Find < Base
112
+ def self.min_param_count
113
+ 2
114
+ end
115
+
116
+ def self.max_param_count
117
+ 2
118
+ end
119
+
88
120
  def initialize(*args)
89
121
  super
90
122
  @needle, @haystack = *@args
@@ -104,6 +136,14 @@ module Dentaku
104
136
  end
105
137
 
106
138
  class Substitute < Base
139
+ def self.min_param_count
140
+ 3
141
+ end
142
+
143
+ def self.max_param_count
144
+ 3
145
+ end
146
+
107
147
  def initialize(*args)
108
148
  super
109
149
  @original, @search, @replacement = *@args
@@ -137,6 +177,14 @@ module Dentaku
137
177
  end
138
178
 
139
179
  class Contains < Base
180
+ def self.min_param_count
181
+ 2
182
+ end
183
+
184
+ def self.max_param_count
185
+ 2
186
+ end
187
+
140
188
  def initialize(*args)
141
189
  super
142
190
  @needle, @haystack = *args
@@ -1,3 +1,3 @@
1
1
  module Dentaku
2
- VERSION = "3.3.3"
2
+ VERSION = "3.3.4"
3
3
  end
@@ -663,6 +663,16 @@ describe Dentaku::Calculator do
663
663
  calculator.evaluate('CONCAT(s1, s2, s3)', 's1' => 'ab', 's2' => 'cd', 's3' => 'ef')
664
664
  ).to eq('abcdef')
665
665
  end
666
+
667
+ it 'manipulates string arguments' do
668
+ expect(calculator.evaluate("left('ABCD', 2)")).to eq('AB')
669
+ expect(calculator.evaluate("right('ABCD', 2)")).to eq('CD')
670
+ expect(calculator.evaluate("mid('ABCD', 2, 2)")).to eq('BC')
671
+ expect(calculator.evaluate("len('ABCD')")).to eq(4)
672
+ expect(calculator.evaluate("find('BC', 'ABCD')")).to eq(2)
673
+ expect(calculator.evaluate("substitute('ABCD', 'BC', 'XY')")).to eq('AXYD')
674
+ expect(calculator.evaluate("contains('BC', 'ABCD')")).to be_truthy
675
+ end
666
676
  end
667
677
 
668
678
  describe 'zero-arity functions' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dentaku
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.3
4
+ version: 3.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solomon White
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-20 00:00:00.000000000 Z
11
+ date: 2019-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codecov