adhearsion 2.0.0.alpha1 → 2.0.0.alpha2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/.gitignore +2 -0
  2. data/.travis.yml +12 -0
  3. data/CHANGELOG.md +17 -0
  4. data/adhearsion.gemspec +4 -3
  5. data/features/app_generator.feature +3 -1
  6. data/features/cli.feature +7 -7
  7. data/features/support/env.rb +46 -0
  8. data/lib/adhearsion.rb +1 -2
  9. data/lib/adhearsion/call.rb +59 -19
  10. data/lib/adhearsion/call_controller.rb +20 -24
  11. data/lib/adhearsion/call_controller/dial.rb +18 -18
  12. data/lib/adhearsion/cli_commands.rb +26 -9
  13. data/lib/adhearsion/configuration.rb +39 -10
  14. data/lib/adhearsion/console.rb +61 -42
  15. data/lib/adhearsion/foundation/libc.rb +13 -0
  16. data/lib/adhearsion/generators/app/app_generator.rb +4 -1
  17. data/lib/adhearsion/generators/app/templates/{Gemfile → Gemfile.erb} +1 -1
  18. data/lib/adhearsion/generators/app/templates/Rakefile +3 -22
  19. data/lib/adhearsion/generators/app/templates/gitignore +7 -0
  20. data/lib/adhearsion/generators/app/templates/lib/simon_game.rb +1 -0
  21. data/lib/adhearsion/generators/app/templates/script/ahn +1 -0
  22. data/lib/adhearsion/initializer.rb +24 -12
  23. data/lib/adhearsion/linux_proc_name.rb +41 -0
  24. data/lib/adhearsion/outbound_call.rb +10 -5
  25. data/lib/adhearsion/plugin.rb +29 -132
  26. data/lib/adhearsion/process.rb +4 -1
  27. data/lib/adhearsion/punchblock_plugin.rb +14 -5
  28. data/lib/adhearsion/punchblock_plugin/initializer.rb +8 -1
  29. data/lib/adhearsion/router/route.rb +1 -3
  30. data/lib/adhearsion/tasks.rb +6 -12
  31. data/lib/adhearsion/tasks/configuration.rb +7 -24
  32. data/lib/adhearsion/tasks/environment.rb +12 -0
  33. data/lib/adhearsion/tasks/plugins.rb +9 -14
  34. data/lib/adhearsion/version.rb +1 -1
  35. data/spec/adhearsion/call_controller/dial_spec.rb +46 -22
  36. data/spec/adhearsion/call_controller_spec.rb +48 -13
  37. data/spec/adhearsion/call_spec.rb +144 -23
  38. data/spec/adhearsion/calls_spec.rb +8 -4
  39. data/spec/adhearsion/console_spec.rb +24 -0
  40. data/spec/adhearsion/initializer/logging_spec.rb +0 -3
  41. data/spec/adhearsion/initializer_spec.rb +52 -37
  42. data/spec/adhearsion/logging_spec.rb +0 -3
  43. data/spec/adhearsion/outbound_call_spec.rb +12 -2
  44. data/spec/adhearsion/plugin_spec.rb +74 -184
  45. data/spec/adhearsion/process_spec.rb +59 -26
  46. data/spec/adhearsion/punchblock_plugin/initializer_spec.rb +3 -4
  47. data/spec/adhearsion/punchblock_plugin_spec.rb +11 -0
  48. data/spec/adhearsion/router/route_spec.rb +37 -6
  49. data/spec/adhearsion_spec.rb +31 -8
  50. data/spec/spec_helper.rb +14 -0
  51. data/spec/support/call_controller_test_helpers.rb +2 -2
  52. data/spec/support/logging_helpers.rb +2 -0
  53. metadata +85 -68
  54. data/lib/adhearsion/dialplan_controller.rb +0 -9
  55. data/lib/adhearsion/foundation/synchronized_hash.rb +0 -93
  56. data/lib/adhearsion/plugin/methods_container.rb +0 -6
  57. data/spec/adhearsion/dialplan_controller_spec.rb +0 -26
@@ -1,9 +0,0 @@
1
- module Adhearsion
2
- class DialplanController < CallController
3
- attr_accessor :dialplan
4
-
5
- def run
6
- instance_exec &dialplan
7
- end
8
- end
9
- end
@@ -1,93 +0,0 @@
1
- ##
2
- # Implementation of a Thread-safe Hash. Works by delegating methods to a Hash behind-the-scenes after obtaining an exclusive # lock. Use exactly as you would a normal Hash.
3
- #
4
- class SynchronizedHash
5
-
6
- def self.atomically_delegate(method_name)
7
- class_eval(<<-RUBY, __FILE__, __LINE__)
8
- def #{method_name}(*args, &block)
9
- @lock.synchronize do
10
- @delegate.send #{method_name.inspect}, *args, &block
11
- end
12
- end
13
- RUBY
14
- end
15
-
16
- # Hash-related methods
17
- atomically_delegate :[]
18
- atomically_delegate :[]=
19
- atomically_delegate :all?
20
- atomically_delegate :any?
21
- atomically_delegate :clear
22
- atomically_delegate :collect
23
- atomically_delegate :default
24
- atomically_delegate :default=
25
- atomically_delegate :delete
26
- atomically_delegate :delete_if
27
- atomically_delegate :detect
28
- atomically_delegate :each
29
- atomically_delegate :each_key
30
- atomically_delegate :each_pair
31
- atomically_delegate :each_value
32
- atomically_delegate :each_with_index
33
- atomically_delegate :empty?
34
- atomically_delegate :entries
35
- atomically_delegate :fetch
36
- atomically_delegate :find
37
- atomically_delegate :find_all
38
- atomically_delegate :grep
39
- atomically_delegate :has_key?
40
- atomically_delegate :has_value?
41
- atomically_delegate :include?
42
- atomically_delegate :index
43
- atomically_delegate :indexes
44
- atomically_delegate :indices
45
- atomically_delegate :inject
46
- atomically_delegate :invert
47
- atomically_delegate :key?
48
- atomically_delegate :keys
49
- atomically_delegate :length
50
- atomically_delegate :map
51
- atomically_delegate :max
52
- atomically_delegate :member?
53
- atomically_delegate :merge
54
- atomically_delegate :merge!
55
- atomically_delegate :min
56
- atomically_delegate :partition
57
- atomically_delegate :rehash
58
- atomically_delegate :reject
59
- atomically_delegate :reject!
60
- atomically_delegate :replace
61
- atomically_delegate :select
62
- atomically_delegate :shift
63
- atomically_delegate :size
64
- atomically_delegate :sort
65
- atomically_delegate :sort_by
66
- atomically_delegate :store
67
- atomically_delegate :to_hash
68
- atomically_delegate :update
69
- atomically_delegate :value?
70
- atomically_delegate :values
71
- atomically_delegate :values_at
72
- atomically_delegate :zip
73
-
74
- # Object-related methods
75
- atomically_delegate :inspect
76
- atomically_delegate :to_s
77
- atomically_delegate :marshal_dump
78
-
79
- def initialize(*args, &block)
80
- @delegate = Hash.new *args, &block
81
- @lock = Mutex.new
82
- end
83
-
84
- ##
85
- # If you need to do many operations atomically (a la transaction), you can call this method and access the yielded Hash
86
- # which can be safely modified for the duration of your block.
87
- #
88
- # @yield [Hash] the Hash on which you can safely operate during your block.
89
- #
90
- def with_lock(&block)
91
- @lock.synchronize { yield @delegate }
92
- end
93
- end
@@ -1,6 +0,0 @@
1
- module Adhearsion
2
- class Plugin
3
- class MethodsContainer < Hash
4
- end
5
- end
6
- end
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Adhearsion
4
- describe DialplanController do
5
- include CallControllerTestHelpers
6
-
7
- it { should be_a DialplanController }
8
- it { should be_a CallController }
9
-
10
- let :dialplan do
11
- Proc.new { foo value }
12
- end
13
-
14
- before { subject.dialplan = dialplan }
15
-
16
- its(:dialplan) { should be dialplan }
17
-
18
- describe "running" do
19
- it "should execute the dialplan in the context of the controller" do
20
- flexmock subject, :value => :bar
21
- subject.should_receive(:foo).once.with(:bar)
22
- subject.run
23
- end
24
- end
25
- end
26
- end