mikka 2.0.0.pre0-java → 2.0.0.pre1-java

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm --create use jruby-1.6.7@mikka
1
+ rvm --create use jruby-1.7.0.preview2@mikka
@@ -2,21 +2,45 @@
2
2
 
3
3
  Mikka is a thin Ruby wrapper around Akka. It makes Akka's Java API more pleasing to the Rubyist's eye.
4
4
 
5
- It uses Akka 1.2, but there are plans to create an Akka 2.0 version as soon as possible. Follow the 2.0 development in the [`mikka-2.0` branch](https://github.com/iconara/mikka/tree/mikka-2.0).
5
+ ## Examples
6
6
 
7
- ## Work in progress
7
+ Here's a quick example:
8
8
 
9
- Mikka is a work in progress, but currently used in production. It currently mostly scratches my own itchs, but improvement suggestions and patches are welcome.
9
+ # first you need an ActorSystem, it contains configuration and coordinates actors
10
+ actor_system = Mikka.create_actor_system('systam')
10
11
 
11
- Check out the `examples` directory for the basics. Start with the `hello_world.rb` example, it is extensively documented and goes through the basics.
12
+ # actors are created by the ActorSystem from an instance of Props, which is
13
+ # a container for actor configuration properties -- here we assume there
14
+ # exists a class called SomeActor
15
+ actor = actor_system.actor_of(Mikka::Props[SomeActor], 'Sigourney Weaver')
16
+
17
+ # send a message to an actor using the shovel operator, which is an alias for #tell
18
+ actor << :hello
19
+
20
+ # when you're done you can shut down your actor system, and wait for it to
21
+ # complete the shutdown process -- don't do this too early, this won't wait
22
+ # for your actors to complete processing of their mailboxes, it will just
23
+ # tell them to stop
24
+ actor_system.shutdown
25
+ actor_system.await_termination
26
+
27
+ that's how you create and communicate with an actor, here's how you create an actor class:
28
+
29
+ class SomeActor < Mikka::Actor
30
+ def receive(message)
31
+ # do the thing
32
+ end
33
+ end
34
+
35
+ that's the basics. v2.0 of Mikka is a work in progress, and there will hopefully be more examples in the future. Mikka is a thin wrapper and you should be able to do everything with it that you can with Akka's Java API. It's not always pretty in Ruby, but it kind of works. Mikka's job is to make it pretty.
12
36
 
13
37
  If you make something that can serve as a useful illustration of some concept, please contribute by sending a patch.
14
38
 
15
39
  ## Requirements
16
40
 
17
- Tested in JRuby 1.6.5+ and Ruby 1.9 mode (run with `jruby --1.9` or set `JRUBY_OPTS='--1.9`).
41
+ Tested in JRuby 1.6.7+ and Ruby 1.9 mode (run with `jruby --1.9` or set `JRUBY_OPTS='--1.9`).
18
42
 
19
- The required Akka and Scala JARs are loaded from the [akka-actor-jars](https://rubygems.org/gems/akka-actor-jars), [akka-remote-jars](https://rubygems.org/gems/akka-remote-jars) and [scala-library-jars](https://rubygems.org/gems/scala-library-jars) wrapper gems.
43
+ The required Akka and Scala JARs are loaded from the [akka-actor-jars](https://rubygems.org/gems/akka-actor-jars) and [scala-library-jars](https://rubygems.org/gems/scala-library-jars) wrapper gems.
20
44
 
21
45
  ## Installation
22
46
 
@@ -29,7 +53,7 @@ Daniel Gaiottino, [@bantai](http://twitter.com/bantai)
29
53
 
30
54
  ## License
31
55
 
32
- Mikka is licensed under the Apache 2 license, the same as Akka. See http://akka.io/docs/akka/1.2/project/licenses.html
56
+ Mikka is licensed under the Apache 2 license, the same as Akka. See http://doc.akka.io/docs/akka/2.0/project/licenses.html
33
57
 
34
58
  ## Mikka?
35
59
 
@@ -64,13 +64,16 @@ module Mikka
64
64
  def receive(message); end
65
65
  def pre_start; end
66
66
  def post_stop; end
67
- def pre_restart(reason); end
67
+ def pre_restart(reason, message); end
68
68
  def post_restart(reason); end
69
69
 
70
70
  def onReceive(message); receive(message); end
71
71
  def preStart; super; pre_start; end
72
72
  def postStop; super; post_stop; end
73
- def preRestart(reason); super; pre_restart(reason); end
73
+ def preRestart(reason, message_option)
74
+ super
75
+ pre_restart(reason, message_option.is_defined ? message_option.get : nil)
76
+ end
74
77
  def postRestart(reason); super; post_restart(reason); end
75
78
  end
76
79
 
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Mikka
4
- VERSION = '2.0.0.pre0'
4
+ VERSION = '2.0.0.pre1'
5
5
  end
@@ -20,7 +20,5 @@ Gem::Specification.new do |s|
20
20
  s.add_dependency 'akka-actor-jars', '~> 2.0.2'
21
21
 
22
22
  s.files = `git ls-files`.split("\n")
23
- # s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
- # s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
23
  s.require_paths = %w(lib)
26
24
  end
@@ -40,10 +40,31 @@ module Mikka
40
40
  actor = @system.actor_of(actor_props, 'some_actor')
41
41
  actor.should be_a(ActorRef)
42
42
  end
43
+ end
43
44
 
44
- # future = actor.ask(:hi, 1000)
45
- # reply = Mikka.await_result(future, :timeout => '1000ms')
46
- # reply.should == :hi
47
-
45
+ describe 'message sending' do
46
+ before do
47
+ @system = Mikka.create_actor_system('testsystem')
48
+ @actor = @system.actor_of(Props[TestActor])
49
+ end
50
+
51
+ after do
52
+ @system.shutdown
53
+ end
54
+
55
+ describe '#tell/#<<' do
56
+ it 'sends a message to an actor' do
57
+ @actor << 'hello'
58
+ end
59
+ end
60
+
61
+ describe '#ask' do
62
+ it 'sends a message'
63
+ # future = actor.ask(:hi, 1000)
64
+ # reply = Mikka.await_result(future, :timeout => '1000ms')
65
+ # reply.should == :hi
66
+
67
+ end
68
+ end
48
69
  end
49
70
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mikka
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 2.0.0.pre0
5
+ version: 2.0.0.pre1
6
6
  platform: java
7
7
  authors:
8
8
  - Theo Hultberg
@@ -10,17 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-08-07 00:00:00.000000000Z
13
+ date: 2012-08-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: akka-actor-jars
17
- version_requirements: &2058 !ruby/object:Gem::Requirement
17
+ version_requirements: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.2
22
+ none: false
23
+ requirement: !ruby/object:Gem::Requirement
18
24
  requirements:
19
25
  - - ~>
20
26
  - !ruby/object:Gem::Version
21
27
  version: 2.0.2
22
28
  none: false
23
- requirement: *2058
24
29
  prerelease: false
25
30
  type: :runtime
26
31
  description: Mikka adapts Akka's Java API to fit better with Ruby
@@ -52,19 +57,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
57
  requirements:
53
58
  - - ! '>='
54
59
  - !ruby/object:Gem::Version
55
- version: '0'
60
+ version: !binary |-
61
+ MA==
56
62
  none: false
57
63
  required_rubygems_version: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - ! '>'
65
+ - - !binary |-
66
+ Pg==
60
67
  - !ruby/object:Gem::Version
61
68
  version: 1.3.1
62
69
  none: false
63
70
  requirements: []
64
71
  rubyforge_project: mikka
65
- rubygems_version: 1.8.15
72
+ rubygems_version: 1.8.24
66
73
  signing_key:
67
74
  specification_version: 3
68
75
  summary: Mikka is a JRuby wrapper for Akka
69
76
  test_files: []
70
- ...