magicbroker 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -1,5 +1,5 @@
1
- README.rdoc
1
+ Manifest
2
+ README.md
2
3
  Rakefile
3
- lib/broker.rb
4
4
  lib/client/client.rb
5
- Manifest
5
+ lib/magicbroker.rb
data/README.md ADDED
@@ -0,0 +1,88 @@
1
+
2
+ Ruby gem for subscribing, unsubscribing and sending events to the Magic Broker 2.
3
+
4
+ ## Getting Started:
5
+
6
+ This gem is already published on rubygems.org, so you can actually just include it in your application.
7
+
8
+ ### Step 1
9
+
10
+ If you're writting a Rails application, first add the following line to your Gemfile file:
11
+
12
+ ```
13
+ gem 'magicbroker', '0.2.0'
14
+ ```
15
+
16
+ ### Step 2
17
+
18
+ Then you can include it in any controller like so:
19
+ ```
20
+ require 'magicbroker'
21
+ ```
22
+
23
+ ### Other ways:
24
+
25
+ If you want to download the latest version of the gem, fork this repository and you can find the packaged gem in the /pkg directory.
26
+
27
+
28
+ ## Using the gem where it should be used: in a Rails application
29
+
30
+ For ease you can declare a global broker entity, in /apps/controllers/application_controller.rb:
31
+
32
+ ```
33
+ require 'magicbroker'
34
+ def magicbroker
35
+ @magicbroker = Magicbroker::Client.new("localhost:8800/osgibroker", "clientID", "topic")
36
+ end
37
+ ```
38
+
39
+ Then you can use your global object. For example, sending events:
40
+
41
+ ```
42
+ magicbroker.subscribe()
43
+ hash = {:key1 => "value1", :key2 => "value2", :key3 => "value3"}
44
+ magicbroker.send_events(hash)
45
+ ```
46
+
47
+ Unsubscribing:
48
+
49
+ ```
50
+ magicbroker.unsubscribe()
51
+ ```
52
+
53
+ Querying events (default timeout of 1 second). You can delegate this task to a Resque worker running in the background:
54
+
55
+ ```
56
+ magicbroker.receive_events(nil)
57
+ ```
58
+
59
+ ### Using without a global object (many broker objects)
60
+
61
+ You can initialize a new magicbroker object, subscribe, receive events and send a key/value pair event:
62
+
63
+ ```
64
+ require 'magicbroker'
65
+ myentity = Magicbroker::Client.new("localhost:8800/osgibroker", "clientID", "topic")
66
+ myentity.subscribe()
67
+ myentity.receive_events(20) #define a timeout of 20 seconds
68
+ myhash = {:key => "value"}
69
+ myentity.send_events(myhash)
70
+ ```
71
+
72
+ ## Installing from source
73
+
74
+ This gem was built using 'echoe', to install the gem in your system run:
75
+
76
+ ```
77
+ rake manifest #To first test the file.
78
+ rake install #To install in your system.
79
+ ```
80
+
81
+ ## Publishing to RubyForge
82
+
83
+ ATTENTION: this is only for developers. You can publish the gem to rubygems.org by running the task:
84
+
85
+ ```
86
+ rake release
87
+ ```
88
+
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('magicbroker', '0.2.0') do |p|
5
+ Echoe.new('magicbroker', '0.2.1') do |p|
6
6
  p.description = "The MAGIC-Broker-2 gem"
7
7
  p.url = "https://github.com/magic-liam/broker-gem-0.2.0.git"
8
8
  p.author = "Roberto Calderon"
data/lib/client/client.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'net/http'
2
2
  require 'uri'
3
3
 
4
- module Broker
4
+ module Magicbroker
5
5
 
6
6
  class Client
7
7
 
@@ -29,7 +29,14 @@ module Broker
29
29
  Net::HTTP.get_print URI.parse(servlet)
30
30
  print servlet
31
31
  end
32
-
32
+
33
+ def receive_events(t)
34
+ t.nil? ? t=1 : t=t
35
+ print
36
+ servlet = 'http://'+@server+'/event?clientID='+@clientID+'&topic='+@topic+'&timeOut='+t.to_s()
37
+ Net::HTTP.get_print URI.parse(servlet)
38
+ print servlet
39
+ end
40
+
33
41
  end
34
-
35
- end
42
+ end
@@ -1,3 +1,3 @@
1
- module Broker
1
+ module Magicbroker
2
2
  autoload :Client, 'client/client'
3
3
  end
data/magicbroker.gemspec CHANGED
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "magicbroker"
5
- s.version = "0.2.0"
5
+ s.version = "0.2.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Roberto Calderon"]
9
9
  s.date = "2012-08-11"
10
10
  s.description = "The MAGIC-Broker-2 gem"
11
11
  s.email = "roberto@robertocalderon.ca"
12
- s.extra_rdoc_files = ["README.rdoc", "lib/broker.rb", "lib/client/client.rb"]
13
- s.files = ["README.rdoc", "Rakefile", "lib/broker.rb", "lib/client/client.rb", "Manifest", "magicbroker.gemspec"]
12
+ s.extra_rdoc_files = ["README.md", "lib/client/client.rb", "lib/magicbroker.rb"]
13
+ s.files = ["Manifest", "README.md", "Rakefile", "lib/client/client.rb", "lib/magicbroker.rb", "magicbroker.gemspec"]
14
14
  s.homepage = "https://github.com/magic-liam/broker-gem-0.2.0.git"
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Magicbroker", "--main", "README.rdoc"]
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Magicbroker", "--main", "README.md"]
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = "magicbroker"
18
18
  s.rubygems_version = "1.8.24"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magicbroker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -16,15 +16,15 @@ email: roberto@robertocalderon.ca
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files:
19
- - README.rdoc
20
- - lib/broker.rb
19
+ - README.md
21
20
  - lib/client/client.rb
21
+ - lib/magicbroker.rb
22
22
  files:
23
- - README.rdoc
23
+ - Manifest
24
+ - README.md
24
25
  - Rakefile
25
- - lib/broker.rb
26
26
  - lib/client/client.rb
27
- - Manifest
27
+ - lib/magicbroker.rb
28
28
  - magicbroker.gemspec
29
29
  homepage: https://github.com/magic-liam/broker-gem-0.2.0.git
30
30
  licenses: []
@@ -35,7 +35,7 @@ rdoc_options:
35
35
  - --title
36
36
  - Magicbroker
37
37
  - --main
38
- - README.rdoc
38
+ - README.md
39
39
  require_paths:
40
40
  - lib
41
41
  required_ruby_version: !ruby/object:Gem::Requirement
data/README.rdoc DELETED
@@ -1 +0,0 @@
1
- Ruby gem for subscribing, unsubscribing and sending events to the Magic Broker 2