carnivore-actor 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +2 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +30 -0
- data/README.md +19 -0
- data/carnivore-actor.gemspec +14 -0
- data/lib/carnivore-actor.rb +4 -0
- data/lib/carnivore-actor/actor.rb +28 -0
- data/lib/carnivore-actor/version.rb +7 -0
- data/test/spec.rb +1 -0
- data/test/specs/actor.rb +47 -0
- metadata +71 -0
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
carnivore-actor (0.1.0)
|
5
|
+
carnivore (> 0.1.10)
|
6
|
+
|
7
|
+
PATH
|
8
|
+
remote: ../carnivore
|
9
|
+
specs:
|
10
|
+
carnivore (0.1.11)
|
11
|
+
celluloid
|
12
|
+
mixlib-config
|
13
|
+
multi_json
|
14
|
+
|
15
|
+
GEM
|
16
|
+
remote: https://rubygems.org/
|
17
|
+
specs:
|
18
|
+
celluloid (0.15.2)
|
19
|
+
timers (~> 1.1.0)
|
20
|
+
mixlib-config (2.1.0)
|
21
|
+
multi_json (1.8.2)
|
22
|
+
timers (1.1.0)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
java
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
carnivore!
|
30
|
+
carnivore-actor!
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Carnivore Actor
|
2
|
+
|
3
|
+
Provides Actor `Carnivore::Source`
|
4
|
+
|
5
|
+
# Usage
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
require 'carnivore'
|
9
|
+
require 'carnivore-actor'
|
10
|
+
|
11
|
+
Carnivore.configure do
|
12
|
+
source = Carnivore::Source.build(:type => :actor)
|
13
|
+
end
|
14
|
+
```
|
15
|
+
|
16
|
+
# Info
|
17
|
+
* Carnivore: https://github.com/carnivore-rb/carnivore
|
18
|
+
* Repository: https://github.com/carnivore-rb/carnivore-actor
|
19
|
+
* IRC: Freenode @ #carnivore
|
@@ -0,0 +1,14 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__)) + '/lib/'
|
2
|
+
require 'carnivore-actor/version'
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'carnivore-actor'
|
5
|
+
s.version = Carnivore::Actor::VERSION.version
|
6
|
+
s.summary = 'Message processing helper'
|
7
|
+
s.author = 'Chris Roberts'
|
8
|
+
s.email = 'code@chrisroberts.org'
|
9
|
+
s.homepage = 'https://github.com/carnivore-rb/carnivore-actor'
|
10
|
+
s.description = 'Carnivore actor source'
|
11
|
+
s.require_path = 'lib'
|
12
|
+
s.add_dependency 'carnivore', '> 0.1.10'
|
13
|
+
s.files = Dir['**/*']
|
14
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'carnivore/source'
|
2
|
+
|
3
|
+
module Carnivore
|
4
|
+
class Source
|
5
|
+
class Actor < Source
|
6
|
+
|
7
|
+
def setup(*args)
|
8
|
+
@messages = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def receive(*args)
|
12
|
+
wait(:available_messages)
|
13
|
+
current_messages
|
14
|
+
end
|
15
|
+
|
16
|
+
def transmit(*args)
|
17
|
+
@messages << args.first
|
18
|
+
signal(:available_messages)
|
19
|
+
end
|
20
|
+
|
21
|
+
def current_messages
|
22
|
+
msgs = @messages.dup
|
23
|
+
@messages.clear
|
24
|
+
msgs
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/test/spec.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'carnivore/spec_helper'
|
data/test/specs/actor.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'carnivore-actor'
|
3
|
+
|
4
|
+
describe 'Carnivore::Source::Actor' do
|
5
|
+
|
6
|
+
describe 'Building an Actor based source' do
|
7
|
+
|
8
|
+
it 'returns the source' do
|
9
|
+
Carnivore::Source.build(:type => :actor, :args => {:name => :actor_source})
|
10
|
+
t = Thread.new{ Carnivore.start! }
|
11
|
+
source_wait
|
12
|
+
Carnivore::Supervisor.supervisor[:actor_source].wont_be_nil
|
13
|
+
t.terminate
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'Actor source based communication' do
|
19
|
+
before do
|
20
|
+
@source1 = []
|
21
|
+
@source2 = []
|
22
|
+
MessageStore.init
|
23
|
+
Carnivore::Source.build(:type => :actor, :args => {:name => :actor_source}).add_callback(:store) do |message|
|
24
|
+
MessageStore.messages.push(message[:message])
|
25
|
+
end
|
26
|
+
@runner = Thread.new{ Carnivore.start! }
|
27
|
+
source_wait
|
28
|
+
end
|
29
|
+
|
30
|
+
after do
|
31
|
+
@runner.terminate
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'message transmissions' do
|
35
|
+
it 'should accept message transmits' do
|
36
|
+
Carnivore::Supervisor.supervisor[:actor_source].transmit('test message')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should receive messages' do
|
40
|
+
Carnivore::Supervisor.supervisor[:actor_source].transmit('test message 2')
|
41
|
+
source_wait
|
42
|
+
MessageStore.messages.must_include 'test message 2'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: carnivore-actor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chris Roberts
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-01-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: carnivore
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>'
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.1.10
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>'
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.1.10
|
30
|
+
description: Carnivore actor source
|
31
|
+
email: code@chrisroberts.org
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- carnivore-actor.gemspec
|
37
|
+
- lib/carnivore-actor/version.rb
|
38
|
+
- lib/carnivore-actor/actor.rb
|
39
|
+
- lib/carnivore-actor.rb
|
40
|
+
- test/spec.rb
|
41
|
+
- test/specs/actor.rb
|
42
|
+
- Gemfile
|
43
|
+
- README.md
|
44
|
+
- CHANGELOG.md
|
45
|
+
- Gemfile.lock
|
46
|
+
homepage: https://github.com/carnivore-rb/carnivore-actor
|
47
|
+
licenses: []
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.8.24
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: Message processing helper
|
70
|
+
test_files: []
|
71
|
+
has_rdoc:
|