ahn-rails 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
1
  pkg/*
2
2
  *.gem
3
3
  .bundle
4
+ tmp
5
+ Gemfile.lock
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ AHNRails
2
+ --------
3
+
4
+ AHNRails provides neat little generators for your Adhearsion + Rails mashups.
5
+
6
+ Simply include ahn-rails in your rails Gemfile and run `rails g ahn:app`.
7
+
8
+ Note on Patches/Pull Requests
9
+ -----------------------------
10
+
11
+ * Fork the project.
12
+ * Make your feature addition or bug fix.
13
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
14
+ * Commit, do not mess with rakefile, version, or history.
15
+ (if you want to have your own version, that is fine but bump version in a commit by itself so I can ignore when I pull)
16
+ * Send me a pull request. Bonus points for topic branches.
17
+
18
+ Copyright
19
+ ---------
20
+
21
+ Copyright (c) 2011 Ben Langfeld. MIT licence (see LICENSE for details).
data/Rakefile CHANGED
@@ -1,2 +1,12 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+
4
+ require 'rake'
5
+ require 'cucumber'
6
+ require 'cucumber/rake/task'
7
+
8
+ Cucumber::Rake::Task.new(:features) do |t|
9
+ t.cucumber_opts = "features --format pretty"
10
+ end
11
+
12
+ task :default => :features
data/ahn-rails.gemspec CHANGED
@@ -18,4 +18,14 @@ Gem::Specification.new do |s|
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
+
22
+ s.add_dependency 'adhearsion', '~> 1.0.1'
23
+
24
+ s.add_development_dependency 'rspec-rails', '~> 2.5.0'
25
+ s.add_development_dependency 'cucumber', '~> 0.10.2'
26
+ s.add_development_dependency 'aruba', '~> 0.3.5'
27
+ s.add_development_dependency 'rails', '~> 3.0.6'
28
+ s.add_development_dependency 'mocha', '~> 0.9.12'
29
+ s.add_development_dependency 'bcrypt-ruby', '~> 2.1.2'
30
+ s.add_development_dependency 'sqlite3-ruby', '~> 1.3.1'
21
31
  end
@@ -0,0 +1,101 @@
1
+ Feature: Adhearsion App Generator
2
+ In order to integrate Adhearsion and Rails
3
+ As a rails developer
4
+ I want to generate an Adhearsion app inside my Rails app
5
+
6
+ Scenario: Generate railsified application layout
7
+ Given a new Rails app
8
+ When I cd to "rails_app"
9
+ And I run `rails g ahn:app -f`
10
+ Then the following directories should exist:
11
+ | components |
12
+ | components/simon_game |
13
+
14
+ And the following files should exist:
15
+ | app/dialplan.rb |
16
+ | app/events.rb |
17
+ | config/adhearsion.rb |
18
+
19
+ And the file "config/adhearsion.rb" should contain exactly:
20
+ """
21
+ require 'rubygems'
22
+ require 'bundler'
23
+ Bundler.setup
24
+ Bundler.require :adhearsion
25
+
26
+ Adhearsion::Configuration.configure do |config|
27
+
28
+ values = YAML.load_file File.expand_path('../adhearsion.yml', __FILE__)
29
+
30
+ (values['gem_components'] || []).each do |c|
31
+ config.add_component c
32
+ end
33
+
34
+ config.logging :level => values['log_level'].to_sym
35
+ config.automatically_answer_incoming_calls = values['automatically_answer_incoming_calls'] || true
36
+ config.end_call_on_hangup = values['end_call_on_hangup'] || true
37
+ config.end_call_on_error = values['end_call_on_error'] || true
38
+
39
+ config.enable_asterisk :argument_delimiter => values['argument_delimiter'] || '|'
40
+ config.asterisk.enable_ami values['ami']
41
+
42
+ config.enable_drb if values['drb']
43
+
44
+ config.enable_rails :path => '..', :env => values['rails_env'].to_sym
45
+
46
+ end
47
+
48
+ Adhearsion::Initializer.start_from_init_file(__FILE__, File.dirname(__FILE__) + "/..")
49
+
50
+ """
51
+ And the file "config/adhearsion.example.yml" should contain exactly:
52
+ """
53
+ gem_components:
54
+
55
+
56
+ log_level: debug
57
+
58
+ automatically_answer_incoming_calls: true
59
+ end_call_on_hangup: true
60
+ end_call_on_error: true
61
+
62
+ argument_delimiter: "|"
63
+ ami:
64
+ host: 127.0.0.1
65
+ username: test
66
+ password: test
67
+ events: true
68
+
69
+ drb: true
70
+
71
+ rails_env: production
72
+
73
+ """
74
+ And the file "Gemfile" should contain "adhearsion"
75
+ And the file "Gemfile" should contain "1.0.1"
76
+ And the file "lib/tasks/adhearsion.rake" should contain exactly:
77
+ """
78
+ begin
79
+ require 'adhearsion/tasks'
80
+ rescue LoadError
81
+ STDERR.puts "\nCannot load Adhearsion! Not all Rake tasks will be loaded!\n\n"
82
+ end
83
+
84
+ """
85
+ And the file ".ahnrc" should contain exactly:
86
+ """
87
+ # Adhearsion Runtime Configuration.
88
+
89
+ paths:
90
+
91
+ # All paths are relative to this file's directory
92
+ init: config/adhearsion.rb
93
+
94
+ dialplan: app/dialplan.rb
95
+
96
+ events: app/events.rb
97
+
98
+ models: app/models/*.rb
99
+
100
+ """
101
+ And a directory named "tmp/adhearsion" should not exist
@@ -0,0 +1,4 @@
1
+ Given /^a new Rails app$/ do
2
+ Given "I run `rails new rails_app`"
3
+ And "I run `ln -s ../../lib/generators rails_app/lib/generators`"
4
+ end
@@ -0,0 +1,7 @@
1
+ require 'cucumber'
2
+ require 'rspec'
3
+ require 'aruba/cucumber'
4
+
5
+ Before do
6
+ @aruba_timeout_seconds = 10
7
+ end
@@ -1,3 +1,3 @@
1
1
  module AhnRails
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,28 @@
1
+ require 'rails/generators/base'
2
+
3
+ module Ahn
4
+ module Generators
5
+ class Base < Rails::Generators::Base #:nodoc:
6
+ def self.source_root
7
+ @_ahn_source_root ||= File.expand_path File.join(File.dirname(__FILE__), 'ahn', generator_name, 'templates')
8
+ end
9
+
10
+ def self.banner
11
+ "rails generate ahn:#{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
12
+ end
13
+
14
+ private
15
+
16
+ def add_gem(name, options = {})
17
+ gemfile_content = File.read destination_path("Gemfile")
18
+ File.open(destination_path("Gemfile"), 'a') { |f| f.write("\n") } unless gemfile_content =~ /\n\Z/
19
+ gem name, options unless gemfile_content.include? name
20
+ end
21
+
22
+ def print_usage
23
+ self.class.help Thor::Base.shell.new
24
+ exit
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,5 @@
1
+ Description:
2
+ The ahn:app generator creates an Adhearsion app that is coupled with your Rails app. It places config in the config/ directory, dialplan.rb and events.rb in app/, components in components/, uses YAML for adhearsion config and loads your rails app in adhearsion.
3
+
4
+ Examples:
5
+ rails generate ahn:app
@@ -0,0 +1,42 @@
1
+ require 'generators/ahn'
2
+
3
+ module Ahn
4
+ module Generators
5
+ class AppGenerator < Base
6
+ def generate_app
7
+ generate_ahn_app
8
+ place_files_for_rails
9
+ remove_ahn_tmp
10
+ place_custom_files
11
+ end
12
+
13
+ private
14
+
15
+ def ahn_tmp_dir
16
+ 'tmp/adhearsion'
17
+ end
18
+
19
+ def generate_ahn_app
20
+ run "ahn create #{ahn_tmp_dir}"
21
+ end
22
+
23
+ def place_files_for_rails
24
+ run "mv #{ahn_tmp_dir}/components components"
25
+ run "mv #{ahn_tmp_dir}/dialplan.rb app/dialplan.rb"
26
+ run "mv #{ahn_tmp_dir}/events.rb app/events.rb"
27
+ end
28
+
29
+ def remove_ahn_tmp
30
+ remove_dir ahn_tmp_dir
31
+ end
32
+
33
+ def place_custom_files
34
+ gem "adhearsion", ">= 1.0.1"
35
+ copy_file "adhearsion.rake", "lib/tasks/adhearsion.rake"
36
+ copy_file "adhearsion.rb", "config/adhearsion.rb"
37
+ copy_file "adhearsion.yml", "config/adhearsion.example.yml"
38
+ copy_file "ahnrc", ".ahnrc"
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,5 @@
1
+ begin
2
+ require 'adhearsion/tasks'
3
+ rescue LoadError
4
+ STDERR.puts "\nCannot load Adhearsion! Not all Rake tasks will be loaded!\n\n"
5
+ end
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
4
+ Bundler.require :adhearsion
5
+
6
+ Adhearsion::Configuration.configure do |config|
7
+
8
+ values = YAML.load_file File.expand_path('../adhearsion.yml', __FILE__)
9
+
10
+ (values['gem_components'] || []).each do |c|
11
+ config.add_component c
12
+ end
13
+
14
+ config.logging :level => values['log_level'].to_sym
15
+ config.automatically_answer_incoming_calls = values['automatically_answer_incoming_calls'] || true
16
+ config.end_call_on_hangup = values['end_call_on_hangup'] || true
17
+ config.end_call_on_error = values['end_call_on_error'] || true
18
+
19
+ config.enable_asterisk :argument_delimiter => values['argument_delimiter'] || '|'
20
+ config.asterisk.enable_ami values['ami']
21
+
22
+ config.enable_drb if values['drb']
23
+
24
+ config.enable_rails :path => '..', :env => values['rails_env'].to_sym
25
+
26
+ end
27
+
28
+ Adhearsion::Initializer.start_from_init_file(__FILE__, File.dirname(__FILE__) + "/..")
@@ -0,0 +1,19 @@
1
+ gem_components:
2
+
3
+
4
+ log_level: debug
5
+
6
+ automatically_answer_incoming_calls: true
7
+ end_call_on_hangup: true
8
+ end_call_on_error: true
9
+
10
+ argument_delimiter: "|"
11
+ ami:
12
+ host: 127.0.0.1
13
+ username: test
14
+ password: test
15
+ events: true
16
+
17
+ drb: true
18
+
19
+ rails_env: production
@@ -0,0 +1,12 @@
1
+ # Adhearsion Runtime Configuration.
2
+
3
+ paths:
4
+
5
+ # All paths are relative to this file's directory
6
+ init: config/adhearsion.rb
7
+
8
+ dialplan: app/dialplan.rb
9
+
10
+ events: app/events.rb
11
+
12
+ models: app/models/*.rb
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ahn-rails
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ben Langfeld
@@ -10,10 +10,97 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-19 00:00:00 +00:00
13
+ date: 2011-04-09 00:00:00 +01:00
14
14
  default_executable:
15
- dependencies: []
16
-
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: adhearsion
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 1.0.1
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-rails
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: 2.5.0
36
+ type: :development
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: cucumber
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 0.10.2
47
+ type: :development
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: aruba
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: 0.3.5
58
+ type: :development
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: rails
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.6
69
+ type: :development
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: mocha
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: 0.9.12
80
+ type: :development
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: bcrypt-ruby
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: 2.1.2
91
+ type: :development
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: sqlite3-ruby
95
+ prerelease: false
96
+ requirement: &id008 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.3.1
102
+ type: :development
103
+ version_requirements: *id008
17
104
  description: Stretch rails beyond the browser, easily
18
105
  email:
19
106
  - ben@langfeld.me
@@ -27,10 +114,21 @@ files:
27
114
  - .gitignore
28
115
  - Gemfile
29
116
  - LICENSE
117
+ - README.md
30
118
  - Rakefile
31
119
  - ahn-rails.gemspec
120
+ - features/app_generator.feature
121
+ - features/step_definitions/rails_setup_steps.rb
122
+ - features/support/env.rb
32
123
  - lib/ahn-rails.rb
33
124
  - lib/ahn-rails/version.rb
125
+ - lib/generators/ahn.rb
126
+ - lib/generators/ahn/app/USAGE
127
+ - lib/generators/ahn/app/app_generator.rb
128
+ - lib/generators/ahn/app/templates/adhearsion.rake
129
+ - lib/generators/ahn/app/templates/adhearsion.rb
130
+ - lib/generators/ahn/app/templates/adhearsion.yml
131
+ - lib/generators/ahn/app/templates/ahnrc
34
132
  has_rdoc: true
35
133
  homepage: http://benlangfeld.github.com/ahn-rails
36
134
  licenses: []
@@ -55,9 +153,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
153
  requirements: []
56
154
 
57
155
  rubyforge_project: ahn-rails
58
- rubygems_version: 1.5.2
156
+ rubygems_version: 1.6.1
59
157
  signing_key:
60
158
  specification_version: 3
61
159
  summary: Adhearsion helpers for Ruby on Rails
62
- test_files: []
63
-
160
+ test_files:
161
+ - features/app_generator.feature
162
+ - features/step_definitions/rails_setup_steps.rb
163
+ - features/support/env.rb