adhearsion 2.0.0.alpha2 → 2.0.0.alpha3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/.gitignore +16 -14
  2. data/CHANGELOG.md +17 -1
  3. data/adhearsion.gemspec +14 -13
  4. data/features/cli_basic.feature +30 -0
  5. data/features/cli_create.feature +24 -0
  6. data/features/cli_daemon.feature +21 -0
  7. data/features/cli_generate.feature +9 -0
  8. data/features/cli_start.feature +33 -0
  9. data/features/cli_stop.feature +38 -0
  10. data/features/controller_generator.feature +19 -0
  11. data/features/plugin_generator.feature +55 -0
  12. data/lib/adhearsion.rb +5 -1
  13. data/lib/adhearsion/call.rb +57 -51
  14. data/lib/adhearsion/call_controller.rb +4 -20
  15. data/lib/adhearsion/call_controller/dial.rb +34 -4
  16. data/lib/adhearsion/calls.rb +4 -1
  17. data/lib/adhearsion/cli_commands.rb +31 -6
  18. data/lib/adhearsion/configuration.rb +2 -6
  19. data/lib/adhearsion/console.rb +56 -17
  20. data/lib/adhearsion/generators.rb +53 -2
  21. data/lib/adhearsion/generators/app/app_generator.rb +2 -24
  22. data/lib/adhearsion/generators/app/templates/config/adhearsion.rb +1 -1
  23. data/lib/adhearsion/generators/controller/controller_generator.rb +18 -0
  24. data/lib/adhearsion/generators/controller/templates/lib/controller.rb +4 -0
  25. data/lib/adhearsion/generators/controller/templates/spec/controller_spec.rb +3 -0
  26. data/lib/adhearsion/generators/generator.rb +77 -0
  27. data/lib/adhearsion/generators/plugin/plugin_generator.rb +33 -0
  28. data/lib/adhearsion/generators/plugin/templates/.gitignore +9 -0
  29. data/lib/adhearsion/generators/plugin/templates/Gemfile.tt +4 -0
  30. data/lib/adhearsion/generators/plugin/templates/README.md.tt +2 -0
  31. data/lib/adhearsion/generators/plugin/templates/Rakefile.tt +1 -0
  32. data/lib/adhearsion/generators/plugin/templates/lib/plugin-template.rb.tt +5 -0
  33. data/lib/adhearsion/generators/plugin/templates/lib/plugin-template/controller_methods.rb.tt +10 -0
  34. data/lib/adhearsion/generators/plugin/templates/lib/plugin-template/plugin.rb.tt +29 -0
  35. data/lib/adhearsion/generators/plugin/templates/lib/plugin-template/version.rb.tt +3 -0
  36. data/lib/adhearsion/generators/plugin/templates/plugin-template.gemspec.tt +35 -0
  37. data/lib/adhearsion/generators/plugin/templates/spec/plugin-template/controller_methods_spec.rb.tt +26 -0
  38. data/lib/adhearsion/generators/plugin/templates/spec/spec_helper.rb.tt +13 -0
  39. data/lib/adhearsion/initializer.rb +14 -22
  40. data/lib/adhearsion/logging.rb +25 -16
  41. data/lib/adhearsion/outbound_call.rb +3 -3
  42. data/lib/adhearsion/plugin.rb +14 -0
  43. data/lib/adhearsion/punchblock_plugin.rb +6 -1
  44. data/lib/adhearsion/punchblock_plugin/initializer.rb +8 -8
  45. data/lib/adhearsion/tasks/configuration.rb +1 -1
  46. data/lib/adhearsion/version.rb +1 -1
  47. data/spec/adhearsion/call_controller/dial_spec.rb +108 -17
  48. data/spec/adhearsion/call_controller_spec.rb +7 -64
  49. data/spec/adhearsion/call_spec.rb +48 -29
  50. data/spec/adhearsion/calls_spec.rb +7 -0
  51. data/spec/adhearsion/configuration_spec.rb +14 -14
  52. data/spec/adhearsion/console_spec.rb +124 -4
  53. data/spec/adhearsion/generators_spec.rb +17 -0
  54. data/spec/adhearsion/initializer_spec.rb +22 -18
  55. data/spec/adhearsion/logging_spec.rb +78 -48
  56. data/spec/adhearsion/outbound_call_spec.rb +6 -15
  57. data/spec/adhearsion/plugin_spec.rb +18 -0
  58. data/spec/adhearsion/process_spec.rb +10 -1
  59. data/spec/adhearsion/punchblock_plugin/initializer_spec.rb +8 -6
  60. data/spec/spec_helper.rb +5 -2
  61. data/spec/support/call_controller_test_helpers.rb +1 -1
  62. data/spec/support/initializer_stubs.rb +1 -1
  63. metadata +106 -66
  64. data/features/cli.feature +0 -108
  65. data/lib/adhearsion/initializer/logging.rb +0 -33
  66. data/spec/adhearsion/initializer/logging_spec.rb +0 -55
@@ -1,108 +0,0 @@
1
- Feature: Adhearsion Ahn CLI
2
- As an Adhearsion user
3
- I want a cli command (ahn)
4
- So that I can create and interact with adhearsion apps
5
-
6
- Scenario: No arguments given
7
- When I run `ahn`
8
- Then I should see the usage message
9
- And the exit status should be 0
10
-
11
- Scenario: Unrecognized commands
12
- When I run `ahn alpha beta`
13
- Then the output should contain:
14
- """
15
- Unknown command: alpha beta
16
- """
17
- And the exit status should be 1
18
-
19
- Scenario: Command create with correct arguments
20
- When I run `ahn create path/somewhere`
21
- And I cd to "path/somewhere"
22
- Then the following files should exist:
23
- | Gemfile |
24
- | README.md |
25
- | Rakefile |
26
- | config/adhearsion.rb |
27
- | config/environment.rb |
28
- And the file "config/adhearsion.rb" should contain "Adhearsion.router"
29
- Then the exit status should be 0
30
-
31
- Scenario: Running create with no arguments
32
- When I run `ahn create`
33
- Then the output should contain:
34
- """
35
- "create" was called incorrectly. Call as "ahn create /path/to/directory".
36
- """
37
- And the exit status should be 1
38
-
39
- Scenario: Command start with no path outside of the app directory
40
- When I run `ahn start`
41
- Then the output should contain:
42
- """
43
- A valid path is required for start, unless run from an Adhearson app directory
44
- """
45
- And the exit status should be 1
46
-
47
- Scenario: Command start with no path inside of the app directory
48
- Given JRuby skip test
49
- Given that I create a valid app under "path/somewhere"
50
- When I cd to "path/somewhere"
51
- And I run `ahn start` interactively
52
- And I wait for output to contain "Starting connection to server"
53
- And I terminate the interactive process
54
- Then the output should contain "Loaded config"
55
- And the output should contain "Adhearsion::Console: Starting up..."
56
- And the output should contain "AHN>"
57
- And the output should contain "Transitioning from booting to force_stop"
58
-
59
- Scenario: Command start with only path works properly
60
- Given JRuby skip test
61
- Given that I create a valid app under "path/somewhere"
62
- When I run `ahn start path/somewhere` interactively
63
- And I wait for output to contain "Starting connection to server"
64
- And I terminate the interactive process
65
- Then the output should contain "Loaded config"
66
- And the output should contain "Adhearsion::Console: Starting up..."
67
- And the output should contain "AHN>"
68
- And the output should contain "Transitioning from booting to force_stop"
69
-
70
- Scenario: Command daemon with path works correctly
71
- Given JRuby skip test
72
- Given that I create a valid app under "path/somewhere"
73
- When I run `ahn daemon path/somewhere`
74
- And I cd to "path/somewhere"
75
- And I terminate the process using the pid file "adhearsion.pid"
76
- Then the output should contain "Daemonizing now"
77
- And the exit status should be 0
78
-
79
- Scenario: Command start with daemon and pid option
80
- Given JRuby skip test
81
- Given that I create a valid app under "path/somewhere"
82
- When I run `ahn daemon path/somewhere --pid-file=ahn.pid`
83
- And I cd to "path/somewhere"
84
- And I terminate the process using the pid file "ahn.pid"
85
- Then the output should contain "Daemonizing now"
86
-
87
- Scenario: Command stop with valid path and pid option
88
- Given JRuby skip test
89
- Given that I create a valid app under "path/somewhere"
90
- When I run `ahn daemon path/somewhere --pid-file=ahn.pid`
91
- And I run `ahn stop path/somewhere --pid-file=ahn.pid`
92
- Then the output should contain:
93
- """
94
- Stopping Adhearsion
95
- """
96
-
97
- Scenario: Command version should print the version
98
- When I run `ahn version`
99
- Then the output should contain:
100
- """
101
- Adhearsion v
102
- """
103
- And the exit status should be 0
104
-
105
- Scenario: Command help
106
- When I run `ahn help`
107
- Then I should see the usage message
108
- And the exit status should be 0
@@ -1,33 +0,0 @@
1
- require 'logging'
2
-
3
- module Adhearsion
4
- class Initializer
5
- class Logging
6
- class << self
7
-
8
- def start(_appenders = nil, level = :info, formatter = nil)
9
- ::Logging.init Adhearsion::Logging::LOG_LEVELS
10
-
11
- ::Logging.logger.root.appenders = _appenders.nil? ? appenders : _appenders
12
-
13
- ::Logging.logger.root.level = level
14
-
15
- ::Logging.logger.root.appenders.each do |appender|
16
- appender.layout = formatter
17
- end unless formatter.nil?
18
- end
19
-
20
- # default appenders
21
- def appenders
22
- @appenders ||= [::Logging.appenders.stdout(
23
- 'stdout',
24
- :layout => ::Logging.layouts.pattern(
25
- :pattern => Adhearsion::Logging.adhearsion_pattern,
26
- :color_scheme => 'bright'
27
- )
28
- )]
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,55 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Adhearsion::Initializer::Logging do
4
-
5
- before do
6
- Adhearsion::Initializer::Logging.start
7
- end
8
-
9
- after do
10
- Adhearsion::Logging.reset
11
- end
12
-
13
- after(:all) do
14
- Adhearsion::Initializer::Logging.start
15
- Adhearsion::Logging.silence!
16
- end
17
-
18
- it "initializes properly a Logging object" do
19
- ::Logging.logger.root.appenders.length.should eql(1)
20
- ::Logging.logger.root.appenders.select{|a| a.is_a?(::Logging::Appenders::Stdout)}.length.should eql(1)
21
- end
22
-
23
- it 'should created the predefined set of log levels' do
24
- ::Logging::LEVELS.length.should eql(Adhearsion::Logging::LOG_LEVELS.length)
25
- end
26
-
27
- it "initializes properly a Logging object with appenders as parameter" do
28
- Adhearsion::Initializer::Logging.start([::Logging.appenders.stdout, ::Logging.appenders.file('example.log')])
29
- ::Logging.logger.root.appenders.length.should eql(2)
30
- ::Logging.logger.root.appenders.select{|a| a.is_a?(::Logging::Appenders::Stdout)}.length.should eql(1)
31
- ::Logging.logger.root.appenders.select{|a| a.is_a?(::Logging::Appenders::File)}.length.should eql(1)
32
- end
33
-
34
- it "initializes properly a Logging object with appenders and log level as parameter" do
35
- Adhearsion::Initializer::Logging.start([::Logging.appenders.stdout, ::Logging.appenders.file('example.log')], :debug)
36
- ::Logging.logger.root.appenders.length.should eql(2)
37
- ::Logging.logger.root.appenders.select{|a| a.is_a?(::Logging::Appenders::Stdout)}.length.should eql(1)
38
- ::Logging.logger.root.appenders.select{|a| a.is_a?(::Logging::Appenders::File)}.length.should eql(1)
39
- ::Logging.logger.root.level.should eql(::Logging::LEVELS["debug"])
40
- end
41
-
42
- it "should create only a Logging object per Class (reuse per all the instances)" do
43
- _logger = Foo.new.logger
44
- 10.times do
45
- Foo.new.logger.object_id.should eql(_logger.object_id)
46
- end
47
- end
48
-
49
- it "should reuse a Logging instance in all Class instances but not with child instances" do
50
- _foo_logger = Foo.new.logger
51
- _bar_logger = Foo::Bar.new.logger
52
- _foo_logger.object_id.should_not eql(_bar_logger)
53
- end
54
-
55
- end