adhearsion-drb 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4f4baa8f80dc36c1547ba0f0a0e6e407846bd243
4
+ data.tar.gz: 446db4156541d6eba3beedf3aa4d431e45fc4813
5
+ SHA512:
6
+ metadata.gz: 028068c753729f5e06861af215c0176ae7543a0034f240f9496a8b4113995a4078f1acb02f2faca6aa8fb378bddf8f825d33eedc7233e9930bc30013b8bf8cbe
7
+ data.tar.gz: 51aeee02aace6c956c917cf366fc4dbf661296bed9b21af825871aba641547a712e989b813675061f0fc3ca3f825a70b391cca0f3cf8657a53cad2320fad99f7
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - jruby-19mode
7
+ - rbx-2.1.1
8
+ - ruby-head
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: rbx-2.1.1
12
+ - rvm: ruby-head
data/CHANGELOG.md CHANGED
@@ -1,2 +1,6 @@
1
+ # 1.1.0
2
+ * Make the server restart when it goes away
3
+ * Add travis config
4
+
1
5
  # v1.0.0
2
6
  * First release
data/README.md CHANGED
@@ -1,12 +1,7 @@
1
- adhearsion-drb
1
+ adhearsion-drb [![Build Status](http://ci.mojolingo.com/job/adhearsion-drb/badge/icon)](http://ci.mojolingo.com/job/adhearsion-drb/)
2
2
  =======
3
3
 
4
- adhearsion-drb is an Adhearsion Plugin providing DRb connectivity.
5
-
6
- Features
7
- --------
8
-
9
- * FIXME (list of features and unsolved problems)
4
+ adhearsion-drb is an Adhearsion Plugin providing DRb connectivity. It allows third party ruby clients to connect to an Adhearsion instance for RPC.
10
5
 
11
6
  Requirements
12
7
  ------------
@@ -29,9 +24,55 @@ Adhearsion.config[:adhearsion_drb] do |config|
29
24
  config.port = "DRB service port".to_i
30
25
  config.acl.allow = ["127.0.0.1"] # list of allowed IPs (optional)
31
26
  config.acl.deny = [] # list of denied IPs (optional)
27
+ config.shared_object = some_shared_object
28
+ end
29
+ ```
30
+
31
+ The `shared_object` in the config is the endpoint to which a 3rd-party client will be bound on connection. The most basic scenario looks something like this:
32
+
33
+ ```ruby
34
+ class DrbEndpoint
35
+ def foo
36
+ :bar
37
+ end
38
+ end
39
+
40
+ Adhearsion.config.adhearsion_drb.shared_object = DrbEndpoint.new
41
+ ```
42
+
43
+ with the following client:
44
+
45
+ ```ruby
46
+ require 'drb'
47
+ adhearsion_api = DRbObject.new_with_uri 'druby://localhost:9050'
48
+ p adhearsion_api.foo
49
+ ```
50
+
51
+ When the Adhearsion application is running, and the client script runs, it should print `:foo` to stdout.
52
+
53
+ A more useful example to return the number of active calls:
54
+
55
+ ```ruby
56
+ class DrbEndpoint
57
+ def call_count
58
+ Adhearsion.active_calls.count
59
+ end
32
60
  end
33
61
  ```
34
62
 
63
+ Or to trigger an outbound call:
64
+
65
+ ```ruby
66
+ class DrbEndpoint
67
+ def place_call(number, provider)
68
+ call = Adhearsion::OutboundCall.originate "SIP/#{number}@#{provider}", controller: FooController
69
+ call.id
70
+ end
71
+ end
72
+ ```
73
+
74
+ NB: Be careful not to define `#call` on your shared object, else it will be evaluated by the config system incorrectly.
75
+
35
76
  Author
36
77
  ------
37
78
 
@@ -19,12 +19,12 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_runtime_dependency "adhearsion", ["~> 2.0"]
22
- s.add_runtime_dependency "activesupport", [">= 3.0.10"]
23
22
  s.add_runtime_dependency "i18n", ">= 0.5.0"
23
+ s.add_runtime_dependency "jruby-openssl" if RUBY_PLATFORM == 'java'
24
24
 
25
25
  s.add_development_dependency "rspec", "~> 2.7.0"
26
26
  s.add_development_dependency "flexmock"
27
27
  s.add_development_dependency "guard-rspec"
28
28
  s.add_development_dependency "rake", ">= 0.9.2"
29
+ s.add_development_dependency "thor", "~> 0.14.0"
29
30
  end
30
-
@@ -1,3 +1,5 @@
1
+ require 'adhearsion/drb/service'
2
+
1
3
  module Adhearsion
2
4
  module Drb
3
5
 
@@ -5,10 +7,6 @@ module Adhearsion
5
7
  # Adhearsion Plugin definition that defines the DRb configuration options
6
8
  # and includes a hook to start the DRb service in Adhearsion initialization process
7
9
  class Plugin < Adhearsion::Plugin
8
- extend ActiveSupport::Autoload
9
-
10
- autoload :Service
11
-
12
10
  # Default configuration
13
11
  config :adhearsion_drb do
14
12
  host "localhost", :desc => "DRb service host"
@@ -0,0 +1,101 @@
1
+ require 'drb'
2
+ require 'drb/acl'
3
+
4
+ module Adhearsion
5
+ module Drb
6
+ class Service
7
+ include Singleton
8
+
9
+ attr_accessor :user_stopped
10
+
11
+ def initialize
12
+ @user_stopped = false
13
+ acl = create_acl config.acl.allow, config.acl.deny
14
+ DRb.install_acl ACL.new(acl) unless acl.empty?
15
+ end
16
+
17
+ ##
18
+ # Start the DRb service
19
+ def start
20
+ logger.info "Starting DRb on #{config.host}:#{config.port}"
21
+ DRb.start_service "druby://#{config.host}:#{config.port}", create_drb_door
22
+ logger.info "DRB Started on #{DRb.uri}"
23
+ keep_service_running!
24
+ end
25
+
26
+ ##
27
+ # Stop the DRb service
28
+ def stop
29
+ @user_stopped = true
30
+ logger.info "Stopping DRb on #{config.host}:#{config.port}"
31
+ DRb.stop_service
32
+ end
33
+
34
+ private
35
+
36
+ ##
37
+ # Access to Drb plugin configuration
38
+ def config
39
+ @config ||= Adhearsion.config[:adhearsion_drb]
40
+ end
41
+
42
+ ##
43
+ # Creates a plain object and injects the Adhearsion RPC methods configured via plugins
44
+ # @return [Object]
45
+ def create_drb_door
46
+ config[:shared_object]
47
+ end
48
+
49
+ ##
50
+ # Creates an array that maps the DRb ACL format, that is:
51
+ # - a set of zero or more allowed IP addresses. Any allowed IP address is preceded by an "allow" element
52
+ # ["allow", "127.0.0.1", "allow", "www.adhearsion.com"]
53
+ # - a set of zero or more allowed IP addresses. Any denied IP address is preceded by an "deny" element
54
+ # ["deny", "192.168.2.*", "deny", "192.168.3.*"]
55
+ #
56
+ # - All together:
57
+ # ["allow", "127.0.0.1", "allow", "www.adhearsion.com", "deny", "192.168.2.*", "deny", "192.168.3.*"]
58
+ #
59
+ # @param allow [String, Array] zero or more allowed IPs
60
+ # @param deny [String, Array] zero or more denied IPs
61
+ #
62
+ # @return [Array]
63
+ def create_acl allow = nil, deny = nil
64
+ if allow.is_a?(String) && allow.empty?
65
+ allow = nil
66
+ end
67
+ if deny.is_a?(String) && deny.empty?
68
+ deny = nil
69
+ end
70
+
71
+ allow = Array(allow)
72
+ deny = Array(deny)
73
+ value = String.new
74
+
75
+ unless allow.empty? && deny.empty?
76
+ value.concat("allow ").concat(allow.join(" allow ")) unless allow.empty?
77
+ value.concat(" ") if !allow.empty? && !deny.empty?
78
+ value.concat("deny ").concat(deny.join(" deny ")) unless deny.empty?
79
+ end
80
+
81
+ value.split
82
+ end
83
+
84
+ def keep_service_running!
85
+ Thread.new do
86
+ DRb.thread.join
87
+ if user_stopped
88
+ logger.info "DRb process stopped."
89
+ else
90
+ logger.warn "DRb thread finished, restarting..."
91
+ start
92
+ end
93
+ end
94
+ end
95
+
96
+ def self.method_missing(method_name, *args, &block)
97
+ instance.send method_name, *args, &block
98
+ end
99
+ end
100
+ end
101
+ end
@@ -1,5 +1,5 @@
1
1
  module Adhearsion
2
2
  module Drb
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -1,13 +1,9 @@
1
1
  require "adhearsion"
2
- require "active_support/dependencies/autoload"
3
-
4
- require "adhearsion/drb/plugin"
5
- require "adhearsion/drb/version"
6
2
 
7
3
  module Adhearsion
8
4
  module Drb
9
- extend ActiveSupport::Autoload
10
-
11
- autoload :Plugin
12
5
  end
13
6
  end
7
+
8
+ require "adhearsion/drb/plugin"
9
+ require "adhearsion/drb/version"
@@ -9,19 +9,19 @@ describe Adhearsion::Drb::Plugin do
9
9
  Adhearsion.config.adhearsion_drb.should be_instance_of Loquacious::Configuration
10
10
  end
11
11
 
12
- it "should configure properly the host" do
12
+ it "should listen on localhost by default" do
13
13
  Adhearsion.config.adhearsion_drb.host.should == "localhost"
14
14
  end
15
15
 
16
- it "should configure properly the port" do
16
+ it "should use the default port of 9050" do
17
17
  Adhearsion.config.adhearsion_drb.port.should == 9050
18
18
  end
19
19
 
20
- it "should configure properly the deny access" do
20
+ it "should default to an empty deny acl" do
21
21
  Adhearsion.config.adhearsion_drb.acl.deny.should have(0).hosts
22
22
  end
23
23
 
24
- it "should configure properly the allow access" do
24
+ it "should default to an allow acl of only 127.0.0.1" do
25
25
  subject.adhearsion_drb.acl.allow.should == ["127.0.0.1"]
26
26
  end
27
27
 
@@ -75,10 +75,12 @@ describe Adhearsion::Drb::Plugin do
75
75
 
76
76
  describe "while initializing" do
77
77
 
78
+ after { Adhearsion::Drb::Service.stop }
79
+
78
80
  it "should start the service" do
79
- Adhearsion::Drb::Plugin::Service.should_receive(:start).and_return true
81
+ Adhearsion::Drb::Service.user_stopped = false
82
+ Adhearsion::Drb::Service.should_receive(:start).and_return true
80
83
  Adhearsion::Plugin.init_plugins
81
84
  end
82
-
83
85
  end
84
- end
86
+ end
@@ -1,12 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Adhearsion::Drb::Plugin::Service do
3
+ describe Adhearsion::Drb::Service do
4
4
 
5
5
  before :all do
6
6
  @host = Adhearsion.config[:adhearsion_drb].host
7
7
  @port = Adhearsion.config[:adhearsion_drb].port
8
8
  @allow = Adhearsion.config[:adhearsion_drb].acl.allow.dup
9
9
  @deny = Adhearsion.config[:adhearsion_drb].acl.deny.dup
10
+ # Use a random high port to prevent concurrent test runs from getting
11
+ # Errno::EADDRINUSE
12
+ # Ruby 1.9.2 version of #rand only allows 1 arg; do some math to keep the range right
13
+ Adhearsion.config[:adhearsion_drb].port = rand(65535 - 1024) + 1024
10
14
  end
11
15
 
12
16
  after :all do
@@ -19,25 +23,25 @@ describe Adhearsion::Drb::Plugin::Service do
19
23
  describe "while creating the acl value" do
20
24
 
21
25
  it "should return <allow 127.0.0.1> as default value" do
22
- Adhearsion::Drb::Plugin::Service.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == %w<allow 127.0.0.1>
26
+ described_class.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == %w<allow 127.0.0.1>
23
27
  end
24
28
 
25
29
  it "should return an empty string when no rule is defined" do
26
30
  Adhearsion.config.adhearsion_drb.acl.allow = []
27
31
  Adhearsion.config.adhearsion_drb.acl.deny = []
28
- Adhearsion::Drb::Plugin::Service.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == []
32
+ described_class.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == []
29
33
  end
30
34
 
31
35
  it "should return an empty string when allow and deny are nil" do
32
36
  Adhearsion.config.adhearsion_drb.acl.allow = nil
33
37
  Adhearsion.config.adhearsion_drb.acl.deny = nil
34
- Adhearsion::Drb::Plugin::Service.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == []
38
+ described_class.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == []
35
39
  end
36
40
 
37
41
  it "should return an empty string when allow and deny are empty" do
38
42
  Adhearsion.config.adhearsion_drb.acl.allow = ""
39
43
  Adhearsion.config.adhearsion_drb.acl.deny = ""
40
- Adhearsion::Drb::Plugin::Service.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == []
44
+ described_class.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == []
41
45
  end
42
46
 
43
47
  describe "having configured deny" do
@@ -47,12 +51,12 @@ describe Adhearsion::Drb::Plugin::Service do
47
51
 
48
52
  it "should return an array with <deny 10.1.*.* deny 10.0.*.*>" do
49
53
  Adhearsion.config.adhearsion_drb.acl.deny = %w<10.1.*.* 10.0.*.*>
50
- Adhearsion::Drb::Plugin::Service.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == %w<deny 10.1.*.* deny 10.0.*.*>
54
+ described_class.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == %w<deny 10.1.*.* deny 10.0.*.*>
51
55
  end
52
56
 
53
57
  it "should return an array with <deny 10.1.*.*>" do
54
58
  Adhearsion.config.adhearsion_drb.acl.deny = "10.1.*.*"
55
- Adhearsion::Drb::Plugin::Service.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == %w<deny 10.1.*.*>
59
+ described_class.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == %w<deny 10.1.*.*>
56
60
  end
57
61
  end
58
62
 
@@ -63,12 +67,12 @@ describe Adhearsion::Drb::Plugin::Service do
63
67
 
64
68
  it "should return an array with <allow 127.0.0.1 allow 10.0.0.1> when another IP is allowed" do
65
69
  Adhearsion.config.adhearsion_drb.acl.allow = %w<127.0.0.1 10.0.0.1>
66
- Adhearsion::Drb::Plugin::Service.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == %w<allow 127.0.0.1 allow 10.0.0.1>
70
+ described_class.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == %w<allow 127.0.0.1 allow 10.0.0.1>
67
71
  end
68
72
 
69
73
  it "should return an array with <allow 10.0.0.1> when another IP is allowed" do
70
74
  Adhearsion.config.adhearsion_drb.acl.allow = "10.0.0.1"
71
- Adhearsion::Drb::Plugin::Service.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == %w<allow 10.0.0.1>
75
+ described_class.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == %w<allow 10.0.0.1>
72
76
  end
73
77
  end
74
78
 
@@ -77,13 +81,13 @@ describe Adhearsion::Drb::Plugin::Service do
77
81
  it "should return an array with <allow 127.0.0.1 allow 10.2.*.* deny 10.1.*.* deny 10.0.*.*>" do
78
82
  Adhearsion.config.adhearsion_drb.acl.allow = %w<127.0.0.1 10.2.*.*>
79
83
  Adhearsion.config.adhearsion_drb.acl.deny = %w<10.1.*.* 10.0.*.*>
80
- Adhearsion::Drb::Plugin::Service.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == %w<allow 127.0.0.1 allow 10.2.*.* deny 10.1.*.* deny 10.0.*.*>
84
+ described_class.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == %w<allow 127.0.0.1 allow 10.2.*.* deny 10.1.*.* deny 10.0.*.*>
81
85
  end
82
86
 
83
87
  it "should return an array with <allow 127.0.0.1 deny 10.1.*.*>" do
84
88
  Adhearsion.config.adhearsion_drb.acl.allow = "127.0.0.1"
85
89
  Adhearsion.config.adhearsion_drb.acl.deny = "10.1.*.*"
86
- Adhearsion::Drb::Plugin::Service.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == %w<allow 127.0.0.1 deny 10.1.*.*>
90
+ described_class.create_acl(Adhearsion.config.adhearsion_drb.acl.allow, Adhearsion.config.adhearsion_drb.acl.deny).should == %w<allow 127.0.0.1 deny 10.1.*.*>
87
91
  end
88
92
  end
89
93
  end
@@ -97,22 +101,21 @@ describe Adhearsion::Drb::Plugin::Service do
97
101
  def foo
98
102
  [3,2,1]
99
103
  end
100
- end
101
104
 
102
- let :client do
103
- DRbObject.new nil, DRb.uri
105
+ def halt_drb_directly!
106
+ DRb.stop_service
107
+ end
104
108
  end
105
109
 
106
- before do
107
- Adhearsion.config.adhearsion_drb.acl.allow = %q<127.0.0.1>
108
- Adhearsion.config.adhearsion_drb.acl.deny = nil
110
+ let(:client) { DRbObject.new nil, DRb.uri }
111
+
112
+ before(:all) do
113
+ Adhearsion.config.adhearsion_drb.acl.allow = %q<127.0.0.1>
114
+ Adhearsion.config.adhearsion_drb.acl.deny = nil
109
115
  Adhearsion.config.adhearsion_drb.shared_object = Blah.new
110
-
111
- Adhearsion::Plugin.init_plugins
112
- end
113
116
 
114
- after do
115
- Adhearsion::Drb::Plugin::Service.stop
117
+ Adhearsion::Drb::Service.user_stopped = false
118
+ Adhearsion::Drb::Service.start
116
119
  end
117
120
 
118
121
  it "should return normal Ruby data structures properly over DRb" do
@@ -123,6 +126,17 @@ describe Adhearsion::Drb::Plugin::Service do
123
126
  lambda { client.interface.bad_interface.should be [3, 2, 1] }.should raise_error NoMethodError
124
127
  end
125
128
 
126
- end
129
+ it "restarts the server if DRb's thread ends" do
130
+ client.halt_drb_directly!
131
+ sleep 2
132
+ client.foo.should == [3, 2, 1]
133
+ end
127
134
 
135
+ it "does not start up again if Service.stop is called" do
136
+ Adhearsion::Drb::Service.should_not_receive :start
137
+ Adhearsion::Drb::Service.stop
138
+ sleep 0.10
139
+ lambda { client.foo }.should raise_error DRb::DRbServerNotFound
140
+ end
141
+ end
128
142
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adhearsion-drb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 1.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - juandebravo
@@ -11,12 +10,11 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2012-04-11 00:00:00.000000000 Z
13
+ date: 2014-03-10 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: adhearsion
18
17
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
19
  - - ~>
22
20
  - !ruby/object:Gem::Version
@@ -24,47 +22,27 @@ dependencies:
24
22
  type: :runtime
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
25
  requirements:
29
26
  - - ~>
30
27
  - !ruby/object:Gem::Version
31
28
  version: '2.0'
32
- - !ruby/object:Gem::Dependency
33
- name: activesupport
34
- requirement: !ruby/object:Gem::Requirement
35
- none: false
36
- requirements:
37
- - - ! '>='
38
- - !ruby/object:Gem::Version
39
- version: 3.0.10
40
- type: :runtime
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
- requirements:
45
- - - ! '>='
46
- - !ruby/object:Gem::Version
47
- version: 3.0.10
48
29
  - !ruby/object:Gem::Dependency
49
30
  name: i18n
50
31
  requirement: !ruby/object:Gem::Requirement
51
- none: false
52
32
  requirements:
53
- - - ! '>='
33
+ - - '>='
54
34
  - !ruby/object:Gem::Version
55
35
  version: 0.5.0
56
36
  type: :runtime
57
37
  prerelease: false
58
38
  version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
39
  requirements:
61
- - - ! '>='
40
+ - - '>='
62
41
  - !ruby/object:Gem::Version
63
42
  version: 0.5.0
64
43
  - !ruby/object:Gem::Dependency
65
44
  name: rspec
66
45
  requirement: !ruby/object:Gem::Requirement
67
- none: false
68
46
  requirements:
69
47
  - - ~>
70
48
  - !ruby/object:Gem::Version
@@ -72,7 +50,6 @@ dependencies:
72
50
  type: :development
73
51
  prerelease: false
74
52
  version_requirements: !ruby/object:Gem::Requirement
75
- none: false
76
53
  requirements:
77
54
  - - ~>
78
55
  - !ruby/object:Gem::Version
@@ -80,51 +57,59 @@ dependencies:
80
57
  - !ruby/object:Gem::Dependency
81
58
  name: flexmock
82
59
  requirement: !ruby/object:Gem::Requirement
83
- none: false
84
60
  requirements:
85
- - - ! '>='
61
+ - - '>='
86
62
  - !ruby/object:Gem::Version
87
63
  version: '0'
88
64
  type: :development
89
65
  prerelease: false
90
66
  version_requirements: !ruby/object:Gem::Requirement
91
- none: false
92
67
  requirements:
93
- - - ! '>='
68
+ - - '>='
94
69
  - !ruby/object:Gem::Version
95
70
  version: '0'
96
71
  - !ruby/object:Gem::Dependency
97
72
  name: guard-rspec
98
73
  requirement: !ruby/object:Gem::Requirement
99
- none: false
100
74
  requirements:
101
- - - ! '>='
75
+ - - '>='
102
76
  - !ruby/object:Gem::Version
103
77
  version: '0'
104
78
  type: :development
105
79
  prerelease: false
106
80
  version_requirements: !ruby/object:Gem::Requirement
107
- none: false
108
81
  requirements:
109
- - - ! '>='
82
+ - - '>='
110
83
  - !ruby/object:Gem::Version
111
84
  version: '0'
112
85
  - !ruby/object:Gem::Dependency
113
86
  name: rake
114
87
  requirement: !ruby/object:Gem::Requirement
115
- none: false
116
88
  requirements:
117
- - - ! '>='
89
+ - - '>='
118
90
  - !ruby/object:Gem::Version
119
91
  version: 0.9.2
120
92
  type: :development
121
93
  prerelease: false
122
94
  version_requirements: !ruby/object:Gem::Requirement
123
- none: false
124
95
  requirements:
125
- - - ! '>='
96
+ - - '>='
126
97
  - !ruby/object:Gem::Version
127
98
  version: 0.9.2
99
+ - !ruby/object:Gem::Dependency
100
+ name: thor
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ version: 0.14.0
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ~>
111
+ - !ruby/object:Gem::Version
112
+ version: 0.14.0
128
113
  description: This gem is an Adhearsion plugin that handles the Drb related stuff
129
114
  email:
130
115
  - juandebravo@gmail.com
@@ -136,6 +121,7 @@ extra_rdoc_files: []
136
121
  files:
137
122
  - .gitignore
138
123
  - .rspec
124
+ - .travis.yml
139
125
  - CHANGELOG.md
140
126
  - Gemfile
141
127
  - Guardfile
@@ -146,44 +132,38 @@ files:
146
132
  - lib/adhearsion-drb.rb
147
133
  - lib/adhearsion/drb.rb
148
134
  - lib/adhearsion/drb/plugin.rb
149
- - lib/adhearsion/drb/plugin/service.rb
135
+ - lib/adhearsion/drb/service.rb
150
136
  - lib/adhearsion/drb/version.rb
151
- - spec/adhearsion/drb/plugin/service_spec.rb
152
137
  - spec/adhearsion/drb/plugin_spec.rb
138
+ - spec/adhearsion/drb/service_spec.rb
153
139
  - spec/adhearsion/drb_spec.rb
154
140
  - spec/spec_helper.rb
155
141
  homepage: ''
156
142
  licenses: []
143
+ metadata: {}
157
144
  post_install_message:
158
145
  rdoc_options: []
159
146
  require_paths:
160
147
  - lib
161
148
  required_ruby_version: !ruby/object:Gem::Requirement
162
- none: false
163
149
  requirements:
164
- - - ! '>='
150
+ - - '>='
165
151
  - !ruby/object:Gem::Version
166
152
  version: '0'
167
- segments:
168
- - 0
169
- hash: 1407999279563995289
170
153
  required_rubygems_version: !ruby/object:Gem::Requirement
171
- none: false
172
154
  requirements:
173
- - - ! '>='
155
+ - - '>='
174
156
  - !ruby/object:Gem::Version
175
157
  version: '0'
176
- segments:
177
- - 0
178
- hash: 1407999279563995289
179
158
  requirements: []
180
159
  rubyforge_project: adhearsion-drb
181
- rubygems_version: 1.8.21
160
+ rubygems_version: 2.0.3
182
161
  signing_key:
183
- specification_version: 3
162
+ specification_version: 4
184
163
  summary: This gem is an Adhearsion plugin that handles the Drb related stuff
185
164
  test_files:
186
- - spec/adhearsion/drb/plugin/service_spec.rb
187
165
  - spec/adhearsion/drb/plugin_spec.rb
166
+ - spec/adhearsion/drb/service_spec.rb
188
167
  - spec/adhearsion/drb_spec.rb
189
168
  - spec/spec_helper.rb
169
+ has_rdoc:
@@ -1,81 +0,0 @@
1
- require 'drb'
2
- require 'drb/acl'
3
-
4
- module Adhearsion
5
- module Drb
6
- class Plugin
7
- class Service
8
-
9
- class << self
10
-
11
- ##
12
- # Start the DRb service
13
- def start
14
- acl = create_acl config.acl.allow, config.acl.deny
15
-
16
- DRb.install_acl ACL.new(acl) unless acl.empty?
17
-
18
- logger.info "Starting DRb on #{config.host}:#{config.port}"
19
- DRb.start_service "druby://#{config.host}:#{config.port}", create_drb_door
20
- end
21
-
22
- ##
23
- # Stop the DRb service
24
- def stop
25
- logger.info "Stopping DRb on #{config.host}:#{config.port}"
26
- DRb.stop_service
27
- end
28
-
29
- ##
30
- # Access to Drb plugin configuration
31
- def config
32
- @config ||= Adhearsion.config[:adhearsion_drb]
33
- end
34
-
35
- ##
36
- # Creates a plain object and injects the Adhearsion RPC methods configured via plugins
37
- # @return [Object]
38
- def create_drb_door
39
- config[:shared_object]
40
- end
41
-
42
- ##
43
- # Creates an array that maps the DRb ACL format, that is:
44
- # - a set of zero or more allowed IP addresses. Any allowed IP address is preceded by an "allow" element
45
- # ["allow", "127.0.0.1", "allow", "www.adhearsion.com"]
46
- # - a set of zero or more allowed IP addresses. Any denied IP address is preceded by an "deny" element
47
- # ["deny", "192.168.2.*", "deny", "192.168.3.*"]
48
- #
49
- # - All together:
50
- # ["allow", "127.0.0.1", "allow", "www.adhearsion.com", "deny", "192.168.2.*", "deny", "192.168.3.*"]
51
- #
52
- # @param allow [String, Array] zero or more allowed IPs
53
- # @param deny [String, Array] zero or more denied IPs
54
- #
55
- # @return [Array]
56
- def create_acl allow = nil, deny = nil
57
- if allow.is_a?(String) && allow.empty?
58
- allow = nil
59
- end
60
- if deny.is_a?(String) && deny.empty?
61
- deny = nil
62
- end
63
-
64
- allow = Array(allow)
65
- deny = Array(deny)
66
- value = String.new
67
-
68
- unless allow.empty? && deny.empty?
69
- value.concat("allow ").concat(allow.join(" allow ")) unless allow.empty?
70
- value.concat(" ") if !allow.empty? && !deny.empty?
71
- value.concat("deny ").concat(deny.join(" deny ")) unless deny.empty?
72
- end
73
-
74
- value.split
75
- end
76
-
77
- end
78
- end
79
- end
80
- end
81
- end