hoth 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,48 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- hoth (0.3.3)
5
- activesupport
6
- bertrpc
7
- hoth
8
- json
9
-
10
- GEM
11
- remote: http://rubygems.org/
12
- specs:
13
- activesupport (3.0.10)
14
- beanstalk-client (1.1.0)
15
- bert (1.1.2)
16
- bertrpc (1.3.0)
17
- bert (< 2.0.0, >= 1.1.0)
18
- diff-lcs (1.1.2)
19
- em-jack (0.1.3)
20
- eventmachine
21
- eventmachine (0.12.10)
22
- json (1.5.3)
23
- memcache-client (1.8.5)
24
- rspec (2.6.0)
25
- rspec-core (~> 2.6.0)
26
- rspec-expectations (~> 2.6.0)
27
- rspec-mocks (~> 2.6.0)
28
- rspec-core (2.6.3)
29
- rspec-expectations (2.6.0)
30
- diff-lcs (~> 1.1.2)
31
- rspec-mocks (2.6.0)
32
- simple_publisher (0.1.1)
33
- starling
34
- system_timer
35
- starling (0.10.1)
36
- eventmachine (>= 0.12.0)
37
- memcache-client (>= 1.7.0)
38
- system_timer (1.0)
39
-
40
- PLATFORMS
41
- ruby
42
-
43
- DEPENDENCIES
44
- beanstalk-client
45
- em-jack
46
- hoth!
47
- rspec (~> 2.6.0)
48
- simple_publisher
data/TODO DELETED
@@ -1,2 +0,0 @@
1
- * Make the rack provider independent from one specific transport.
2
- * Make the bodies of the rack_provider return an object which responds to each in order not break on Ruby 1.9.
@@ -1,35 +0,0 @@
1
- require 'ernie'
2
-
3
- module Hoth
4
- module Providers
5
- class BertRPCProvider
6
-
7
- def self.create_ernie_definition
8
- Ernie.log "Possible Service implementations: #{Object.constants.grep(/.*Impl$/).inspect}"
9
- Object.constants.grep(/.*Impl$/).each do |impl_class_name|
10
- if impl_class = Object.const_get(impl_class_name) #&& impl_class.respond_to?(:execute)
11
- Ernie.log "Service implementation was loaded! (#{impl_class.inspect})"
12
- if impl_class.respond_to?(:execute)
13
- service_name = impl_class_name.gsub("Impl", "").underscore.to_sym
14
- mod(service_name) do
15
- fun(:execute) do |*args|
16
- return_value = begin
17
- Hoth::Transport::Bert::TuplePreparer.prepare(Hoth::Services.send(service_name, *args))
18
- rescue Exception => e
19
- Ernie.log %Q{An Exception occured: #{e.message} -- #{e.backtrace.join("\n\t")}}
20
- false
21
- end
22
- end
23
- end
24
- else
25
- Ernie.log "Implementation wasn't applicatable. :execute method is missing!"
26
- end
27
- else
28
- Ernie.log "Service implementation was not loaded! (#{impl_class_name.inspect})"
29
- end
30
- end
31
- end
32
-
33
- end
34
- end
35
- end
@@ -1,87 +0,0 @@
1
- require 'bert'
2
- require 'bertrpc'
3
-
4
- module Hoth
5
- module Transport
6
- class Bert < Base
7
-
8
- class TuplePreparer
9
- def self.prepare(obj)
10
- case obj
11
- when Array
12
- obj.collect { |o| prepare o }
13
- when Hash
14
- obj.each { |k,v| obj[k] = prepare(v) }
15
- else
16
- ruby2tuple obj
17
- end
18
- end
19
-
20
- def self.ruby2tuple(ruby)
21
- if ruby.respond_to? :to_serialize
22
- tuple = t[ruby.class.name.underscore, {}]
23
- ruby.to_serialize.each do |field|
24
- tuple.last[field] = prepare(ruby.send(field))
25
- end
26
- tuple
27
- else
28
- ruby
29
- end
30
- end
31
- end
32
-
33
- class Deserializer
34
- def self.deserialize(data)
35
- case data
36
- when BERT::Tuple
37
- tuple2ruby data
38
- when Array
39
- data.collect { |o| deserialize o }
40
- when Hash
41
- data.each { |k,v| data[k] = deserialize(v) }
42
- else
43
- data
44
- end
45
- end
46
-
47
- def self.tuple2ruby(tuple)
48
- case tuple
49
- when BERT::Tuple
50
- begin
51
- ruby_class = tuple.first.camelize.constantize
52
- ruby_obj = ruby_class.new({})
53
- ruby_obj.to_serialize.each do |field|
54
- ruby_obj.send("#{field}=", deserialize(tuple.last[field]))
55
- end
56
-
57
- ruby_obj
58
- rescue NameError => e
59
- puts %Q{An Exception occured: #{e.message} -- #{e.backtrace.join("\n\t")}}
60
- tuple
61
- end
62
- else
63
- puts "Was not anything we could decode!"
64
- tuple
65
- end
66
- end
67
- end
68
-
69
- def call_remote_with(*args)
70
- bert_service = BERTRPC::Service.new(self.endpoint.host, self.endpoint.port)
71
-
72
- response = bert_service.call.send(self.name).execute(*TuplePreparer.prepare(args))
73
-
74
- if self.return_value
75
- return Deserializer.deserialize(response)
76
- else
77
- return true
78
- end
79
- end
80
-
81
- def decode_params(params)
82
- Deserializer.deserialize(params)
83
- end
84
-
85
- end
86
- end
87
- end
@@ -1,23 +0,0 @@
1
- begin
2
- require 'simple_publisher'
3
- rescue LoadError
4
- STDERR.puts "You need the simple_publisher gem if you want to use Workling/Starling transport."
5
- end
6
-
7
- module Hoth
8
- module Transport
9
-
10
- class Workling < Base
11
-
12
- def call_remote_with(*args)
13
- topic = SimplePublisher::Topic.new(:name => "#{self.module.name.to_s.underscore}_subscribers__#{name.to_s.underscore}")
14
- connection = SimplePublisher::StarlingConnection.new(:host => endpoint.host, :port => endpoint.port)
15
-
16
- publisher = SimplePublisher::Publisher.new(:topic => topic, :connection => connection)
17
- publisher.publish(encoder.encode(args))
18
- end
19
-
20
- end
21
-
22
- end
23
- end
@@ -1,42 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../../', 'spec_helper'))
2
-
3
- module Hoth
4
- module Transport
5
-
6
- describe "Workling" do
7
-
8
- it "should send publish a message via SimplePublisher" do
9
- endpoint = mock("EndpointMock")
10
- endpoint.should_receive(:host).and_return("localhost")
11
- endpoint.should_receive(:port).and_return("22122")
12
-
13
- service_module = mock("ServiceModule")
14
- service_module.should_receive(:name).and_return("TestServiceModule")
15
-
16
- service = mock("ServiceMock")
17
- service.should_receive(:name).and_return("TestService")
18
- service.should_receive(:endpoint).any_number_of_times.and_return(endpoint)
19
- service.should_receive(:module).any_number_of_times.and_return(service_module)
20
-
21
- SimplePublisher::Topic.should_receive(:new).with(:name => "test_service_module_subscribers__test_service").and_return(topic = mock("Topic"))
22
-
23
- SimplePublisher::StarlingConnection.should_receive(:new).with(:host => "localhost", :port => "22122").and_return(connection = mock("Connection"))
24
-
25
- SimplePublisher::Publisher.should_receive(:new).with(
26
- :topic => topic,
27
- :connection => connection
28
- ).and_return(publisher = mock("PublisherMock"))
29
-
30
- uid = "GC-123546"
31
- email_address = "test@example.com"
32
-
33
- publisher.should_receive(:publish).with([uid, email_address])
34
-
35
- transport = Workling.new(service)
36
- transport.call_remote_with(uid, email_address)
37
- end
38
-
39
- end
40
-
41
- end
42
- end