Permalink
Browse files

Rename to adhearsion-drb with appropriate namespacing in Adhearsion::Drb

  • Loading branch information...
1 parent aed8272 commit 7902c75deb5ca0fba912e505f2ef64349e7b9436 @benlangfeld benlangfeld committed Nov 30, 2011
View
@@ -2,3 +2,4 @@
.bundle
Gemfile.lock
pkg/*
+vendor/ruby
View
@@ -2,5 +2,5 @@ source "http://rubygems.org"
gem 'adhearsion', :git => 'git://github.com/adhearsion/adhearsion.git', :branch => :develop
-# Specify your gem's dependencies in ahn-drb.gemspec
+# Specify your gem's dependencies in adhearsion-drb.gemspec
gemspec
View
@@ -1,7 +1,7 @@
-ahn-drb
+adhearsion-drb
=======
-ahn-drb is an Adhearsion Plugin providing DRb connectivity.
+adhearsion-drb is an Adhearsion Plugin providing DRb connectivity.
Features
--------
@@ -16,15 +16,15 @@ Requirements
Install
-------
-Add `ahn-drb` to your Adhearsion app's Gemfile.
+Add `adhearsion-drb` to your Adhearsion app's Gemfile.
Configuration
-------------
In your Adhearsion app configuration file, add the following values:
```ruby
-Adhearsion.config[:ahn_drb] do |config|
+Adhearsion.config[:adhearsion_drb] do |config|
config.host = "DRb service host"
config.port = "DRB service port".to_i
config.acl.allow = ["127.0.0.1"] # list of allowed IPs (optional)
@@ -39,9 +39,9 @@ Original author: [Juan de Bravo](https://github.com/juandebravo)
Links
-----
-* [Source](https://github.com/adhearsion/ahn-drb)
-* [Documentation](http://rdoc.info/github/adhearsion/ahn-drb/master/frames)
-* [Bug Tracker](https://github.com/adhearsion/ahn-drb/issues)
+* [Source](https://github.com/adhearsion/adhearsion-drb)
+* [Documentation](http://rdoc.info/github/adhearsion/adhearsion-drb/master/frames)
+* [Bug Tracker](https://github.com/adhearsion/adhearsion-drb/issues)
Note on Patches/Pull Requests
-----------------------------
@@ -56,4 +56,4 @@ Note on Patches/Pull Requests
Copyright
---------
-Check [License file](https://github.com/adhearsion/ahn-drb/blob/master/LICENSE)
+Check [License file](https://github.com/adhearsion/adhearsion-drb/blob/master/LICENSE)
View
@@ -2,7 +2,6 @@ require "bundler/gem_tasks"
require "bundler/setup"
-
task :default => :spec
require 'rspec/core'
@@ -1,17 +1,17 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
-require "ahn_drb/version"
+require "adhearsion/drb/version"
Gem::Specification.new do |s|
- s.name = "ahn-drb"
- s.version = AhnDrb::VERSION
+ s.name = "adhearsion-drb"
+ s.version = Adhearsion::Drb::VERSION
s.authors = ["juandebravo", "Ben Langfeld", "Jason Goecke"]
s.email = ["juandebravo@gmail.com", "ben@langfeld.me", "jsgoecke@voxeo.com"]
s.homepage = ""
s.summary = %q{This gem is an Adhearsion plugin that handles the Drb related stuff}
s.description = %q{This gem is an Adhearsion plugin that handles the Drb related stuff}
- s.rubyforge_project = "ahn-drb"
+ s.rubyforge_project = "adhearsion-drb"
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
View
@@ -0,0 +1 @@
+require 'adhearsion/drb'
View
@@ -0,0 +1,13 @@
+require "adhearsion"
+require "active_support/dependencies/autoload"
+
+require "adhearsion/drb/plugin"
+require "adhearsion/drb/version"
+
+module Adhearsion
+ module Drb
+ extend ActiveSupport::Autoload
+
+ autoload :Plugin
+ end
+end
@@ -0,0 +1,32 @@
+module Adhearsion
+ module Drb
+
+ ##
+ # Adhearsion Plugin definition that defines the DRb configuration options
+ # and includes a hook to start the DRb service in Adhearsion initialization process
+ class Plugin < Adhearsion::Plugin
+ extend ActiveSupport::Autoload
+
+ autoload :Service
+
+ # Default configuration
+ config :adhearsion_drb do
+ host "localhost", :desc => "DRb service host"
+ port 9050 , :desc => "DRb service port"
+
+ desc "Access Control List configuration for the DRb service"
+ acl {
+ allow ["127.0.0.1"], :desc => "list of valid IP addresses to access DRb service"
+ deny [] , :desc => "list of invalid IP addresses to access DRb service"
+ }
+ end
+
+ # Include the DRb service in plugins initialization process
+ init :adhearsion_drb do
+ Service.start
+ end
+
+ end
+
+ end
+end
@@ -0,0 +1,81 @@
+require 'drb'
+require 'drb/acl'
+
+module Adhearsion
+ module Drb
+ class Plugin
+ class Service
+
+ class << self
+
+ ##
+ # Start the DRb service
+ def start
+ acl = create_acl config.acl.allow, config.acl.deny
+
+ DRb.install_acl ACL.new(acl) unless acl.empty?
+
+ logger.info "Starting DRb on #{config.host}:#{config.port}"
+ DRb.start_service "druby://#{config.host}:#{config.port}", create_drb_door
+ end
+
+ ##
+ # Stop the DRb service
+ def stop
+ logger.info "Stoping DRb on #{config.host}:#{config.port}"
+ DRb.stop_service
+ end
+
+ ##
+ # Access to Drb plugin configuration
+ def config
+ @config ||= Adhearsion.config[:adhearsion_drb]
+ end
+
+ ##
+ # Creates a plain object and injects the Adhearsion RPC methods configured via plugins
+ # @return [Object]
+ def create_drb_door
+ Plugin.add_rpc_methods Object.new
+ end
+
+ ##
+ # Creates an array that maps the DRb ACL format, that is:
+ # - a set of zero or more allowed IP addresses. Any allowed IP address is preceded by an "allow" element
+ # ["allow", "127.0.0.1", "allow", "www.adhearsion.com"]
+ # - a set of zero or more allowed IP addresses. Any denied IP address is preceded by an "deny" element
+ # ["deny", "192.168.2.*", "deny", "192.168.3.*"]
+ #
+ # - All together:
+ # ["allow", "127.0.0.1", "allow", "www.adhearsion.com", "deny", "192.168.2.*", "deny", "192.168.3.*"]
+ #
+ # @param allow [String, Array] zero or more allowed IPs
+ # @param deny [String, Array] zero or more denied IPs
+ #
+ # @return [Array]
+ def create_acl allow = nil, deny = nil
+ if allow.is_a?(String) && allow.empty?
+ allow = nil
+ end
+ if deny.is_a?(String) && deny.empty?
+ deny = nil
+ end
+
+ allow = Array(allow)
+ deny = Array(deny)
+ value = String.new
+
+ unless allow.empty? && deny.empty?
+ value.concat("allow ").concat(allow.join(" allow ")) unless allow.empty?
+ value.concat(" ") if !allow.empty? && !deny.empty?
+ value.concat("deny ").concat(deny.join(" deny ")) unless deny.empty?
+ end
+
+ value.split
+ end
+
+ end
+ end
+ end
+ end
+end
@@ -0,0 +1,5 @@
+module Adhearsion
+ module Drb
+ VERSION = "0.1.0"
+ end
+end
View
@@ -1,13 +0,0 @@
-require "adhearsion"
-require "active_support/dependencies/autoload"
-
-require "ahn_drb/plugin"
-require "ahn_drb/version"
-
-module AhnDrb
-
- extend ActiveSupport::Autoload
-
- autoload :Plugin
-
-end
View
@@ -1,31 +0,0 @@
-
-module AhnDrb
-
- ##
- # Adhearsion Plugin definition that defines the DRb configuration options
- # and includes a hook to start the DRb service in Adhearsion initialization process
- class Plugin < Adhearsion::Plugin
- extend ActiveSupport::Autoload
-
- autoload :Service
-
- # Default configuration
- config :ahn_drb do
- host "localhost", :desc => "DRb service host"
- port 9050 , :desc => "DRb service port"
-
- desc "Access Control List configuration for the DRb service"
- acl {
- allow ["127.0.0.1"], :desc => "list of valid IP addresses to access DRb service"
- deny [] , :desc => "list of invalid IP addresses to access DRb service"
- }
- end
-
- # Include the DRb service in plugins initialization process
- init :ahn_drb do
- Service.start
- end
-
- end
-
-end
@@ -1,81 +0,0 @@
-require 'drb'
-require 'drb/acl'
-
-module AhnDrb
-
- class Plugin
-
- class Service
-
- class << self
-
- ##
- # Start the DRb service
- def start
- acl = create_acl config.acl.allow, config.acl.deny
-
- DRb.install_acl ACL.new(acl) unless acl.empty?
-
- logger.info "Starting DRb on #{config.host}:#{config.port}"
- DRb.start_service "druby://#{config.host}:#{config.port}", create_drb_door
- end
-
- ##
- # Stop the DRb service
- def stop
- logger.info "Stoping DRb on #{config.host}:#{config.port}"
- DRb.stop_service
- end
-
- ##
- # Access to Drb plugin configuration
- def config
- @config ||= Adhearsion.config[:ahn_drb]
- end
-
- ##
- # Creates a plain object and injects the Adhearsion RPC methods configured via plugins
- # @return [Object]
- def create_drb_door
- Plugin.add_rpc_methods Object.new
- end
-
- ##
- # Creates an array that maps the DRb ACL format, that is:
- # - a set of zero or more allowed IP addresses. Any allowed IP address is preceded by an "allow" element
- # ["allow", "127.0.0.1", "allow", "www.adhearsion.com"]
- # - a set of zero or more allowed IP addresses. Any denied IP address is preceded by an "deny" element
- # ["deny", "192.168.2.*", "deny", "192.168.3.*"]
- #
- # - All together:
- # ["allow", "127.0.0.1", "allow", "www.adhearsion.com", "deny", "192.168.2.*", "deny", "192.168.3.*"]
- #
- # @param allow [String, Array] zero or more allowed IPs
- # @param deny [String, Array] zero or more denied IPs
- #
- # @return [Array]
- def create_acl allow = nil, deny = nil
- if allow.is_a?(String) && allow.empty?
- allow = nil
- end
- if deny.is_a?(String) && deny.empty?
- deny = nil
- end
-
- allow = Array(allow)
- deny = Array(deny)
- value = String.new
-
- unless allow.empty? && deny.empty?
- value.concat("allow ").concat(allow.join(" allow ")) unless allow.empty?
- value.concat(" ") if !allow.empty? && !deny.empty?
- value.concat("deny ").concat(deny.join(" deny ")) unless deny.empty?
- end
-
- value.split
- end
-
- end
- end
- end
-end
View
@@ -1,3 +0,0 @@
-module AhnDrb
- VERSION = "0.1.0"
-end
Oops, something went wrong.

0 comments on commit 7902c75

Please sign in to comment.