adhearsion 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake/testtask'
3
3
  require 'rake/rdoctask'
4
4
  require 'rake/gempackagetask'
5
5
 
6
- ADHEARSION_VERSION = `grep ahn -e '^\s*\$ADHEARSION_VERSION' | sed 's/[^[:digit:].]/''/g'`.strip
6
+ ADHEARSION_VERSION = File.read '.version'
7
7
  Summary = %{Adhearsion is a professional integration system for
8
8
  integrating anything and everything.}
9
9
 
@@ -105,4 +105,9 @@ task :update => [:repackage] do
105
105
  puts `gem uninstall adhearsion`
106
106
  `gem install pkg/adhearsion*.gem`
107
107
  puts "Done."
108
+ end
109
+
110
+ desc 'Create both the gem and the Trixbox RPM. Called "d" for "distribute"'
111
+ task :d => [:repackage] do
112
+ # Coming soon
108
113
  end
data/ahn CHANGED
@@ -34,12 +34,12 @@ usage = %"Usage:
34
34
  The helper management system is still under development. Not all of these
35
35
  commands will work. It's coming soon, though! :)"
36
36
 
37
- $ADHEARSION_VERSION = "0.7.0"
37
+ ADHEARSION_VERSION = File.read File.join(File.dirname(__FILE__), '.version')
38
38
  ARGV.unshift 'start' if ARGV.empty?
39
39
 
40
40
  case ARGV.shift
41
41
  when /help|-h|--h|-help|--help/ then puts usage
42
- when 'version' then puts "Adhearsion v#{$ADHEARSION_VERSION}"
42
+ when 'version' then puts "Adhearsion v#{ADHEARSION_VERSION}"
43
43
  when 'create'
44
44
  require 'fileutils'
45
45
  include FileUtils
@@ -120,7 +120,7 @@ when 'start'
120
120
 
121
121
  Dir.chdir app
122
122
 
123
- puts %{\nStarting Adhearsion v#{$ADHEARSION_VERSION}
123
+ puts %{\nStarting Adhearsion v#{ADHEARSION_VERSION}
124
124
  Written by Jay Phillips of Codemecca LLC, et al.
125
125
  http://adhearsion.com\n\n}
126
126
 
@@ -146,7 +146,7 @@ when 'start'
146
146
  end
147
147
 
148
148
  require 'adhearsion'
149
- require 'database'
149
+ require 'database' if CONFIG['enable_database']
150
150
  require 'servlet_container'
151
151
 
152
152
  # Load appropriate helpers
@@ -124,7 +124,7 @@ end
124
124
  # end
125
125
  #end
126
126
 
127
- class Fixnum
127
+ class Module
128
128
 
129
129
  # One ring is approximately six seconds.
130
130
  def rings() self*6 end
@@ -135,6 +135,9 @@ class Fixnum
135
135
  to_s =~ other
136
136
  end
137
137
 
138
+ def am() self end
139
+ def pm() self+12 end
140
+
138
141
  # Used by __case__ statements. For Adhearsion's purposes, passing
139
142
  # a Fixnum to a case statement will convert both the Fixnum operand
140
143
  # and other operand to Strings and then return their === equivalency.
@@ -143,6 +146,18 @@ class Fixnum
143
146
  end
144
147
  end
145
148
 
149
+ class Time
150
+ def weekday?() (1..5).include? wday end
151
+ def weekend?() !weekday? end
152
+ def sunday?() wday == 0 end
153
+ def monday?() wday == 1 end
154
+ def tuesday?() wday == 2 end
155
+ def wednesday?() wday == 3 end
156
+ def thursday?() wday == 4 end
157
+ def friday?() wday == 5 end
158
+ def saturday?() wday == 6 end
159
+ end
160
+
146
161
  class Hash
147
162
  def method_missing name, *args
148
163
  if name.to_s[-1] == ?= then self[name.to_s.chop.to_sym] = args.first
@@ -1,52 +1,10 @@
1
1
  require 'rubygems'
2
2
  require 'rake/testtask'
3
3
  require 'rake/rdoctask'
4
- require 'rake/gempackagetask'
5
4
 
6
- ADHEARSION_VERSION = '0.7.0'
7
5
  Summary = 'Adhearsion is a professional integration system for
8
6
  integrating anything and everything.'
9
7
 
10
- #task :default => [:test]
11
-
12
- #desc "Run the Adhearsion unit tests"
13
- #task :test do
14
- # Dir['test/*.rb'].each do |f| require f end
15
- #end
16
-
17
- gem_spec = Gem::Specification.new do |s|
18
-
19
- s.name = 'adhearsion'
20
- s.rubyforge_project = 'adhearsion'
21
- s.author = 'Jay Phillips'
22
- s.email = 'admin -at- jicksta dot com'
23
- s.version = ADHEARSION_VERSION
24
- s.summary = Summary
25
- s.homepage = 'http://adhearsion.com'
26
-
27
- s.add_dependency 'activerecord', '>= 1.14.4'
28
- s.add_dependency 'activesupport', '>= 1.3.1'
29
- s.add_dependency 'rake', '>= 0.7.1'
30
-
31
- s.platform = Gem::Platform::RUBY
32
- s.require_path = 'lib'
33
- s.executables = 'start_adhearsion' # ['start_adhearsion', 'ahn']
34
- s.bindir = '.'
35
- #s.extra_rdoc_files = ['LICENSE']
36
-
37
- include = Dir['**/*']
38
- exclude = Dir['{log,pkg}/**/*']
39
-
40
- s.files = include - exclude
41
-
42
- # test_files = Dir['tests/*.rb'] # Will be added when not so buggy
43
- end
44
-
45
- Rake::GemPackageTask.new gem_spec do |pkg|
46
- pkg.need_zip = false
47
- pkg.need_tar = false
48
- end
49
-
50
8
  #desc "Generate documentation for Adhearsion"
51
9
  #Rake::RDocTask.new do |rdoc|
52
10
  # rdoc.rdoc_dir 'doc'
@@ -64,16 +22,16 @@ task :wiki => [:rm_wiki] do
64
22
  puts `find docs/wiki`
65
23
  end
66
24
 
67
- desc "Removes all cached compiled RubyInline shared objects"
68
- task :purge_objects do
69
- `rm -rf ~/.ruby_inline/*`
70
- end
71
-
72
25
  desc "Removes the local copy of the wiki"
73
26
  task :rm_wiki do
74
27
  `rm -rf wiki.zip docs/wiki/`
75
28
  end
76
29
 
30
+ desc "Removes all cached compiled RubyInline shared objects"
31
+ task :purge_objects do
32
+ `rm -rf ~/.ruby_inline/*`
33
+ end
34
+
77
35
  desc "Prepares Adhearsion for a new release"
78
36
  task :prepare_release do
79
37
  # Remove log files
@@ -87,9 +45,6 @@ task :prepare_release do
87
45
  puts "WARNING: These files are not under version control:\n#{unversioned_files}" unless unversioned_files.empty?
88
46
  end
89
47
 
90
- desc "Simply prints the Adhearsion version."
91
- task :version do puts ADHEARSION_VERSION end
92
-
93
48
  desc 'Create sample databases per the config/migration.rb and database.yml files.'
94
49
  task :migrate do
95
50
  require 'config/migration'
@@ -1,11 +1,17 @@
1
1
  answer_before_call: true
2
2
  hangup_after_call: true
3
+ enable_database: false
3
4
 
4
- info:
5
- name: Codemecca LLC
6
- main_number: 409/767-2813
7
- street_address:
8
- city:
9
- state:
10
- zip:
11
- country: United States
5
+ # This information is completely optional. It may be the
6
+ # case that a particular helper you're using will need
7
+ # information about your company. If this is the case,
8
+ # it may be beneficial to fill in this information.
9
+ #
10
+ # info:
11
+ # name: Super Ultra Mega Corp
12
+ # main_number: 18005555555
13
+ # street_address: 123 Onetwothree Blvd
14
+ # city: Dallas
15
+ # state: Texas
16
+ # zip: 77777
17
+ # country: United States
@@ -16,20 +16,18 @@
16
16
  # * No database
17
17
  # |
18
18
  # | If you simply have no use for keeping any information about
19
- # | users, groups, or anything else, you can leave this entire
20
- # | file commented. You don't even need ActiveRecord installed.
19
+ # | users, groups, or anything else, change the "enable_database"
20
+ # | field to "false" in database.yml.
21
21
  # '____________________________________________________________
22
22
  #
23
23
  ### SETTING UP YOUR DATABASE WITH A SAMPLE SCHEMA
24
24
  #
25
- # If you would like run
25
+ # To make your Adhearsion app database-driven, you'll need to take a moment
26
+ # to configure your database.
26
27
  #
27
28
  # ActiveRecord resources:
28
29
  # * http://slash7.com/cheats/activerecord_cheatsheet.pdf
29
30
  #
30
- #
31
- # Uncomment the =begin/=end blocks to enable database access.
32
- #=begin
33
31
 
34
32
  require 'active_record'
35
33
  ActiveRecord::Base.logger = Logger.new 'logs/database.log', 10, 1.megabyte
@@ -38,13 +36,15 @@ ActiveRecord::Base.establish_connection YAML.load_file('config/database.yml')
38
36
  # When Adhearsion first encounters this Group class, it will automatically associate it
39
37
  # to the "groups" database.
40
38
  class Group < ActiveRecord::Base
41
- has_many :user
39
+ has_many :users
42
40
  end
43
41
 
44
42
  class User < ActiveRecord::Base
45
43
  validates_uniqueness_of :name
46
44
  validates_presence_of :name
47
45
  belongs_to :group
46
+ def busy?
47
+ # Include your own logic here!
48
+ false
49
+ end
48
50
  end
49
-
50
- #=end
@@ -1,3 +1,5 @@
1
+ # To use sqlite3, you'll need to have it installed. Try installing
2
+ # it with your system's package manager.
1
3
  adapter: sqlite3 # can also be "sqlite" for sqlite v2
2
4
  dbfile: config/adhearsion.sqlite3
3
5
 
@@ -1,56 +1,41 @@
1
+ # This is an example dialplan. Feel free to remove this file and
2
+ # start your dialplan from scratch.
1
3
 
2
- from_pwnyourphone {
3
- # You rock! Be awesome and record us a message! We'll put supportive messages on the podcast!"
4
- # Get ready to record. 5, 4, 3, 1 *BEEP*
5
- play %(you-rock record-us-a-message we-put-messages-on-podcast get-ready five-countdown beep)
6
- record :for => 3.minutes, :to => "/recordings/pwner.#{Time.now.to_i}.#{calleridnumber}.gsm"
7
- }
8
4
 
5
+ # This "internal" context would map over if Adhearsion were invoked
6
+ # in Asterisk's own "internal" context. For example, if you set up
7
+ # your extensions.conf file for Adhearsion as so:
8
+ #
9
+ # [internal]
10
+ # exten => _X.,1,AGI(agi://192.168.1.3)
11
+ #
12
+ # then, when Adhearsion receives that call, it sees it came from
13
+ # the "internal" context and invokes this.
9
14
  internal {
10
- callee = User.find_by_ivr_extension extension
11
- if callee
12
-
13
- voicemail extension if last_dial_status != :answer
14
-
15
- #elsif extension.to_s =~ //#/^(((\d{1,3})?\d{1{3})?[1-9]\d{2})?[1-9]\d{6}$/
16
- # puts "got here"
17
- # dial "SIP/#{extension}@sipphone"
18
- else
19
- case extension
20
- when 21 then play weather_report
21
- when 32 then dial "SIP/zoip@demo.zoip.org"
22
- when 888 then loop { print '.'; XBMC.sendkey XBMC.translate(wait_for_digit) }
23
- when 9999
24
- if rand(20) == 0
25
- play %W(a-connect-charge-of #{rand(50) + 10} cents-per-minute will-apply)
26
- sleep 1.second
27
- play %w(just-kidding-not-upset)
28
- end
29
- check_voicemail caller.voicemailbox
15
+ # In this example context you'll see use of a User object. This
16
+ # is intended to be an ActiveRecord object created from your
17
+ # config/database.rb file.
18
+ case extension
19
+ when 101...200
20
+ employee = Employee.find_by_extension extension
21
+ unless employee.busy? then dial employee
30
22
  else
31
- play 'all-your-base'
32
- end
33
- end
34
- }
23
+ voicemail extension
24
+ end
35
25
 
36
- old {
37
- case extension
38
- when 1 then play weather_report("Richardson, Texas")
39
- when 2 then play weather_report(input(5, :play => 'zip-code'))
40
- when 3 then +xbmc
41
- when 4
42
- dial :tweedledee
26
+ when 888 then play weather_report("Dallas, Texas")
27
+ when 999 then check_voicemail extension
28
+
29
+ # This is simply an example of including another context in
30
+ # the block of another context. Simply place a plus sign before
31
+ # its name. No need to even declare it above the context you
32
+ # enter it into.
33
+ when 999 then +joker_voicemail
43
34
  end
44
35
  }
45
-
46
- xbmc {
47
- loop {
48
- print '.'
49
- XBMC.sendkey XBMC.translate(wait_for_digit)
50
- }
51
- }
52
-
53
- from_gizmo {
54
- #dial :tweedledum
55
- +xbmc
56
- }
36
+ joker_voicemail {
37
+ play %w(a-connect-charge-of 22 cents-per-minute will-apply)
38
+ sleep 2.seconds
39
+ play 'just-kidding-not-upset'
40
+ check_voicemail extension
41
+ }
@@ -1,12 +1,39 @@
1
+ =begin Adhearsion metadata
2
+
3
+ name: Xbox Media Center Controller
4
+ author:
5
+ name: Jay Phillips
6
+ blog: http://jicksta.com
7
+ email: Jicksta -at- Gmail.com
8
+ instructions: >
9
+ Hacked xbox owners can use this helper to remotely control
10
+ their Xbox Media Center (XBMC) application. It works by
11
+ sending HTTP requests to XBMC's web server (which must be
12
+ enabled first), potentially emulating many different tasks.
13
+
14
+ See the XBMC's HTTP API at
15
+ http://www.xboxmediacenter.com/wiki/index.php?title=WebServerHTTP-API
16
+ for a full list of the available commands. Most often you'll
17
+ want to use the SendKey command in a loop, though, to take
18
+ in input. Here is how you may do that:
19
+
20
+ <pre>
21
+ loop { XBMC.sendkey XBMC.translate!(wait_for_digit) }
22
+ </pre>
23
+
24
+ That will take an infinite loop receiving keypad input,
25
+ converting it to the appropriate numerical key codes, then
26
+ sending a "SendKey" command with the translated argument.
27
+
28
+ =end
1
29
  class XBMC
2
30
  KEY_MAPPING = { '1'=>37, '2'=>166, '4'=>169, '5'=>11, '6'=>168, '8'=>167 }
3
31
  KEY_MAPPING.default = 0
4
32
  def XBMC.translate(key) KEY_MAPPING[key] end
5
33
  def XBMC.method_missing name, hash={}
6
- puts 'method missinggg'
7
34
  args = []
8
- hash = { :parameter => hash} unless hash.is_a? Hash
35
+ hash = { :parameter => hash} unless hash.kind_of? Hash
9
36
  hash.merge({:command => name}).each { |k,v| args << "#{k}=#{v}" }
10
- open("http://#{hash.ip || $HELPERS.xbmc.ip}/xbmcCmds/xbmcHttp?#{args * '&'}").read
37
+ open("http://#{hash['ip'] || $HELPERS['xbmc']['ip']}/xbmcCmds/xbmcHttp?#{args * '&'}").read
11
38
  end
12
39
  end
@@ -0,0 +1,49 @@
1
+ # This is an example dialplan. Be sure to use
2
+ internal {
3
+ callee = User.find_by_ivr_extension extension
4
+ if callee
5
+
6
+ voicemail extension if last_dial_status != :answer
7
+
8
+ #elsif extension.to_s =~ //#/^(((\d{1,3})?\d{1{3})?[1-9]\d{2})?[1-9]\d{6}$/
9
+ # puts "got here"
10
+ # dial "SIP/#{extension}@sipphone"
11
+ else
12
+ case extension
13
+ when 21 then play weather_report
14
+ when 32 then dial "SIP/zoip@demo.zoip.org"
15
+ when 888 then loop { print '.'; XBMC.sendkey XBMC.translate(wait_for_digit) }
16
+ when 9999
17
+ if rand(20) == 0
18
+ play %W(a-connect-charge-of #{rand(50) + 10} cents-per-minute will-apply)
19
+ sleep 1.second
20
+ play %w(just-kidding-not-upset)
21
+ end
22
+ check_voicemail caller.voicemailbox
23
+ else
24
+ play 'all-your-base'
25
+ end
26
+ end
27
+ }
28
+
29
+ old {
30
+ case extension
31
+ when 1 then play weather_report("Richardson, Texas")
32
+ when 2 then play weather_report(input(5, :play => 'zip-code'))
33
+ when 3 then +xbmc
34
+ when 4
35
+ dial :tweedledee
36
+ end
37
+ }
38
+
39
+ xbmc {
40
+ loop {
41
+ print '.'
42
+ XBMC.sendkey XBMC.translate(wait_for_digit)
43
+ }
44
+ }
45
+
46
+ from_gizmo {
47
+ #dial :tweedledum
48
+ +xbmc
49
+ }
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: adhearsion
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.7.0
7
- date: 2006-12-26 00:00:00 -06:00
6
+ version: 0.7.1
7
+ date: 2006-12-29 00:00:00 -06:00
8
8
  summary: Adhearsion is a professional integration system for integrating anything and everything.
9
9
  require_paths:
10
10
  - lib
@@ -46,6 +46,7 @@ files:
46
46
  - new_projects/extensions.rb
47
47
  - new_projects/helpers
48
48
  - new_projects/logs
49
+ - new_projects/old.extensions.rb
49
50
  - new_projects/Rakefile
50
51
  - new_projects/config/adhearsion.sqlite3
51
52
  - new_projects/config/adhearsion.yml
@@ -85,10 +86,7 @@ files:
85
86
  - new_projects/logs/database.log
86
87
  - test/core_extensions_test.rb
87
88
  - test/dial_test.rb
88
- - test/stress_tests
89
89
  - test/test_micromenus.rb
90
- - test/stress_tests/test.rb
91
- - test/stress_tests/test.yml
92
90
  test_files: []
93
91
 
94
92
  rdoc_options: []
@@ -1,13 +0,0 @@
1
- require 'yaml'
2
- x = YAML.load_file 'test.yml'
3
- threads = []
4
- x[x.keys.first].keys.grep(/\d+_times/)
5
-
6
-
7
- 1_000.times do
8
- threads.push(Thread.new do
9
-
10
- end)
11
- end
12
-
13
- threads.select { |s| s.start }
@@ -1,13 +0,0 @@
1
- outboundcalls:
2
- 100_times:
3
- extension: 14097672813
4
- context: outbound
5
-
6
- testjaysextension:
7
- 120_times:
8
- context: internal
9
-
10
- testmikesextension:
11
- 100_times:
12
- extension: 1404
13
- context: default