nutella_lib 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/nutella_lib/net.rb +2 -2
- data/nutella_lib.gemspec +2 -2
- data/test/test_nutella_lib.rb +25 -25
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 809635436c6083ffcc66ee67660196d6fedd0161
|
4
|
+
data.tar.gz: fc2d5da13567805306c78c295da4642c09b2b168
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 637ca3db4ef68539e09bfe8a4889c23f4d56bcb3a70a81ab9fe1be719c5b7810ec2ed6fee6dae1f8918840b373e4757dc0c0920b4acdce964fc818a4e8656a99
|
7
|
+
data.tar.gz: ce91068690716748971db0a22f8874da88641d1f5b2b2b40a8951f6033679fe63b45418a71e16fdc004c95e940e1b53445e35afcdd118ffd3329ee1e43aa5c27
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/lib/nutella_lib/net.rb
CHANGED
@@ -92,7 +92,7 @@ module Nutella
|
|
92
92
|
# string (the string will be wrapped into a JSON string automatically. Format: {"payload":"<message>"})
|
93
93
|
# hash (the hash will be converted into a JSON string automatically)
|
94
94
|
# json string (the JSON string will be sent as is)
|
95
|
-
def Net.
|
95
|
+
def Net.sync_request (channel, message=nil)
|
96
96
|
# Pad channel
|
97
97
|
new_channel = "#{Nutella.run_id}/#{channel}"
|
98
98
|
# Prepare message
|
@@ -124,7 +124,7 @@ module Nutella
|
|
124
124
|
# string (the string will be wrapped into a JSON string automatically. Format: {"payload":"<message>"})
|
125
125
|
# hash (the hash will be converted into a JSON string automatically)
|
126
126
|
# json string (the JSON string will be sent as is)
|
127
|
-
def Net.
|
127
|
+
def Net.async_request (channel, message=nil, callback)
|
128
128
|
# Pad channel
|
129
129
|
new_channel = "#{Nutella.run_id}/#{channel}"
|
130
130
|
# Prepare message
|
data/nutella_lib.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: nutella_lib 0.3.
|
5
|
+
# stub: nutella_lib 0.3.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "nutella_lib"
|
9
|
-
s.version = "0.3.
|
9
|
+
s.version = "0.3.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
data/test/test_nutella_lib.rb
CHANGED
@@ -48,31 +48,31 @@ class TestNutellaLib < MiniTest::Test
|
|
48
48
|
# end
|
49
49
|
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
51
|
+
def test_request_response
|
52
|
+
nutella.init('my_run_id', 'ltg.evl.uic.edu', 'my_bot_component')
|
53
|
+
nutella.set_resource_id 'my_resource_id'
|
54
|
+
|
55
|
+
nutella.net.subscribe('demo1', lambda do |message, component_id, resource_id|
|
56
|
+
puts "Received a message from #{component_id}/#{resource_id}. Message: #{message}"
|
57
|
+
end)
|
58
|
+
|
59
|
+
nutella.net.handle_requests( 'demo1', lambda do |message, component_id, resource_id|
|
60
|
+
puts "We received a request: message #{message}, from #{component_id}/#{resource_id}"
|
61
|
+
#Then we are going to return some JSON
|
62
|
+
{my:'json'}
|
63
|
+
end)
|
64
|
+
|
65
|
+
response = nutella.net.sync_request( 'demo1', 'my request is a string' )
|
66
|
+
puts 'Response to sync'
|
67
|
+
p response
|
68
|
+
|
69
|
+
nutella.net.async_request( 'demo1', 'my request is a string', lambda do |response|
|
70
|
+
puts 'Response to async'
|
71
|
+
p response
|
72
|
+
end)
|
73
|
+
|
74
|
+
nutella.net.listen
|
75
|
+
end
|
76
76
|
|
77
77
|
|
78
78
|
end
|