expressive 0.0.26 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/expressive.rb +1 -1
- data/lib/expressive/version.rb +1 -1
- data/lib/scope.rb +65 -4
- data/spec/expressive_spec.rb +209 -9
- metadata +5 -43
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
N2I2ZjM0OTM3MWVhMjA4OWMyNjZlOTJmOWFkNzA3M2U5NDU5ODk0NA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MDhiNjhjMjU1NWRkZGYzNmY1Y2U2ZWNjYTQ0NmUyZjI5Nzk5OTFiOQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZmM1ZGJkOTc5NjAyNTdjZjkxOTY3MWM3MTZhZmFhOTgwODU5ZDg4NDNhMTM3
|
10
|
+
YmZhZDY1YTAzMTNlM2JiZjNjMDIwOThlYTAwNWUzMGZhMGRkMjMyMDFiOWIy
|
11
|
+
Y2FhYzBhZWI4YWIzMzY3NzY2ZmE0OTgxZTBjZjhiZTg0NjFhZjM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YzkzYzUyNjI2NmU5MDc3MzdkMDI3Zjc4YjU0OTE2ZmVhMDMzNWQ2MzdiNDYw
|
14
|
+
NTVmMWRjMWQxZDI0YzQyOWNlNmMyNGZlMmZkY2M4Mjk0NTI3YTA3NDkxYTE2
|
15
|
+
MGQzYmYxZmNjMmQ0MWU0ZmIzNGQ3YTFmNGYxYjljMWY5NGE5MGM=
|
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)
|
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)
|
24
24
|
end
|
25
25
|
|
26
26
|
module Boolean
|
data/lib/expressive/version.rb
CHANGED
data/lib/scope.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Expressive
|
2
2
|
require 'json'
|
3
|
+
require "cgi"
|
3
4
|
|
4
5
|
class Scope
|
5
6
|
attr_reader :lookups
|
@@ -89,17 +90,21 @@ module Expressive
|
|
89
90
|
end
|
90
91
|
|
91
92
|
syntax('$hash') do |scope, cells|
|
92
|
-
puts "$hash..."
|
93
93
|
hash = {}
|
94
94
|
cells.each do |cell|
|
95
95
|
key = cell.elements[1].elements[0].elements[1].text_value
|
96
96
|
value = cell.elements[1].elements[1].elements[1].instance_eval{eval(scope)}
|
97
|
-
puts value.class
|
98
97
|
hash[key] = value
|
99
98
|
end
|
100
99
|
hash
|
101
100
|
end
|
102
101
|
|
102
|
+
syntax('$hval') do |scope, cells|
|
103
|
+
key = cells[0].eval(scope)
|
104
|
+
hash = cells[1].eval(scope)
|
105
|
+
hash[key]
|
106
|
+
end
|
107
|
+
|
103
108
|
syntax('$lookup') {|scope, cells| perform_lookup(scope, cells)}
|
104
109
|
syntax('lookup') {|scope, cells| perform_lookup(scope, cells)}
|
105
110
|
|
@@ -107,6 +112,18 @@ module Expressive
|
|
107
112
|
perform_webhook(:post, scope, cells)
|
108
113
|
end
|
109
114
|
|
115
|
+
syntax('$concat') do |scope, cells|
|
116
|
+
perform_concat(scope, cells)
|
117
|
+
end
|
118
|
+
|
119
|
+
syntax('$sms') do |scope, cells|
|
120
|
+
perform_sms(scope, cells)
|
121
|
+
end
|
122
|
+
|
123
|
+
syntax('$split') do |scope, cells|
|
124
|
+
perform_split(scope, cells)
|
125
|
+
end
|
126
|
+
|
110
127
|
syntax('put') do |scope, cells|
|
111
128
|
perform_webhook(:put, scope, cells)
|
112
129
|
end
|
@@ -167,6 +184,39 @@ module Expressive
|
|
167
184
|
|
168
185
|
private
|
169
186
|
|
187
|
+
def perform_concat(scope, cells)
|
188
|
+
return cells[0].eval(scope) + cells[1].eval(scope)
|
189
|
+
end
|
190
|
+
|
191
|
+
def perform_sms(scope, cells)
|
192
|
+
uri = URI.parse("http://api.clickatell.com/http/sendmsg")
|
193
|
+
|
194
|
+
query = {:user => ENV["clickatell_username"], :password => ENV["clickatell_password"], :api_id => ENV['clickatell_api_id']}
|
195
|
+
|
196
|
+
to = cells[0].eval(scope)
|
197
|
+
message = CGI.escape(cells[1].eval(scope))
|
198
|
+
if to[0] == "0"
|
199
|
+
to = "44" + to[1..-1]
|
200
|
+
elsif to[0] == "+"
|
201
|
+
to = to[1..-1]
|
202
|
+
end
|
203
|
+
query[:to] = to
|
204
|
+
query[:text] = message
|
205
|
+
uri.query = query.map{|k,v| "#{k}=#{v}"}.join("&")
|
206
|
+
begin
|
207
|
+
response = Webhook.new(:get, uri.to_s, {}, {}).execute
|
208
|
+
scope = scope.merge(response) if response.is_a?(Hash)
|
209
|
+
rescue RestClient::Exception => e
|
210
|
+
scope['_errors'] = e.message
|
211
|
+
end
|
212
|
+
scope
|
213
|
+
|
214
|
+
end
|
215
|
+
|
216
|
+
def perform_split(scope, cells)
|
217
|
+
return cells[0].elements[1].text_value.split(cells[1].elements[1].text_value)
|
218
|
+
end
|
219
|
+
|
170
220
|
#(post "http://example.com" "*" (headers "AUTH-TOKEN=13415") )
|
171
221
|
#(post "http://example.com" name email john smith (headers "AUTH-TOKEN=13415") )
|
172
222
|
def perform_round(*args)
|
@@ -190,14 +240,23 @@ module Expressive
|
|
190
240
|
|
191
241
|
def perform_webhook(verb, scope, cells)
|
192
242
|
#convert cells to array so it can manipulated easily
|
193
|
-
cells_array = cells.map{|c| c.text_value.gsub(/\A"|"\Z/, '')}
|
243
|
+
cells_array = cells.map{|c| c.eval(scope).kind_of?(Hash) || !!c.eval(scope) == c.eval(scope) ? c.eval(scope) : c.text_value.gsub(/\A"|"\Z/, '')}
|
244
|
+
if !cells_array[2].nil? and !!cells_array[2] == cells_array[2]
|
245
|
+
update_case = cells_array[2]
|
246
|
+
else
|
247
|
+
update_case = true
|
248
|
+
end
|
194
249
|
url = cells_array.shift
|
195
250
|
url = Expressive.run(url, scope) if url =~ /\A\(.*\)\Z/
|
196
251
|
headers = create_webhook_headers(cells_array)
|
197
252
|
params = create_webhook_parameters(scope, cells_array)
|
198
253
|
begin
|
199
254
|
response = Webhook.new(verb, url, params, headers).execute
|
200
|
-
|
255
|
+
if update_case
|
256
|
+
scope = scope.merge(response) if response.is_a?(Hash)
|
257
|
+
else
|
258
|
+
return response
|
259
|
+
end
|
201
260
|
rescue RestClient::Exception => e
|
202
261
|
scope['_errors'] = e.message
|
203
262
|
end
|
@@ -220,6 +279,8 @@ module Expressive
|
|
220
279
|
def create_webhook_parameters(scope, cells)
|
221
280
|
if cells.first && cells.first == '*'
|
222
281
|
scope.to_hash
|
282
|
+
elsif cells.first.kind_of? Hash
|
283
|
+
cells.first
|
223
284
|
else
|
224
285
|
cells.inject({}) do |params, key|
|
225
286
|
params[key] = scope[key]
|
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) }
|
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) }
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "understands booleans" do
|
@@ -24,15 +24,31 @@ describe "Expressive" do
|
|
24
24
|
it { Expressive.run('"hello world 2012"').should eql "hello world 2012" }
|
25
25
|
it { Expressive.run('"hello world 2.5"').should eql "hello world 2.5" }
|
26
26
|
it { Expressive.run('"hello world false"').should eql "hello world false" }
|
27
|
+
|
28
|
+
context "string manipulation" do
|
29
|
+
it {Expressive.run('($concat "hello" " world")').should eql "hello world" }
|
30
|
+
it {
|
31
|
+
@scope["scope_value"] = "world"
|
32
|
+
Expressive.run('($concat "hello " scope_value)', @scope).should eql "hello world"
|
33
|
+
}
|
34
|
+
it {Expressive.run('($split "a,b,c,d,e" ",")').should eql ['a', 'b', 'c', 'd', 'e'] }
|
35
|
+
end
|
36
|
+
|
27
37
|
end
|
28
38
|
|
29
|
-
describe "
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
39
|
+
describe "hash manipulation" do
|
40
|
+
context "hash definition" do
|
41
|
+
it { Expressive.run('($hash (test "value"))').should eql ({"test" => "value"})}
|
42
|
+
it { Expressive.run('($hash (test 5))').should eql ({"test" => 5})}
|
43
|
+
it { Expressive.run('($hash (test 5.3))').should eql ({"test" => 5.3})}
|
44
|
+
it { Expressive.run('($hash (test "value") (test2 64))').should eql ({"test" => "value", "test2" => 64})}
|
45
|
+
it { Expressive.run('($hash (test "value") (test2 (date)))').should eql ({"test" => "value", "test2" => Time.parse(Date.today.to_s).utc})}
|
46
|
+
it { Expressive.run('($hash (test "value") (test2 (date)) (key ($hash (within "a_hash"))))').should eql ({"test" => "value", "test2" => Time.parse(Date.today.to_s).utc, "key" => {"within" => "a_hash"}})}
|
47
|
+
end
|
48
|
+
|
49
|
+
context "hash value" do
|
50
|
+
it { Expressive.run('($hval "test" ($hash (test "value")))').should eql "value"}
|
51
|
+
end
|
36
52
|
end
|
37
53
|
|
38
54
|
it "understands variables" do
|
@@ -142,8 +158,85 @@ EOH
|
|
142
158
|
Expressive.run(@statement, @scope).should eql 0
|
143
159
|
end
|
144
160
|
end
|
145
|
-
end
|
146
161
|
|
162
|
+
context "multiple if statements with set" do
|
163
|
+
before do
|
164
|
+
@scope["letter_template"] = ""
|
165
|
+
@statement = <<-EOH
|
166
|
+
(set letter_001_sent (if (= letter_template "001-OFFCHA-GENERAL") "Y", letter_001_sent))
|
167
|
+
(set letter_002_sent (if (= letter_template "002-OFFCHA-NO8PCTINT") "Y", letter_002_sent))
|
168
|
+
(set letter_003_sent (if (= letter_template "003-OFFCHA-DEBTPURCH") "Y", letter_003_sent))
|
169
|
+
(set letter_004_sent (if (= letter_template "004-SIGNEDACC-CLIENT") "Y", letter_004_sent))
|
170
|
+
(set letter_005_sent (if (= letter_template "005-SIGNEDACC-LENDER") "Y", letter_005_sent))
|
171
|
+
EOH
|
172
|
+
end
|
173
|
+
it "does nothing when letter_template is nil" do
|
174
|
+
@scope["letter_template"] = be_nil
|
175
|
+
Expressive.run(@statement, @scope)
|
176
|
+
|
177
|
+
@scope["letter_001_sent"].should be_nil
|
178
|
+
@scope["letter_002_sent"].should be_nil
|
179
|
+
@scope["letter_003_sent"].should be_nil
|
180
|
+
@scope["letter_004_sent"].should be_nil
|
181
|
+
@scope["letter_005_sent"].should be_nil
|
182
|
+
end
|
183
|
+
it "does not affect existing values" do
|
184
|
+
@scope["letter_001_sent"] = "Y"
|
185
|
+
@scope["letter_template"] = "002-OFFCHA-NO8PCTINT"
|
186
|
+
Expressive.run(@statement, @scope)
|
187
|
+
@scope["letter_002_sent"].should == "Y"
|
188
|
+
@scope["letter_001_sent"].should == "Y"
|
189
|
+
@scope["letter_003_sent"].should be_nil
|
190
|
+
@scope["letter_004_sent"].should be_nil
|
191
|
+
@scope["letter_005_sent"].should be_nil
|
192
|
+
end
|
193
|
+
it "sets letter_001_sent to Y" do
|
194
|
+
@scope["letter_template"] = "001-OFFCHA-GENERAL"
|
195
|
+
Expressive.run(@statement, @scope)
|
196
|
+
@scope["letter_001_sent"].should == "Y"
|
197
|
+
@scope["letter_002_sent"].should be_nil
|
198
|
+
@scope["letter_003_sent"].should be_nil
|
199
|
+
@scope["letter_004_sent"].should be_nil
|
200
|
+
@scope["letter_005_sent"].should be_nil
|
201
|
+
end
|
202
|
+
it "sets letter_002_sent to Y" do
|
203
|
+
@scope["letter_template"] = "002-OFFCHA-NO8PCTINT"
|
204
|
+
Expressive.run(@statement, @scope)
|
205
|
+
@scope["letter_002_sent"].should == "Y"
|
206
|
+
@scope["letter_001_sent"].should be_nil
|
207
|
+
@scope["letter_003_sent"].should be_nil
|
208
|
+
@scope["letter_004_sent"].should be_nil
|
209
|
+
@scope["letter_005_sent"].should be_nil
|
210
|
+
end
|
211
|
+
it "sets letter_003_sent to Y" do
|
212
|
+
@scope["letter_template"] = "003-OFFCHA-DEBTPURCH"
|
213
|
+
Expressive.run(@statement, @scope)
|
214
|
+
@scope["letter_003_sent"].should == "Y"
|
215
|
+
@scope["letter_001_sent"].should be_nil
|
216
|
+
@scope["letter_002_sent"].should be_nil
|
217
|
+
@scope["letter_004_sent"].should be_nil
|
218
|
+
@scope["letter_005_sent"].should be_nil
|
219
|
+
end
|
220
|
+
it "sets letter_004_sent to Y" do
|
221
|
+
@scope["letter_template"] = "004-SIGNEDACC-CLIENT"
|
222
|
+
Expressive.run(@statement, @scope)
|
223
|
+
@scope["letter_004_sent"].should == "Y"
|
224
|
+
@scope["letter_001_sent"].should be_nil
|
225
|
+
@scope["letter_002_sent"].should be_nil
|
226
|
+
@scope["letter_003_sent"].should be_nil
|
227
|
+
@scope["letter_005_sent"].should be_nil
|
228
|
+
end
|
229
|
+
it "sets letter_005_sent to Y" do
|
230
|
+
@scope["letter_template"] = "005-SIGNEDACC-LENDER"
|
231
|
+
Expressive.run(@statement, @scope)
|
232
|
+
@scope["letter_005_sent"].should == "Y"
|
233
|
+
@scope["letter_001_sent"].should be_nil
|
234
|
+
@scope["letter_002_sent"].should be_nil
|
235
|
+
@scope["letter_003_sent"].should be_nil
|
236
|
+
@scope["letter_004_sent"].should be_nil
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
147
240
|
describe "understands logical statements" do
|
148
241
|
it { Expressive.run('(and true true)').should eql true }
|
149
242
|
it { Expressive.run('(and true false)').should eql false }
|
@@ -166,6 +259,14 @@ EOH
|
|
166
259
|
@scope['vsi'].should eql 'vsi1234'
|
167
260
|
end
|
168
261
|
|
262
|
+
it "using single set commands with if" do
|
263
|
+
@scope['vsi'] = 'oldvalue'
|
264
|
+
Expressive.run('(set vsi (if (= 1 2) "vsi1234", vsi))', @scope)
|
265
|
+
@scope['vsi'].should eql 'oldvalue'
|
266
|
+
Expressive.run('(set vsi (if (= 1 1) "vsi1234", vsi))', @scope).should eql "vsi1234"
|
267
|
+
@scope['vsi'].should eql 'vsi1234'
|
268
|
+
end
|
269
|
+
|
169
270
|
it "using multiple set commands" do
|
170
271
|
Expressive.run('(and (set vsi "vsi1234") (set vso "vso1234") (set vsbool true))', @scope).should eql true
|
171
272
|
@scope['vsi'].should eql 'vsi1234'
|
@@ -281,6 +382,47 @@ EOH
|
|
281
382
|
end
|
282
383
|
end
|
283
384
|
|
385
|
+
describe "understands sms statements" do
|
386
|
+
before(:each) do
|
387
|
+
ENV["clickatell_username"] = "user"
|
388
|
+
ENV["clickatell_password"] = "pass"
|
389
|
+
ENV["clickatell_api_id"] = "apiid"
|
390
|
+
@base_url = "http://api.clickatell.com/http/sendmsg?user=user&password=pass&api_id=apiid"
|
391
|
+
end
|
392
|
+
it "should call http with hardcoded text" do
|
393
|
+
|
394
|
+
end
|
395
|
+
it "should send sms based off values in case" do
|
396
|
+
@scope['mobile_phone_no'] = "447968115250"
|
397
|
+
request = stub_request(:get, @base_url + "&to=447968115250&text=this%20is%20a%20test").to_return(body: {'goodbye' => 'srsly'})
|
398
|
+
Expressive.run('($sms "447968115250" "this is a test")', @scope)
|
399
|
+
assert_requested(request)
|
400
|
+
@scope['goodbye'].should eql 'srsly'
|
401
|
+
end
|
402
|
+
it "should normalise regular phone numbers" do
|
403
|
+
@scope['mobile_phone_no'] = "07968115250"
|
404
|
+
request = stub_request(:get, @base_url + "&to=447968115250&text=this%20is%20a%20test").to_return(body: {'goodbye' => 'srsly'})
|
405
|
+
Expressive.run('($sms "447968115250" "this is a test")', @scope)
|
406
|
+
assert_requested(request)
|
407
|
+
@scope['goodbye'].should eql 'srsly'
|
408
|
+
end
|
409
|
+
it "should normalise international phone numbers" do
|
410
|
+
@scope['mobile_phone_no'] = "+447968115250"
|
411
|
+
request = stub_request(:get, @base_url + "&to=447968115250&text=this%20is%20a%20test").to_return(body: {'goodbye' => 'srsly'})
|
412
|
+
Expressive.run('($sms "447968115250" "this is a test")', @scope)
|
413
|
+
assert_requested(request)
|
414
|
+
@scope['goodbye'].should eql 'srsly'
|
415
|
+
end
|
416
|
+
it "should encode data" do
|
417
|
+
@scope['mobile_phone_no'] = "+447968115250"
|
418
|
+
request = stub_request(:get, @base_url + "&to=447968115250&text=This%20is%20you%27re%20text%20-%20it%20%26%20the%20message%20should%20be%20encoded").to_return(body: {'goodbye' => 'srsly'})
|
419
|
+
Expressive.run('($sms "447968115250" "This is you\'re text - it & the message should be encoded")', @scope)
|
420
|
+
assert_requested(request)
|
421
|
+
@scope['goodbye'].should eql 'srsly'
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
|
284
426
|
describe "understands web-hook statements" do
|
285
427
|
context "put" do
|
286
428
|
it_should_behave_like "a webhook", :put
|
@@ -312,6 +454,14 @@ EOH
|
|
312
454
|
@scope['goodbye'].should eql 'srsly'
|
313
455
|
end
|
314
456
|
|
457
|
+
it "should get with generated url" do
|
458
|
+
@scope['ohai'] = "world"
|
459
|
+
request = stub_request(:get, "www.example.com/?ohai=world").to_return(body: {'goodbye' => 'srsly'})
|
460
|
+
Expressive.run('(get ($concat "http://www.example.com/?ohai=" ohai))', @scope)
|
461
|
+
assert_requested(request)
|
462
|
+
@scope['goodbye'].should eql 'srsly'
|
463
|
+
end
|
464
|
+
|
315
465
|
it "should get with all parameters if wild card is given" do
|
316
466
|
@scope['ohai'] = "world"
|
317
467
|
@scope["monty"] = "python"
|
@@ -351,6 +501,56 @@ EOH
|
|
351
501
|
assert_requested(request)
|
352
502
|
@scope['goodbye'].should eql 'srsly'
|
353
503
|
end
|
504
|
+
|
505
|
+
it "should take a hash of values to post" do
|
506
|
+
@scope['ohai'] = "world"
|
507
|
+
@scope["monty"] = "python"
|
508
|
+
request = stub_request(:post, "www.example.com").with(body: {'param1' => 'value1', 'param2' => 'value2', 'param3' => 'value3'}).to_return(body: {'param4' => 'value4'})
|
509
|
+
Expressive.run('(post "http://www.example.com" ($hash (param1 "value1") (param2 "value2") (param3 "value3")))', @scope)
|
510
|
+
assert_requested(request)
|
511
|
+
@scope['param4'].should eql 'value4'
|
512
|
+
end
|
513
|
+
|
514
|
+
it "should be able to create a new hash of values to post" do
|
515
|
+
@scope['ohai'] = "world"
|
516
|
+
@scope["monty"] = "python"
|
517
|
+
request = stub_request(:post, "www.example.com").with(body: {'param1' => 'world', 'param2' => 'value2', 'param3' => 'python'}).to_return(body: {'param4' => 'value4'})
|
518
|
+
Expressive.run('(post "http://www.example.com" ($hash (param1 ohai) (param2 "value2") (param3 monty)))', @scope)
|
519
|
+
assert_requested(request)
|
520
|
+
@scope['param4'].should eql 'value4'
|
521
|
+
end
|
522
|
+
|
523
|
+
it "should be able to create a nested hash of values to post" do
|
524
|
+
@scope['ohai'] = "world"
|
525
|
+
@scope["monty"] = "python"
|
526
|
+
@scope["nested"] = "conference"
|
527
|
+
request = stub_request(:post, "www.example.com").with(body: {'param1' => 'world', 'param2' => {'level1' => {'level2' => 'conference'}}, 'param3' => 'python'}).to_return(body: {'param4' => 'value4'})
|
528
|
+
Expressive.run('(post "http://www.example.com" ($hash (param1 ohai) (param2 ($hash (level1 ($hash (level2 nested))))) (param3 monty)))', @scope)
|
529
|
+
assert_requested(request)
|
530
|
+
@scope['param4'].should eql 'value4'
|
531
|
+
end
|
532
|
+
|
533
|
+
it "should extract data from response of post" do
|
534
|
+
@scope['ohai'] = "world"
|
535
|
+
@scope["monty"] = "python"
|
536
|
+
request = stub_request(:post, "www.example.com").with(body: {'param1' => 'world', 'param2' => 'value2', 'param3' => 'python'}).to_return(body: {'param4' => 'value4'})
|
537
|
+
Expressive.run('(post "http://www.example.com" ($hash (param1 ohai) (param2 "value2") (param3 monty)))', @scope)
|
538
|
+
assert_requested(request)
|
539
|
+
@scope['param4'].should eql 'value4'
|
540
|
+
end
|
541
|
+
|
542
|
+
it "should update scope with data extracted from response and no other" do
|
543
|
+
@scope['ohai'] = "world"
|
544
|
+
@scope["monty"] = "python"
|
545
|
+
|
546
|
+
request = stub_request(:post, "www.example.com").with(body: {'param1' => 'world', 'param2' => 'value2', 'param3' => 'python'}).to_return(body: {'case_id' => '452'})
|
547
|
+
Expressive.run('(set related_id ($hval "case_id" (post "http://www.example.com" ($hash (param1 ohai) (param2 "value2") (param3 monty)) false)))', @scope)
|
548
|
+
assert_requested(request)
|
549
|
+
@scope.to_hash.keys.should_not include 'case_id'
|
550
|
+
puts @scope.to_hash
|
551
|
+
@scope['related_id'].should eql '452'
|
552
|
+
end
|
553
|
+
|
354
554
|
end
|
355
555
|
|
356
556
|
context "conditional post" do
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: expressive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.27
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ijonas Kisselbach
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-01-21 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: ruby_gntp
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rdoc
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: bundler
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,7 +69,6 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: guard
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ~>
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ~>
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,7 +83,6 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: guard-rspec
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - ~>
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,7 +90,6 @@ dependencies:
|
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - ~>
|
108
95
|
- !ruby/object:Gem::Version
|
@@ -110,7 +97,6 @@ dependencies:
|
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: webmock
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
101
|
- - ~>
|
116
102
|
- !ruby/object:Gem::Version
|
@@ -118,7 +104,6 @@ dependencies:
|
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
108
|
- - ~>
|
124
109
|
- !ruby/object:Gem::Version
|
@@ -126,7 +111,6 @@ dependencies:
|
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: pry
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
115
|
- - ~>
|
132
116
|
- !ruby/object:Gem::Version
|
@@ -134,7 +118,6 @@ dependencies:
|
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
122
|
- - ~>
|
140
123
|
- !ruby/object:Gem::Version
|
@@ -142,7 +125,6 @@ dependencies:
|
|
142
125
|
- !ruby/object:Gem::Dependency
|
143
126
|
name: timecop
|
144
127
|
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
128
|
requirements:
|
147
129
|
- - ~>
|
148
130
|
- !ruby/object:Gem::Version
|
@@ -150,7 +132,6 @@ dependencies:
|
|
150
132
|
type: :development
|
151
133
|
prerelease: false
|
152
134
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
135
|
requirements:
|
155
136
|
- - ~>
|
156
137
|
- !ruby/object:Gem::Version
|
@@ -158,7 +139,6 @@ dependencies:
|
|
158
139
|
- !ruby/object:Gem::Dependency
|
159
140
|
name: rake
|
160
141
|
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
142
|
requirements:
|
163
143
|
- - ! '>='
|
164
144
|
- !ruby/object:Gem::Version
|
@@ -166,7 +146,6 @@ dependencies:
|
|
166
146
|
type: :development
|
167
147
|
prerelease: false
|
168
148
|
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
149
|
requirements:
|
171
150
|
- - ! '>='
|
172
151
|
- !ruby/object:Gem::Version
|
@@ -174,7 +153,6 @@ dependencies:
|
|
174
153
|
- !ruby/object:Gem::Dependency
|
175
154
|
name: polyglot
|
176
155
|
requirement: !ruby/object:Gem::Requirement
|
177
|
-
none: false
|
178
156
|
requirements:
|
179
157
|
- - ~>
|
180
158
|
- !ruby/object:Gem::Version
|
@@ -182,7 +160,6 @@ dependencies:
|
|
182
160
|
type: :runtime
|
183
161
|
prerelease: false
|
184
162
|
version_requirements: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
163
|
requirements:
|
187
164
|
- - ~>
|
188
165
|
- !ruby/object:Gem::Version
|
@@ -190,7 +167,6 @@ dependencies:
|
|
190
167
|
- !ruby/object:Gem::Dependency
|
191
168
|
name: json
|
192
169
|
requirement: !ruby/object:Gem::Requirement
|
193
|
-
none: false
|
194
170
|
requirements:
|
195
171
|
- - ! '>='
|
196
172
|
- !ruby/object:Gem::Version
|
@@ -198,7 +174,6 @@ dependencies:
|
|
198
174
|
type: :runtime
|
199
175
|
prerelease: false
|
200
176
|
version_requirements: !ruby/object:Gem::Requirement
|
201
|
-
none: false
|
202
177
|
requirements:
|
203
178
|
- - ! '>='
|
204
179
|
- !ruby/object:Gem::Version
|
@@ -206,7 +181,6 @@ dependencies:
|
|
206
181
|
- !ruby/object:Gem::Dependency
|
207
182
|
name: treetop
|
208
183
|
requirement: !ruby/object:Gem::Requirement
|
209
|
-
none: false
|
210
184
|
requirements:
|
211
185
|
- - ~>
|
212
186
|
- !ruby/object:Gem::Version
|
@@ -214,7 +188,6 @@ dependencies:
|
|
214
188
|
type: :runtime
|
215
189
|
prerelease: false
|
216
190
|
version_requirements: !ruby/object:Gem::Requirement
|
217
|
-
none: false
|
218
191
|
requirements:
|
219
192
|
- - ~>
|
220
193
|
- !ruby/object:Gem::Version
|
@@ -222,7 +195,6 @@ dependencies:
|
|
222
195
|
- !ruby/object:Gem::Dependency
|
223
196
|
name: awesome_print
|
224
197
|
requirement: !ruby/object:Gem::Requirement
|
225
|
-
none: false
|
226
198
|
requirements:
|
227
199
|
- - ~>
|
228
200
|
- !ruby/object:Gem::Version
|
@@ -230,7 +202,6 @@ dependencies:
|
|
230
202
|
type: :runtime
|
231
203
|
prerelease: false
|
232
204
|
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
none: false
|
234
205
|
requirements:
|
235
206
|
- - ~>
|
236
207
|
- !ruby/object:Gem::Version
|
@@ -238,7 +209,6 @@ dependencies:
|
|
238
209
|
- !ruby/object:Gem::Dependency
|
239
210
|
name: rest-client
|
240
211
|
requirement: !ruby/object:Gem::Requirement
|
241
|
-
none: false
|
242
212
|
requirements:
|
243
213
|
- - ~>
|
244
214
|
- !ruby/object:Gem::Version
|
@@ -246,7 +216,6 @@ dependencies:
|
|
246
216
|
type: :runtime
|
247
217
|
prerelease: false
|
248
218
|
version_requirements: !ruby/object:Gem::Requirement
|
249
|
-
none: false
|
250
219
|
requirements:
|
251
220
|
- - ~>
|
252
221
|
- !ruby/object:Gem::Version
|
@@ -282,33 +251,26 @@ files:
|
|
282
251
|
- spec/webhook_examples.rb
|
283
252
|
homepage: http://github.com/emergeadapt/expressive
|
284
253
|
licenses: []
|
254
|
+
metadata: {}
|
285
255
|
post_install_message:
|
286
256
|
rdoc_options: []
|
287
257
|
require_paths:
|
288
258
|
- lib
|
289
259
|
required_ruby_version: !ruby/object:Gem::Requirement
|
290
|
-
none: false
|
291
260
|
requirements:
|
292
261
|
- - ! '>='
|
293
262
|
- !ruby/object:Gem::Version
|
294
263
|
version: '0'
|
295
|
-
segments:
|
296
|
-
- 0
|
297
|
-
hash: 4009429271067879068
|
298
264
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
299
|
-
none: false
|
300
265
|
requirements:
|
301
266
|
- - ! '>='
|
302
267
|
- !ruby/object:Gem::Version
|
303
268
|
version: '0'
|
304
|
-
segments:
|
305
|
-
- 0
|
306
|
-
hash: 4009429271067879068
|
307
269
|
requirements: []
|
308
270
|
rubyforge_project:
|
309
|
-
rubygems_version:
|
271
|
+
rubygems_version: 2.0.3
|
310
272
|
signing_key:
|
311
|
-
specification_version:
|
273
|
+
specification_version: 4
|
312
274
|
summary: Scheme-like language for manipulating CaseBlocks cases
|
313
275
|
test_files:
|
314
276
|
- spec/expressive_spec.rb
|