nutella_lib 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.travis.yml +5 -0
- data/Gemfile +17 -0
- data/LICENSE +21 -0
- data/README.md +3 -0
- data/Rakefile +44 -0
- data/VERSION +1 -0
- data/lib/nutella_lib.rb +26 -0
- data/lib/nutella_lib/core.rb +45 -0
- data/lib/nutella_lib/ext/kernel.rb +7 -0
- data/lib/nutella_lib/net.rb +194 -0
- data/lib/nutella_lib/noext.rb +6 -0
- data/lib/nutella_lib/persist.rb +63 -0
- data/nutella_lib.gemspec +77 -0
- data/test/helper.rb +35 -0
- data/test/test_nutella_lib.rb +22 -0
- metadata +221 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6a97fa54cf895d9a462fa41e9359e09956c7187f
|
4
|
+
data.tar.gz: 860c5ee47f0dd0204fd8f7d231398c600be38053
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ee9c68c86d822abff7772fd226c18cb927291a41dade3a658efb86f226d6f2c6e1fb31600f9c7e00467800430ff194fd2ba071650e0766e2c327a51e88a62b21
|
7
|
+
data.tar.gz: 8e4b5f099ccd0f0c17020402880b256785e8ed0ccb5e6e3483136caa5139595275573a15ff66a111f906bd6dc4f1291e9a4e1e57aa260e7006029cc5222d126b
|
data/.document
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'simple_ruby_mqtt_client', '~> 0.2.0', '>= 0.2.0'
|
4
|
+
|
5
|
+
group :development do
|
6
|
+
gem 'shoulda', '~> 3', '>= 3'
|
7
|
+
gem 'minitest', '~> 5.4', '>= 5'
|
8
|
+
gem "yard", '~> 0.8', '>= 0.8.7'
|
9
|
+
gem 'rdoc', '~> 4.0', '>= 4.0'
|
10
|
+
gem 'bundler', '~> 1.0', '>= 1.0'
|
11
|
+
gem 'jeweler', '~> 2.0.1', '>= 2.0.1'
|
12
|
+
gem 'simplecov', '~> 0', '>= 0'
|
13
|
+
end
|
14
|
+
|
15
|
+
group :test do
|
16
|
+
gem "rake"
|
17
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 by The Board of Trustees of the University of Illinois at Chicago
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
+
gem.name = "nutella_lib"
|
18
|
+
gem.homepage = "https://github.com/nutella-framework/nutella_lib.rb"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{nutella protocol library for ruby}
|
21
|
+
gem.description = %Q{Implements the nutella protocol and exposes it natively to ruby developers}
|
22
|
+
gem.email = "tebemis@gmail.com"
|
23
|
+
gem.authors = ["Alessandro Gnoli"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Code coverage detail"
|
36
|
+
task :simplecov do
|
37
|
+
ENV['COVERAGE'] = "true"
|
38
|
+
Rake::Task['test'].execute
|
39
|
+
end
|
40
|
+
|
41
|
+
task :default => :test
|
42
|
+
|
43
|
+
require 'yard'
|
44
|
+
YARD::Rake::YardocTask.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
data/lib/nutella_lib.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'nutella_lib/core'
|
2
|
+
require 'nutella_lib/net'
|
3
|
+
require 'nutella_lib/persist'
|
4
|
+
|
5
|
+
# Gems used across the whole library
|
6
|
+
require 'simple_ruby_mqtt_client'
|
7
|
+
require 'json'
|
8
|
+
require 'set'
|
9
|
+
|
10
|
+
# NO_EXT gets defined when you require "nutella_lib/noext", which
|
11
|
+
# signals that you don't want any extensions.
|
12
|
+
unless defined?(Nutella::NO_EXT)
|
13
|
+
require 'nutella_lib/ext/kernel'
|
14
|
+
end
|
15
|
+
|
16
|
+
# Adding a convenience method to the string class
|
17
|
+
# to test if it contains properly formatted JSON
|
18
|
+
class String
|
19
|
+
def is_json?
|
20
|
+
begin
|
21
|
+
!!JSON.parse(self)
|
22
|
+
rescue
|
23
|
+
false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# This module is the wrapper around the whole nutella library.
|
2
|
+
module Nutella
|
3
|
+
|
4
|
+
# Initializes the nutella library
|
5
|
+
def Nutella.init(args)
|
6
|
+
if args.length < 2
|
7
|
+
STDERR.puts "Couldn't read run_id and broker address from the command line, impossible to initialize library!"
|
8
|
+
return
|
9
|
+
end
|
10
|
+
@run_id = args[0]
|
11
|
+
begin
|
12
|
+
@actor_name = Nutella.config_actor_name(@run_id)
|
13
|
+
rescue
|
14
|
+
STDERR.puts "Couldn't find nutella.json file, impossible to initialize library!"
|
15
|
+
return
|
16
|
+
end
|
17
|
+
@mqtt = SimpleMQTTClient.new(args[1], @actor_name)
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
# Accessors for module instance variables
|
22
|
+
def Nutella.run_id; @run_id end
|
23
|
+
def Nutella.actor_name; @actor_name end
|
24
|
+
def Nutella.mqtt; @mqtt end
|
25
|
+
|
26
|
+
|
27
|
+
# Nutella library modules loading
|
28
|
+
def Nutella.net; Nutella::Net end
|
29
|
+
def Nutella.persist; Nutella::Persist end
|
30
|
+
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
# Extracts the actor name from nutella.json file and appends it to the run_id
|
35
|
+
def Nutella.config_actor_name (run_id)
|
36
|
+
h = JSON.parse( IO.read( "nutella.json" ) )
|
37
|
+
full_actor_name = run_id + '_' + h["name"]
|
38
|
+
full_actor_name[0, 23]
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
@@ -0,0 +1,194 @@
|
|
1
|
+
module Nutella
|
2
|
+
|
3
|
+
# This class implements the pub/sub nutella protocol
|
4
|
+
# @author Alessandro Gnoli <tebemis@gmail.com>
|
5
|
+
module Net
|
6
|
+
|
7
|
+
# Subscribe to a channel
|
8
|
+
# The callback takes one parameter and that is the message that is received.
|
9
|
+
# Messages that are not JSON are discarded.
|
10
|
+
def Net.subscribe (channel, callback)
|
11
|
+
# Pad the channel
|
12
|
+
new_channel = Nutella.run_id + '/' + channel
|
13
|
+
# Subscribe
|
14
|
+
Nutella.mqtt.subscribe(new_channel, lambda do |message|
|
15
|
+
# Make sure the message is JSON, if not drop the message
|
16
|
+
begin
|
17
|
+
message_hash = JSON.parse(message)
|
18
|
+
callback.call(message_hash)
|
19
|
+
rescue
|
20
|
+
return
|
21
|
+
end
|
22
|
+
end)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Unsubscribe from a channel
|
26
|
+
def Net.unsubscribe(channel)
|
27
|
+
# Pad the channel
|
28
|
+
new_channel = Nutella.run_id + '/' + channel
|
29
|
+
# Unsubscribe
|
30
|
+
Nutella.mqtt.unsubscribe(new_channel)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Publishes a message to a channel
|
34
|
+
# Message can be:
|
35
|
+
# empty (equivalent of a GET)
|
36
|
+
# string (the string will be wrapped into a JSON string automatically. Format: {"payload":"<message>"})
|
37
|
+
# hash (the hash will be converted into a JSON string automatically)
|
38
|
+
# json string (the JSON string will be sent as is)
|
39
|
+
def Net.publish(channel, message)
|
40
|
+
# Pad the channel
|
41
|
+
new_channel = Nutella.run_id + '/' + channel
|
42
|
+
# Publish
|
43
|
+
begin
|
44
|
+
m = Net.prepare_message_for_publish(message)
|
45
|
+
Nutella.mqtt.publish(new_channel, m)
|
46
|
+
rescue
|
47
|
+
STDERR.puts $!
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Performs a synchronous request
|
52
|
+
# Message can be:
|
53
|
+
# empty (equivalent of a GET)
|
54
|
+
# string (the string will be wrapped into a JSON string automatically. Format: {"payload":"<message>"})
|
55
|
+
# hash (the hash will be converted into a JSON string automatically)
|
56
|
+
# json string (the JSON string will be sent as is)
|
57
|
+
def Net.sync_req (channel, message="")
|
58
|
+
# Generate message unique id
|
59
|
+
id = message.hash
|
60
|
+
# Attach id
|
61
|
+
begin
|
62
|
+
payload = Net.attach_message_id(message, id)
|
63
|
+
rescue
|
64
|
+
STDERR.puts $!
|
65
|
+
return
|
66
|
+
end
|
67
|
+
# Initialize response and response counter
|
68
|
+
ready_to_go = 2
|
69
|
+
response = nil
|
70
|
+
# Subscribe to same channel to collect response
|
71
|
+
Net.subscribe(channel, lambda do |res|
|
72
|
+
if (res["id"]==id)
|
73
|
+
ready_to_go -= 1
|
74
|
+
if ready_to_go==0
|
75
|
+
Net.unsubscribe(channel)
|
76
|
+
response = res
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end)
|
80
|
+
# Send message the message
|
81
|
+
Net.publish(channel, payload)
|
82
|
+
# Wait for the response to come back
|
83
|
+
sleep(0.5) until ready_to_go==0
|
84
|
+
response
|
85
|
+
end
|
86
|
+
|
87
|
+
# Performs an asynchronosus request
|
88
|
+
# Message can be:
|
89
|
+
# empty (equivalent of a GET)
|
90
|
+
# string (the string will be wrapped into a JSON string automatically. Format: {"payload":"<message>"})
|
91
|
+
# hash (the hash will be converted into a JSON string automatically)
|
92
|
+
# json string (the JSON string will be sent as is)
|
93
|
+
def Net.async_req (channel, message="", callback)
|
94
|
+
# Generate message unique id
|
95
|
+
id = message.hash
|
96
|
+
# Attach id
|
97
|
+
begin
|
98
|
+
payload = Net.attach_message_id(message, id)
|
99
|
+
rescue
|
100
|
+
STDERR.puts $!
|
101
|
+
return
|
102
|
+
end
|
103
|
+
# Initialize flag that prevents handling of our own messages
|
104
|
+
ready_to_go = false
|
105
|
+
# Register callback to handle data the request response whenever it comes
|
106
|
+
Net.subscribe(channel, lambda do |res|
|
107
|
+
# Check that the message we receive is not the one we are sending ourselves.
|
108
|
+
if res["id"]==id
|
109
|
+
if ready_to_go
|
110
|
+
Net.unsubscribe(channel)
|
111
|
+
callback.call(res)
|
112
|
+
else
|
113
|
+
ready_to_go = true
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end)
|
117
|
+
# Send message
|
118
|
+
Net.publish(channel, payload)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Handles requests on a certain channel
|
122
|
+
def Net.handle_requests (channel, &handler)
|
123
|
+
Net.subscribe(channel, lambda do |req|
|
124
|
+
# Ignore anything that doesn't have an id (i.e. not requests)
|
125
|
+
id = req["id"]
|
126
|
+
if id.nil?
|
127
|
+
return
|
128
|
+
end
|
129
|
+
# Ignore recently processed requests
|
130
|
+
if @last_requests.nil?
|
131
|
+
@last_requests = Set.new
|
132
|
+
end
|
133
|
+
if @last_requests.include?(id)
|
134
|
+
@last_requests.delete(id)
|
135
|
+
return
|
136
|
+
end
|
137
|
+
@last_requests.add(id)
|
138
|
+
req.delete("id")
|
139
|
+
res = handler.call(req)
|
140
|
+
begin
|
141
|
+
res_and_id = attach_message_id(res, id)
|
142
|
+
Net.publish(channel, res_and_id)
|
143
|
+
rescue
|
144
|
+
STDERR.puts 'When handling a request you need to return JSON'
|
145
|
+
end
|
146
|
+
end)
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
def Net.listen
|
151
|
+
begin
|
152
|
+
sleep
|
153
|
+
rescue Interrupt
|
154
|
+
# Simply returns
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
private
|
160
|
+
|
161
|
+
def Net.attach_message_id (message, id)
|
162
|
+
if message.is_a?(Hash)
|
163
|
+
message[:id] = id
|
164
|
+
payload = message.to_json
|
165
|
+
elsif message.is_json?
|
166
|
+
p = JSON.parse(message)
|
167
|
+
p[:id] = id
|
168
|
+
payload = p.to_json
|
169
|
+
elsif message.is_a?(String)
|
170
|
+
payload = { :payload => message, :id => id }.to_json
|
171
|
+
else
|
172
|
+
raise 'Your request is not JSON!'
|
173
|
+
end
|
174
|
+
payload
|
175
|
+
end
|
176
|
+
|
177
|
+
def Net.prepare_message_for_publish (message)
|
178
|
+
if message.is_a?(Hash)
|
179
|
+
message[:from] = Nutella.actor_name
|
180
|
+
payload = message.to_json
|
181
|
+
elsif message.is_json?
|
182
|
+
p = JSON.parse(message)
|
183
|
+
p[:from] = Nutella.actor_name
|
184
|
+
payload = p.to_json
|
185
|
+
elsif message.is_a?(String)
|
186
|
+
payload = { :payload => message, :from => Nutella.actor_name }.to_json
|
187
|
+
else
|
188
|
+
raise 'You are trying to publish something that is not JSON!'
|
189
|
+
end
|
190
|
+
payload
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'pstore'
|
3
|
+
|
4
|
+
module Nutella
|
5
|
+
|
6
|
+
module Persist
|
7
|
+
|
8
|
+
# This module exposes a single method to retrieve a JSONStore
|
9
|
+
def Persist.getJsonStore(file_name)
|
10
|
+
JSONStore.new(file_name)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
# JSONStore provides the same functionality as PStore, except it uses JSON
|
16
|
+
# to dump objects instead of Marshal.
|
17
|
+
# Example use:
|
18
|
+
# store = nutella.persist.getJsonStore("json_store/json_test.json")
|
19
|
+
# # Write
|
20
|
+
# store.transaction { store["key"]="value" }
|
21
|
+
# # Read
|
22
|
+
# value = store.transaction { store["key"] }
|
23
|
+
# puts value # prints "value"
|
24
|
+
# # Dump the whole store
|
25
|
+
# hash = store.transaction { store.to_h }
|
26
|
+
# p hash # prints {"key" => "value"}
|
27
|
+
|
28
|
+
class JSONStore < PStore
|
29
|
+
|
30
|
+
def dump(table)
|
31
|
+
table.to_json
|
32
|
+
end
|
33
|
+
|
34
|
+
def load(content)
|
35
|
+
JSON.parse(content)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Dumps the whole store to hash
|
39
|
+
# example:
|
40
|
+
# store = JSONStore.new("my_file.json")
|
41
|
+
# hash = store.transaction { store.to_h }
|
42
|
+
def to_h
|
43
|
+
@table
|
44
|
+
end
|
45
|
+
|
46
|
+
def marshal_dump_supports_canonical_option?
|
47
|
+
false
|
48
|
+
end
|
49
|
+
|
50
|
+
EMPTY_MARSHAL_DATA = {}.to_json
|
51
|
+
EMPTY_MARSHAL_CHECKSUM = Digest::MD5.digest(EMPTY_MARSHAL_DATA)
|
52
|
+
def empty_marshal_data
|
53
|
+
EMPTY_MARSHAL_DATA
|
54
|
+
end
|
55
|
+
def empty_marshal_checksum
|
56
|
+
EMPTY_MARSHAL_CHECKSUM
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
|
data/nutella_lib.gemspec
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: nutella_lib 0.2.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "nutella_lib"
|
9
|
+
s.version = "0.2.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Alessandro Gnoli"]
|
14
|
+
s.date = "2014-11-12"
|
15
|
+
s.description = "Implements the nutella protocol and exposes it natively to ruby developers"
|
16
|
+
s.email = "tebemis@gmail.com"
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".travis.yml",
|
24
|
+
"Gemfile",
|
25
|
+
"LICENSE",
|
26
|
+
"README.md",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"lib/nutella_lib.rb",
|
30
|
+
"lib/nutella_lib/core.rb",
|
31
|
+
"lib/nutella_lib/ext/kernel.rb",
|
32
|
+
"lib/nutella_lib/net.rb",
|
33
|
+
"lib/nutella_lib/noext.rb",
|
34
|
+
"lib/nutella_lib/persist.rb",
|
35
|
+
"nutella_lib.gemspec",
|
36
|
+
"test/helper.rb",
|
37
|
+
"test/test_nutella_lib.rb"
|
38
|
+
]
|
39
|
+
s.homepage = "https://github.com/nutella-framework/nutella_lib.rb"
|
40
|
+
s.licenses = ["MIT"]
|
41
|
+
s.rubygems_version = "2.2.2"
|
42
|
+
s.summary = "nutella protocol library for ruby"
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
s.specification_version = 4
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_runtime_dependency(%q<simple_ruby_mqtt_client>, [">= 0.2.0", "~> 0.2.0"])
|
49
|
+
s.add_development_dependency(%q<shoulda>, [">= 3", "~> 3"])
|
50
|
+
s.add_development_dependency(%q<minitest>, [">= 5", "~> 5.4"])
|
51
|
+
s.add_development_dependency(%q<yard>, [">= 0.8.7", "~> 0.8"])
|
52
|
+
s.add_development_dependency(%q<rdoc>, [">= 4.0", "~> 4.0"])
|
53
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0", "~> 1.0"])
|
54
|
+
s.add_development_dependency(%q<jeweler>, [">= 2.0.1", "~> 2.0.1"])
|
55
|
+
s.add_development_dependency(%q<simplecov>, [">= 0", "~> 0"])
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<simple_ruby_mqtt_client>, [">= 0.2.0", "~> 0.2.0"])
|
58
|
+
s.add_dependency(%q<shoulda>, [">= 3", "~> 3"])
|
59
|
+
s.add_dependency(%q<minitest>, [">= 5", "~> 5.4"])
|
60
|
+
s.add_dependency(%q<yard>, [">= 0.8.7", "~> 0.8"])
|
61
|
+
s.add_dependency(%q<rdoc>, [">= 4.0", "~> 4.0"])
|
62
|
+
s.add_dependency(%q<bundler>, [">= 1.0", "~> 1.0"])
|
63
|
+
s.add_dependency(%q<jeweler>, [">= 2.0.1", "~> 2.0.1"])
|
64
|
+
s.add_dependency(%q<simplecov>, [">= 0", "~> 0"])
|
65
|
+
end
|
66
|
+
else
|
67
|
+
s.add_dependency(%q<simple_ruby_mqtt_client>, [">= 0.2.0", "~> 0.2.0"])
|
68
|
+
s.add_dependency(%q<shoulda>, [">= 3", "~> 3"])
|
69
|
+
s.add_dependency(%q<minitest>, [">= 5", "~> 5.4"])
|
70
|
+
s.add_dependency(%q<yard>, [">= 0.8.7", "~> 0.8"])
|
71
|
+
s.add_dependency(%q<rdoc>, [">= 4.0", "~> 4.0"])
|
72
|
+
s.add_dependency(%q<bundler>, [">= 1.0", "~> 1.0"])
|
73
|
+
s.add_dependency(%q<jeweler>, [">= 2.0.1", "~> 2.0.1"])
|
74
|
+
s.add_dependency(%q<simplecov>, [">= 0", "~> 0"])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
module SimpleCov::Configuration
|
4
|
+
def clean_filters
|
5
|
+
@filters = []
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
SimpleCov.configure do
|
10
|
+
clean_filters
|
11
|
+
load_profile 'test_frameworks'
|
12
|
+
end
|
13
|
+
|
14
|
+
ENV["COVERAGE"] && SimpleCov.start do
|
15
|
+
add_filter "/.rvm/"
|
16
|
+
end
|
17
|
+
require 'rubygems'
|
18
|
+
require 'bundler'
|
19
|
+
begin
|
20
|
+
Bundler.setup(:default, :development)
|
21
|
+
rescue Bundler::BundlerError => e
|
22
|
+
$stderr.puts e.message
|
23
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
24
|
+
exit e.status_code
|
25
|
+
end
|
26
|
+
require 'minitest/autorun'
|
27
|
+
|
28
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
29
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
30
|
+
require 'nutella_lib'
|
31
|
+
|
32
|
+
class MiniTest::Test
|
33
|
+
end
|
34
|
+
|
35
|
+
MiniTest.autorun
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestNutellaLib < MiniTest::Test
|
4
|
+
|
5
|
+
# def test_that_kernel_extension_works
|
6
|
+
# assert_instance_of Nutella::Core, nutella
|
7
|
+
# end
|
8
|
+
|
9
|
+
# def test_core_module_method_call
|
10
|
+
# nutella.hello "Ruby"
|
11
|
+
# end
|
12
|
+
|
13
|
+
|
14
|
+
# tests for sync/asynch_Req
|
15
|
+
# v = nutella.net.sync_req("quakes_schedule", '{"stringa":"json"}')
|
16
|
+
# v = nutella.net.sync_req("quakes_schedule", "messaggio")
|
17
|
+
# v = nutella.net.sync_req("quakes_schedule", {})
|
18
|
+
# v = nutella.net.sync_req("quakes_schedule", {:cane => "dio"})
|
19
|
+
# v = nutella.net.sync_req("quakes_schedule")
|
20
|
+
|
21
|
+
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nutella_lib
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alessandro Gnoli
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: simple_ruby_mqtt_client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.0
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.2.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.2.0
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.2.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: shoulda
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3'
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '3'
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '3'
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '3'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: minitest
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '5'
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '5.4'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '5'
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '5.4'
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: yard
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 0.8.7
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.8'
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.8.7
|
90
|
+
- - "~>"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0.8'
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: rdoc
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '4.0'
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '4.0'
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '4.0'
|
110
|
+
- - "~>"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '4.0'
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: bundler
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '1.0'
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '1.0'
|
123
|
+
type: :development
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '1.0'
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '1.0'
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: jeweler
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: 2.0.1
|
140
|
+
- - "~>"
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 2.0.1
|
143
|
+
type: :development
|
144
|
+
prerelease: false
|
145
|
+
version_requirements: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 2.0.1
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 2.0.1
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: simplecov
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
- - "~>"
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
163
|
+
type: :development
|
164
|
+
prerelease: false
|
165
|
+
version_requirements: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
- - "~>"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
description: Implements the nutella protocol and exposes it natively to ruby developers
|
174
|
+
email: tebemis@gmail.com
|
175
|
+
executables: []
|
176
|
+
extensions: []
|
177
|
+
extra_rdoc_files:
|
178
|
+
- LICENSE
|
179
|
+
- README.md
|
180
|
+
files:
|
181
|
+
- ".document"
|
182
|
+
- ".travis.yml"
|
183
|
+
- Gemfile
|
184
|
+
- LICENSE
|
185
|
+
- README.md
|
186
|
+
- Rakefile
|
187
|
+
- VERSION
|
188
|
+
- lib/nutella_lib.rb
|
189
|
+
- lib/nutella_lib/core.rb
|
190
|
+
- lib/nutella_lib/ext/kernel.rb
|
191
|
+
- lib/nutella_lib/net.rb
|
192
|
+
- lib/nutella_lib/noext.rb
|
193
|
+
- lib/nutella_lib/persist.rb
|
194
|
+
- nutella_lib.gemspec
|
195
|
+
- test/helper.rb
|
196
|
+
- test/test_nutella_lib.rb
|
197
|
+
homepage: https://github.com/nutella-framework/nutella_lib.rb
|
198
|
+
licenses:
|
199
|
+
- MIT
|
200
|
+
metadata: {}
|
201
|
+
post_install_message:
|
202
|
+
rdoc_options: []
|
203
|
+
require_paths:
|
204
|
+
- lib
|
205
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0'
|
210
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
211
|
+
requirements:
|
212
|
+
- - ">="
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: '0'
|
215
|
+
requirements: []
|
216
|
+
rubyforge_project:
|
217
|
+
rubygems_version: 2.2.2
|
218
|
+
signing_key:
|
219
|
+
specification_version: 4
|
220
|
+
summary: nutella protocol library for ruby
|
221
|
+
test_files: []
|