call_center 1.0.1 → 1.0.3

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.
@@ -1,17 +0,0 @@
1
- require File.expand_path("../helper", __FILE__)
2
-
3
- class MyObject
4
- end
5
-
6
- class CoreExtTest < Test::Unit::TestCase
7
- should "use existing" do
8
- obj = MyObject.new
9
- $capture = nil
10
- block = lambda { |a|
11
- $capture = [self, a]
12
- }
13
- obj.instance_exec(true, &block)
14
-
15
- assert_equal [obj, true], $capture
16
- end
17
- end
@@ -1,65 +0,0 @@
1
- class Call
2
- include CallCenter
3
- include CommonCallMethods
4
-
5
- call_flow :state, :initial => :initial do
6
- actor :customer do |call, event|
7
- "/voice/calls/flow?event=#{event}&actor=customer"
8
- end
9
- actor :agent do |call, event|
10
- "/voice/calls/flow?event=#{event}&actor=agent"
11
- end
12
-
13
- state :initial do
14
- response do |x, call| # To allow defining render blocks within a state
15
- call.notify(:rendering_initial)
16
- x.Say "Hello World"
17
- end
18
-
19
- event :incoming_call, :to => :voicemail, :unless => :agents_available?
20
- event :incoming_call, :to => :routing, :if => :agents_available?
21
- event :something_crazy_happens, :to => :uh_oh
22
- end
23
-
24
- state :voicemail do
25
- response do |x| # To allow defining render blocks outside a state
26
- notify(:rendering_voicemail)
27
- x.Say "Hello World"
28
- x.Record :action => customer(:voicemail_complete)
29
- end
30
-
31
- customer :hangs_up, :to => :voicemail_completed
32
- end
33
-
34
- state :routing do
35
- customer :hangs_up, :to => :cancelled
36
- event :start_conference, :to => :in_conference
37
- end
38
-
39
- state :cancelled do
40
- after(:success, :uniq => true) { notify(:cancelled) }
41
-
42
- customer :hangs_up, :to => same
43
- customer :end, :to => :ended
44
- end
45
-
46
- response(:cancelled) do |x, call|
47
- # Just for sake of comparison
48
- end
49
-
50
- state :ended do
51
- after(:always) { notify(:after_always) }
52
- after(:success) { notify(:after_success) }
53
- after(:failure) { notify(:after_failure) }
54
-
55
- after(:always, :uniq => true) { notify(:after_always_uniq) }
56
- after(:success, :uniq => true) { |transition| notify(:after_success_uniq, transition) }
57
- after(:failure, :uniq => true) { notify(:after_failure_uniq) }
58
-
59
- before(:always) { notify(:before_always) }
60
- before(:always, :uniq => true) { notify(:before_always_uniq) }
61
-
62
- customer :end, :to => same
63
- end
64
- end
65
- end
@@ -1,43 +0,0 @@
1
- class DynamicTransitionCall
2
- include CallCenter
3
- include CommonCallMethods
4
-
5
- call_flow :state, :initial => :initial do
6
- state :initial do
7
- response do |x|
8
- x.Say "Hello World"
9
- end
10
-
11
- flow_if :agents_available? do
12
- flow_if :via_phone? do
13
- event :incoming_call, :to => :routing_on_phone
14
- end
15
-
16
- flow_unless :via_phone? do
17
- event :incoming_call, :to => :routing_on_mobile_client, :if => :on_mobile?
18
- event :incoming_call, :to => :routing_on_webrtc, :unless => :prefer_flash?
19
- event :incoming_call, :to => :routing_on_client
20
- end
21
- end
22
-
23
- flow_unless :agents_available? do
24
- flow_unless :voicemail_full? do
25
- event :incoming_call, :to => :voicemail
26
- end
27
-
28
- flow_if :voicemail_full? do
29
- event :incoming_call, :to => :cancelled
30
- end
31
- end
32
- end
33
-
34
- state :routing_on_client do
35
- flow_if :out_of_area? do
36
- event :picks_up, :to => :cancelled
37
- end
38
- flow_unless :out_of_area? do
39
- event :picks_up, :to => :in_conference
40
- end
41
- end
42
- end
43
- end
@@ -1,26 +0,0 @@
1
- class LegacyCall
2
- include CallCenter
3
- include CommonCallMethods
4
-
5
- state_machine :state, :initial => :initial do
6
- event :incoming_call do
7
- transition :initial => :voicemail, :unless => :agents_available?
8
- transition :initial => :routing, :if => :agents_available?
9
- end
10
-
11
- after_transition any => :voicemail, :do => :voicemail
12
- after_transition any => :routing, :do => :routing
13
-
14
- event :customer_hangs_up do
15
- transition :voicemail => :voicemail_completed
16
- transition :routing => :cancelled
17
- transition :cancelled => same
18
- end
19
-
20
- after_transition any => :voicemail_completed, :do => :voicemail_completed
21
-
22
- event :something_crazy_happens do
23
- transition :initial => :uh_oh # No after transition for this one
24
- end
25
- end
26
- end
@@ -1,21 +0,0 @@
1
- class MultipleFlowCall
2
- include CallCenter
3
-
4
- call_flow :status, :initial => :ready do
5
- state :ready do
6
- event :go, :to => :done
7
- response do |x|
8
- x.Say "Hello World"
9
- end
10
- end
11
- end
12
-
13
- call_flow :outgoing_status, :initial => :outgoing_ready do
14
- state :outgoing_ready do
15
- event :outgoing_go, :to => :outgoing_done
16
- response do |x|
17
- x.Say "Hello Outgoing World"
18
- end
19
- end
20
- end
21
- end
@@ -1,12 +0,0 @@
1
- class NonStandardCall
2
- include CallCenter
3
-
4
- call_flow :status, :initial => :ready do
5
- state :ready do
6
- event :go, :to => :done
7
- response do |x|
8
- x.Say "Hello World"
9
- end
10
- end
11
- end
12
- end
@@ -1,30 +0,0 @@
1
- require 'bundler/setup'
2
- require 'test/unit'
3
- require 'shoulda'
4
- require 'mocha'
5
- require 'bourne'
6
-
7
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
- require 'call_center'
9
-
10
- require 'active_support'
11
- require 'action_pack'
12
- require 'action_controller'
13
-
14
- class Test::Unit::TestCase
15
- def response_from_page_or_rjs
16
- HTML::Document.new(@body).root
17
- end
18
-
19
- def body(text, debug = false)
20
- puts text if debug
21
- @body = text
22
- end
23
- end
24
-
25
- module CommonCallMethods
26
- def agents_available?; end
27
- def voicemail; end
28
- def voicemail_completed; end
29
- def routing; end
30
- end