expressive 0.0.29 → 0.0.30
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 +8 -8
- data/Gemfile.lock +1 -1
- data/lib/expressive.rb +1 -1
- data/lib/expressive/version.rb +1 -1
- data/lib/scope.rb +7 -1
- data/spec/expressive_spec.rb +59 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDExOTI2N2Y5ZGUwNTgyMmYzZjE4N2E1NDcxZDZmNjI2NjhlNjk4OQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODFkMmRkYzljNmFmZjU1NmYwNTllZDg3NTNhZDZhYTY2OWQyZTAxNA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmQ3YTBmOWEyZjYyN2YwZGZiOTRjYzY1YjFhYTU2YjJlY2JhZDhjZWI4MWRk
|
10
|
+
ZGU3MzhkZjYzOTcwM2ZmOTk3OWUwMDFmNmJiYmJjMmU2MmViZGMwNzA1MTBj
|
11
|
+
MmU3MDI2MjdiYTRlYTk3MmQ3MWZiNDQ3OTJiNWNmMGFkMTViMzU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODBjNmMwNTFhMzVlZWE1YzE3NDIxMTNlNDdkOGIyNTZkNWNjMWIzZDdkNWFh
|
14
|
+
NjE3MzlmZTNhZGQ0YTU5NmJjMWNlM2I0NjA0NzcxYTk5OTQzYzVmNjE1NGQ0
|
15
|
+
Y2I4NTlhM2Y4NTNjM2RlMDgxODVjNzJkOTg1MWJhY2NhNDEwMGE=
|
data/Gemfile.lock
CHANGED
data/lib/expressive.rb
CHANGED
@@ -20,7 +20,7 @@ module Expressive
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.all_symbols
|
23
|
-
%w(+ - * / = set sum $sub post >= > < <= and or if date datetime get put lookup $lookup $head $tail $reverse round $round $days_ago $hours_ago $minutes_ago $append $id $hash $concat $split $sms $hval)
|
23
|
+
%w(+ - * / = set sum $sub post >= > < <= and or if date datetime get put lookup $lookup $head $tail $reverse round $round $days_ago $hours_ago $minutes_ago $append $id $hash $concat $split $sms $hval $index)
|
24
24
|
end
|
25
25
|
|
26
26
|
module Boolean
|
data/lib/expressive/version.rb
CHANGED
data/lib/scope.rb
CHANGED
@@ -103,6 +103,12 @@ module Expressive
|
|
103
103
|
hash
|
104
104
|
end
|
105
105
|
|
106
|
+
syntax('$index') do |scope, cell|
|
107
|
+
data = cell[0].eval(scope)
|
108
|
+
index = cell[1].eval(scope)
|
109
|
+
data[index]
|
110
|
+
end
|
111
|
+
|
106
112
|
syntax('$hval') do |scope, cells|
|
107
113
|
key = cells[0].eval(scope)
|
108
114
|
hash = cells[1].eval(scope)
|
@@ -189,7 +195,7 @@ module Expressive
|
|
189
195
|
private
|
190
196
|
|
191
197
|
def perform_concat(scope, cells)
|
192
|
-
return cells[0].eval(scope) + cells[1].eval(scope)
|
198
|
+
return cells[0].eval(scope).to_s + cells[1].eval(scope).to_s
|
193
199
|
end
|
194
200
|
|
195
201
|
def perform_sms(scope, cells)
|
data/spec/expressive_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe "Expressive" do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
describe "all_symbols" do
|
9
|
-
it { Expressive.all_symbols.should =~ %w(+ - * / = set sum $sub get put post >= > < <= and or if date datetime lookup round $round $days_ago $hours_ago $minutes_ago $append $id $head $lookup $reverse $tail $hash $concat $split $sms $hval) }
|
9
|
+
it { Expressive.all_symbols.should =~ %w(+ - * / = set sum $sub get put post >= > < <= and or if date datetime lookup round $round $days_ago $hours_ago $minutes_ago $append $id $head $lookup $reverse $tail $hash $concat $split $sms $hval $index) }
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "understands booleans" do
|
@@ -91,6 +91,7 @@ describe "Expressive" do
|
|
91
91
|
it { Expressive.run("(= (+ 4 2) 6)").should eql true }
|
92
92
|
it { Expressive.run("(if (and (< 3 9) (> 2 1)), true, false)").should eql true }
|
93
93
|
it { Expressive.run("(if (and (< 10 9) (> 2 1)), true, false)").should eql false }
|
94
|
+
|
94
95
|
end
|
95
96
|
|
96
97
|
describe "understands conditional statements" do
|
@@ -261,7 +262,7 @@ EOH
|
|
261
262
|
|
262
263
|
describe "understands the modification of scope" do
|
263
264
|
|
264
|
-
it "
|
265
|
+
it "sets scope based off rounded equality calculation" do
|
265
266
|
@scope['total_payment_amount'] = 2.32
|
266
267
|
@scope['refund_amount'] = 2.32
|
267
268
|
@scope['payment_reconciled'] = "asdf"
|
@@ -359,6 +360,49 @@ EOH
|
|
359
360
|
|
360
361
|
end
|
361
362
|
|
363
|
+
describe "$index" do
|
364
|
+
it "generates an array" do
|
365
|
+
Expressive.run('(2 3)').should eql [2,3]
|
366
|
+
end
|
367
|
+
it "picks out correct field" do
|
368
|
+
Expressive.run('($index (2 3) 1)').should eql 3
|
369
|
+
end
|
370
|
+
|
371
|
+
it "picks correct result from calculations" do
|
372
|
+
@scope["total_payment_amount"] = 56
|
373
|
+
@scope.add_lookup_function("related_payments_count") do |options, additional_query_specs = []|
|
374
|
+
2
|
375
|
+
end
|
376
|
+
|
377
|
+
@scope.add_lookup_function("related_payments_summed") do |options, select_field, additional_query_specs = []|
|
378
|
+
200.50
|
379
|
+
end
|
380
|
+
|
381
|
+
result = Expressive.run('($index ((set total_payment_amount ($round (lookup related_payments_summed \"total_amount\") 2)) (lookup related_payments_count)) 1)', @scope)
|
382
|
+
|
383
|
+
@scope["total_payment_amount"].should == 200.50
|
384
|
+
result.should == 2
|
385
|
+
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
|
390
|
+
it "sets value and then looksup another" do
|
391
|
+
@scope["total_payment_amount"] = 56
|
392
|
+
@scope.add_lookup_function("related_payments_count") do |options, additional_query_specs = []|
|
393
|
+
2
|
394
|
+
end
|
395
|
+
|
396
|
+
@scope.add_lookup_function("related_payments_summed") do |options, select_field, additional_query_specs = []|
|
397
|
+
200.50
|
398
|
+
end
|
399
|
+
|
400
|
+
result = Expressive.run('(set total_payment_amount ($round (lookup related_payments_summed \"total_amount\") 2)) (lookup related_payments_count)', @scope)
|
401
|
+
|
402
|
+
@scope["total_payment_amount"].should == 200.50
|
403
|
+
result.should == 2
|
404
|
+
end
|
405
|
+
|
362
406
|
describe "understands adding values to lists" do
|
363
407
|
it "add a single value to a list of values" do
|
364
408
|
Expressive.run('($append participating_teams 1)', @scope)
|
@@ -394,6 +438,19 @@ EOH
|
|
394
438
|
it { Expressive.run("($minutes_ago 12)").should eql (@now - 12 * 60) }
|
395
439
|
end
|
396
440
|
|
441
|
+
describe "concat" do
|
442
|
+
it "string and number values" do
|
443
|
+
Expressive.run('($concat "ref-" 3)').should eql "ref-3"
|
444
|
+
end
|
445
|
+
|
446
|
+
it "concats from lookups" do
|
447
|
+
@scope.add_lookup_function("related_matter", case_type: "matter_case_type") do |options, select_field, additional_query_specs = []|
|
448
|
+
"value1"
|
449
|
+
end
|
450
|
+
Expressive.run('($concat "matter-" (lookup related_matter "field1"))', @scope).should eql "matter-value1"
|
451
|
+
end
|
452
|
+
|
453
|
+
end
|
397
454
|
|
398
455
|
describe "understands using lookup functions" do
|
399
456
|
it "should perform the lookup function (add account and reverse login)" do
|