magent 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
data/examples/comm/run.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $:.unshift File.dirname(__FILE__)+"/../../lib/"
4
- require 'magent'
3
+ $:.unshift File.dirname(__FILE__)+"/../../lib/"
4
+ require 'magent'
5
5
 
6
6
  id = "#{rand(16)}#{rand(16)}#{rand(16)}#{rand(16)}"
7
7
 
8
8
  values = (1..5).to_a.map { rand(10) }
9
9
  puts values.join(" + ")
10
- Magent.push("/workers", :sum, id, *values)
10
+ Magent.push("workers", :sum, id, *values)
11
11
 
12
12
  channel = Magent::GenericChannel.new("+#{id}")
13
13
 
@@ -1,7 +1,7 @@
1
1
  $:.unshift File.dirname(__FILE__)+"/../../lib/"
2
2
  require 'magent'
3
3
 
4
- Magent.push("/errors", :fail, "this is a fail")
4
+ Magent.push("errors", :fail, "this is a fail")
5
5
 
6
6
  class Error
7
7
  include Magent::Actor
@@ -3,10 +3,10 @@ require 'magent'
3
3
 
4
4
  # Use: magent /path/to/this/file
5
5
 
6
- Magent.push("/bots", :echo, "hello, world")
7
- Magent.push("/bots", :do_task, "File", :exist?, "/etc/passwd")
8
- Magent.push("/bots", :echo, "Press ctrl+c to close")
9
- Magent.push("/bots", :do_not_exist, "you should not see this message")
6
+ Magent.push("bots", :echo, "hello, world")
7
+ Magent.push("bots", :do_task, "File", :exist?, "/etc/passwd")
8
+ Magent.push("bots", :echo, "Press ctrl+c to close")
9
+ Magent.push("bots", :do_not_exist, "you should not see this message")
10
10
 
11
11
  class Bot
12
12
  include Magent::Actor
@@ -1,10 +1,10 @@
1
1
  $:.unshift File.dirname(__FILE__)+"/../../lib/"
2
2
  require 'magent'
3
3
 
4
- Magent.push("/stats", :calc)
5
- Magent.push("/stats", :calc)
6
- Magent.push("/stats", :calc)
7
- Magent.push("/stats", :calc)
4
+ Magent.push("stats", :calc)
5
+ Magent.push("stats", :calc)
6
+ Magent.push("stats", :calc)
7
+ Magent.push("stats", :calc)
8
8
 
9
9
  class Stats
10
10
  include Magent::Actor
data/lib/magent/actor.rb CHANGED
@@ -15,7 +15,7 @@ module Magent
15
15
  end
16
16
 
17
17
  def channel_name(name = nil)
18
- @channel_name ||= (name || Magent::Utils.underscore(self.name))
18
+ @channel_name ||= (name || Magent::Utils.underscore(self.name)).to_s
19
19
  end
20
20
 
21
21
  def actions
@@ -28,8 +28,7 @@ module Magent
28
28
 
29
29
  def channel
30
30
  @channel ||= begin
31
- channel_name = "/"+self.channel_name
32
- Channel.new(channel_name)
31
+ Channel.new(self.channel_name)
33
32
  end
34
33
  end
35
34
 
data/lib/magent/utils.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  module Magent
2
2
  module Utils
3
3
  def self.underscore(word)
4
- word.to_s.gsub(/::/, '/').
4
+ word.to_s.gsub(/::/, '.').
5
5
  gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
6
6
  gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase
7
7
  end
8
8
 
9
9
  def self.camelize(word)
10
- word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
10
+ word.to_s.gsub(/\.(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
11
11
  end
12
12
  end
13
13
  end
data/lib/magent.rb CHANGED
@@ -13,7 +13,7 @@ require 'magent/actor'
13
13
  require 'magent/processor'
14
14
 
15
15
  module Magent
16
- VERSION = '0.2'
16
+ VERSION = '0.3'
17
17
 
18
18
  def self.connection
19
19
  @@connection ||= Mongo::Connection.new(nil, nil, :auto_reconnect => true)
data/magent.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{magent}
5
- s.version = "0.2"
5
+ s.version = "0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["David Cuadrado"]
9
- s.date = %q{2010-01-06}
9
+ s.date = %q{2010-01-19}
10
10
  s.default_executable = %q{magent}
11
11
  s.description = %q{Simple job queue system based on mongodb}
12
12
  s.email = ["krawek@gmail.com"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magent
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.2"
4
+ version: "0.3"
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cuadrado
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-06 00:00:00 -05:00
12
+ date: 2010-01-19 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency