atome 0.5.6.2.0 → 0.5.6.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/atome/genesis/generators/communication.rb +6 -4
- data/lib/atome/genesis/sparkle.rb +10 -3
- data/lib/atome/helpers/utilities.rb +12 -24
- data/lib/atome/kernel/universe.rb +13 -0
- data/lib/atome/version.rb +1 -1
- data/vendor/assets/application/examples/database_handling.rb +26 -10
- data/vendor/assets/server/atome_server.rb +33 -76
- data/vendor/assets/src/js/atome/atome_helpers/communication.js +6 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 695be1c2b746dd4a424e74ebb28ff18884fb207fb1de1bd8db9ea732b1fd7574
|
4
|
+
data.tar.gz: 943340100b85b85ebb8c1d1af89801b89204c810452cb16a860ace32b3e47190
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cb8f32ad5373a51222e70c87261e5c8cc0d05a0038d2087a5e433aeacd08cdeacfb43fc692ac489d18d82a6471ce4bdced8e647cd1e10e97664bcf6c6bbdf4d
|
7
|
+
data.tar.gz: bf36e8c816ebbd99fc36aee7d4dd94bbb324e1b5caf1017731e598e1423a0524ab55b0e13b060c8d6d67ab0c6cdaa0368b0d93e6d9e9479257bfec890788e6b0
|
@@ -10,10 +10,12 @@ new({ particle: :message, category: :communication, type: :hash }) do |params, b
|
|
10
10
|
params = { data: params } unless params.instance_of? Hash
|
11
11
|
params[:user] = 'dfghg4df5gdfgh654'
|
12
12
|
params[:pass] = 'gfhkzrhgzr4h98948'
|
13
|
-
instance_variable_set('@message_code', {}) unless instance_variable_get('@message_code')
|
14
|
-
store_proc= instance_variable_get('@message_code')
|
15
|
-
|
16
|
-
|
13
|
+
# instance_variable_set('@message_code', {}) unless instance_variable_get('@message_code')
|
14
|
+
# store_proc= instance_variable_get('@message_code')
|
15
|
+
message_id= "msg_#{Universe.messages.length}"
|
16
|
+
params[:message_id]=message_id
|
17
|
+
# store_proc[mmessage_id]=bloc
|
18
|
+
Universe.store_messages({msg_nb:message_id, proc: bloc })
|
17
19
|
html.send_message(params)
|
18
20
|
|
19
21
|
end
|
@@ -141,7 +141,9 @@ end
|
|
141
141
|
def atome_genesis
|
142
142
|
atome_infos
|
143
143
|
A.server({ address: 'localhost:9292', type: 'ws' })
|
144
|
-
A.init_websocket
|
144
|
+
A.init_websocket do |msg|
|
145
|
+
puts "-3 #{msg}"
|
146
|
+
end
|
145
147
|
end
|
146
148
|
|
147
149
|
def init_database # this method is call from JS (atome/communication)
|
@@ -149,6 +151,7 @@ def init_database # this method is call from JS (atome/communication)
|
|
149
151
|
particles = Universe.particle_list
|
150
152
|
categories = Universe.categories
|
151
153
|
atomes = Universe.atomes
|
154
|
+
# puts "we are here!!"
|
152
155
|
# particles.each do |particle, value|
|
153
156
|
# value[:category] = :undefined if value[:category].nil?
|
154
157
|
# A.message({ action: :init_db, particle: particle, type: value[:type], category: value[:category] })
|
@@ -158,6 +161,10 @@ end
|
|
158
161
|
def user_login
|
159
162
|
user = Universe.current_user
|
160
163
|
pass = Black_matter.password
|
161
|
-
message({ action: :login, value: user })
|
162
|
-
|
164
|
+
message({ action: :login, value: user }) do |msg|
|
165
|
+
puts "-2 #{msg}"
|
166
|
+
end
|
167
|
+
message({ action: :pass, value: pass }) do |msg|
|
168
|
+
puts "-1 #{msg}"
|
169
|
+
end
|
163
170
|
end
|
@@ -177,13 +177,13 @@ class Atome
|
|
177
177
|
new_atome
|
178
178
|
end
|
179
179
|
|
180
|
-
def store(params)
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
end
|
180
|
+
# def store(params)
|
181
|
+
# params.each do |particle_to_save, data|
|
182
|
+
# # @!atome[particle_to_save]=data
|
183
|
+
# # instance_variable_set(particle_to_save,data)
|
184
|
+
# end
|
185
|
+
#
|
186
|
+
# end
|
187
187
|
|
188
188
|
def history(filter = {})
|
189
189
|
filter[:id] = @id
|
@@ -210,7 +210,7 @@ class Atome
|
|
210
210
|
# option_found = params.values[0]
|
211
211
|
# instance_variable_get(elem_code)["#{option_found}_code"] = user_proc
|
212
212
|
# else
|
213
|
-
|
213
|
+
instance_variable_get(elem_code)[element] = user_proc
|
214
214
|
# end
|
215
215
|
end
|
216
216
|
|
@@ -251,9 +251,9 @@ class Atome
|
|
251
251
|
else
|
252
252
|
instance_variable_get("@#{element}_code")[element]
|
253
253
|
# instance_exec(@callback[element], proc_found)if proc_found.is_a? Proc
|
254
|
-
|
254
|
+
end
|
255
255
|
# array_of_proc_found.each do |proc_found|
|
256
|
-
|
256
|
+
proc_found.call(return_params) if proc_found.is_a? Proc
|
257
257
|
# end if array_of_proc_found
|
258
258
|
|
259
259
|
# if array_of_proc_found
|
@@ -381,26 +381,14 @@ class Atome
|
|
381
381
|
end
|
382
382
|
|
383
383
|
def server_receiver(params)
|
384
|
-
|
385
|
-
|
386
|
-
calllbacks_found= instance_variable_get('@message_code')
|
387
|
-
# we delete the default message created by atome
|
388
|
-
calllbacks_found.delete(:message)
|
389
|
-
# we get the oldest available callback, to treat it
|
390
|
-
oldest_callback = calllbacks_found.delete(calllbacks_found.keys.first)
|
391
|
-
params=params[:return] #TODO : format retrun data correctly instead of this line
|
392
|
-
oldest_callback.call(params) if oldest_callback.is_a? Proc
|
393
|
-
# callback(:message, params)
|
384
|
+
callback_found = Universe.messages[params[:message_id]]
|
385
|
+
callback_found.call(params) if callback_found.is_a? Proc
|
394
386
|
end
|
395
387
|
|
396
388
|
def init_websocket
|
397
|
-
instance_variable_set('@message_code', {})
|
398
|
-
# connection is particle (communication.rb)
|
399
389
|
connection(@current_server)
|
400
390
|
end
|
401
391
|
|
402
|
-
|
403
|
-
|
404
392
|
def encrypt(string)
|
405
393
|
# if RUBY_ENGINE.downcase == 'opal' || 'wasm32-wasi'
|
406
394
|
# `sha256(#{string})`
|
@@ -9,6 +9,7 @@ class Universe
|
|
9
9
|
@renderer_list = %i[html browser headless server log]
|
10
10
|
@sanitizers = {}
|
11
11
|
@specificities = {}
|
12
|
+
@messages = {}
|
12
13
|
|
13
14
|
@categories = %w[ communication effect event geometry hierarchy identity material
|
14
15
|
property security spatial time utility ]
|
@@ -20,6 +21,18 @@ class Universe
|
|
20
21
|
class << self
|
21
22
|
attr_reader :atomes, :renderer_list, :atome_list, :particle_list, :classes, :counter, :atomes_specificities
|
22
23
|
|
24
|
+
def messages
|
25
|
+
@messages
|
26
|
+
end
|
27
|
+
|
28
|
+
def store_messages(new_msg)
|
29
|
+
@messages[new_msg[:msg_nb]] = new_msg[:proc]
|
30
|
+
end
|
31
|
+
|
32
|
+
def delete_messages(msg_to_del)
|
33
|
+
@messages.delete(msg_to_del)
|
34
|
+
end
|
35
|
+
|
23
36
|
def set_help(particle, &doc)
|
24
37
|
@help[particle] = doc
|
25
38
|
end
|
data/lib/atome/version.rb
CHANGED
@@ -1,23 +1,39 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
A.message({ action: :insert, data: { table: :security, particle: :password, data: 'my_pass'} })
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
A.message({ action: :insert, data: { table: :security, particle: :password, data: 'my_pass'} }) do |datas|
|
4
|
+
puts "0 data received: #{datas}"
|
5
|
+
end
|
4
6
|
|
5
7
|
A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs' } }) do |data_received_from_server|
|
6
|
-
puts "my first insert #{data_received_from_server}"
|
8
|
+
puts "1 my first insert #{data_received_from_server}"
|
7
9
|
end
|
8
10
|
|
11
|
+
A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs2' } })
|
12
|
+
|
9
13
|
A.message({ action: :query, data: { table: :identity } }) do |data_received_from_server|
|
10
|
-
puts "another insert : #{data_received_from_server}"
|
14
|
+
puts "2 another insert : #{data_received_from_server}"
|
11
15
|
end
|
12
16
|
|
13
17
|
A.message({ action: :query, data: { table: :identity } }) do |data_received|
|
14
|
-
puts "received : #{data_received}"
|
18
|
+
puts "3 received : #{data_received}"
|
19
|
+
end
|
20
|
+
|
21
|
+
A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs3' } }) do |result|
|
22
|
+
puts "4 insert done : #{result}"
|
23
|
+
end
|
24
|
+
|
25
|
+
A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs4' } }) do |result|
|
26
|
+
puts "5 last message received: #{result}"
|
15
27
|
end
|
16
28
|
|
17
|
-
A.message({ action: :insert, data: { table: :
|
18
|
-
puts "
|
29
|
+
A.message({ action: :insert, data: { table: :security, particle: :name, data: 'john doe' } }) do |data_received_from_server|
|
30
|
+
puts "6 test 1 : #{data_received_from_server}"
|
19
31
|
end
|
20
32
|
|
21
|
-
A.message({ action: :insert, data: { table: :identity, particle: :
|
22
|
-
puts "
|
33
|
+
A.message({ action: :insert, data: { table: :identity, particle: :tit, data: 'dummy' } }) do |data_received_from_server|
|
34
|
+
puts "7 test 2 : #{data_received_from_server}"
|
23
35
|
end
|
36
|
+
|
37
|
+
A.message({ action: :insert, data: { table: :unknown, particle: :name, data: 'dummy2' } }) do |data_received_from_server|
|
38
|
+
puts "test 3 : #{data_received_from_server}"
|
39
|
+
end
|
@@ -21,79 +21,52 @@ class EDen
|
|
21
21
|
Database.connect_database
|
22
22
|
end
|
23
23
|
|
24
|
-
def self.terminal(cmd, option, ws, value, user, pass)
|
25
|
-
{ return: `#{cmd}
|
24
|
+
def self.terminal(cmd, option, ws, value, user, pass, message_id)
|
25
|
+
{ return: `#{cmd}`, message_id: message_id }
|
26
26
|
end
|
27
27
|
|
28
|
-
def self.pass(cmd, option, ws, value, user, pass)
|
29
|
-
{ return: '
|
28
|
+
def self.pass(cmd, option, ws, value, user, pass, message_id)
|
29
|
+
{ return: 'password received', message_id: message_id }
|
30
30
|
end
|
31
31
|
|
32
|
-
def self.
|
32
|
+
def self.login(cmd, option, ws, value, user, pass, message_id)
|
33
|
+
{ return: 'login received', message_id: message_id }
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.init_db(cmd, option, ws, value, user, pass, message_id)
|
33
37
|
# Database.
|
34
|
-
{ return: 'database initialised' }
|
38
|
+
{ return: 'database initialised', message_id: message_id }
|
35
39
|
end
|
36
40
|
|
37
|
-
def self.query(cmd, option, ws, value, user, pass)
|
41
|
+
def self.query(cmd, option, ws, value, user, pass, message_id)
|
38
42
|
identity_table = db_access[cmd['table'].to_sym]
|
39
43
|
result = identity_table.send(:all).send(:select)
|
40
|
-
{ action: :query, data: cmd['table'], return: result }
|
44
|
+
{ action: :query, data: cmd['table'], return: "==> #{result}", message_id: message_id }
|
41
45
|
end
|
42
46
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
# { action: :insert, data: cmd, return: { email: 'tre@tre' } }
|
47
|
-
# end
|
48
|
-
|
49
|
-
def self.insert(params, option, ws, value, user, pass)
|
50
|
-
table = params['table']
|
51
|
-
particle = params['particle']
|
47
|
+
def self.insert(params, option, ws, value, user, pass, message_id)
|
48
|
+
table = params['table'].to_sym
|
49
|
+
particle = params['particle'].to_sym
|
52
50
|
data = params['data']
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
51
|
+
if db_access.table_exists?(table)
|
52
|
+
schema = db_access.schema(table)
|
53
|
+
if schema.any? { |col_def| col_def.first == particle }
|
54
|
+
identity_table = db_access[table.to_sym]
|
55
|
+
identity_table.insert(particle => data)
|
56
|
+
{ action: :insert, return: "column : #{particle}, in table : #{table}, updated with : #{data}", message_id: message_id }
|
57
|
+
else
|
58
|
+
{ action: :insert, return: "column not found: #{particle.class}", message_id: message_id }
|
59
|
+
end
|
60
|
+
else
|
61
|
+
{ action: :insert, return: "table not found: #{table.class}", message_id: message_id }
|
62
|
+
|
63
|
+
end
|
60
64
|
end
|
61
65
|
|
62
|
-
|
63
|
-
# db = Database.connect_database
|
64
|
-
# identity_items = db[:identity]
|
65
|
-
# security_items = db[:security]
|
66
|
-
#
|
67
|
-
# identity_items.insert(email: 'tre@tre')
|
68
|
-
# security_items.insert(password: 'poipoi')
|
69
|
-
# # testtest= "Mails count: #{identity_items.count}"
|
70
|
-
#
|
71
|
-
# user_email = value["mail"]
|
72
|
-
# user_password = value["pass"]
|
73
|
-
#
|
74
|
-
# # user_exists = identity_items.all.select{|item| item[:email]==user_email}
|
75
|
-
# user_exists = identity_items.send(:all).send(:select) do |item|
|
76
|
-
# item[:email] == user_email
|
77
|
-
# end
|
78
|
-
#
|
79
|
-
# if user_exists.empty?
|
80
|
-
# # "Mails count: #{identity_items.count}"
|
81
|
-
# # "Mails count: #{identity_items.all}"
|
82
|
-
# "Email non trouvé, erreur"
|
83
|
-
# # Ask to the user if he wants to subscribe
|
84
|
-
# # Send the basic template
|
85
|
-
# else
|
86
|
-
# "Email trouvé, cherche mdp"
|
87
|
-
# # Verify password
|
88
|
-
# # If password isn't ok, send error
|
89
|
-
# # If the password is ok, send the user account template
|
90
|
-
# end
|
91
|
-
# end
|
92
|
-
|
93
|
-
def self.file(source, operation, ws, value, user, pass)
|
66
|
+
def self.file(source, operation, ws, value, user, pass, message_id)
|
94
67
|
file_content = File.send(operation, source, value).to_s
|
95
68
|
file_content = file_content.gsub("'", "\"")
|
96
|
-
{ return: "=> operation: #{operation}, source: #{source} , content : #{file_content}" }
|
69
|
+
{ return: "=> operation: #{operation}, source: #{source} , content : #{file_content}", message_id: message_id }
|
97
70
|
end
|
98
71
|
|
99
72
|
# return_message = EDen.safe_send(action_requested, data,option, current_user, user_pass)
|
@@ -124,6 +97,7 @@ end
|
|
124
97
|
class Database
|
125
98
|
|
126
99
|
def self.table_exists?(table_name)
|
100
|
+
# code below must be removed but not fpr now
|
127
101
|
eden = Sequel.connect("sqlite://eden.sqlite3")
|
128
102
|
if eden.table_exists?(table_name)
|
129
103
|
puts "La table #{table_name} existe dans la base de données."
|
@@ -336,19 +310,6 @@ class Database
|
|
336
310
|
end
|
337
311
|
|
338
312
|
class App < Roda
|
339
|
-
|
340
|
-
# comment below when test will be done
|
341
|
-
# File.delete("./eden.sqlite3") if File.exist?("./eden.sqlite3")
|
342
|
-
eden = Database.connect_database
|
343
|
-
items = eden[:atome]
|
344
|
-
|
345
|
-
# populate the table
|
346
|
-
items.insert(creator: 'moi')
|
347
|
-
items.insert(creator: 'toi')
|
348
|
-
items.insert(creator: 'vous')
|
349
|
-
puts "Item count: #{items.count}"
|
350
|
-
test = "Item count: #{items.count}"
|
351
|
-
# puts "My name is: #{items(:creator)}"
|
352
313
|
index_content = File.read("../src/index_server.html")
|
353
314
|
opts[:root] = '../src'
|
354
315
|
plugin :static, %w[/css /js /medias], root: '../src'
|
@@ -358,9 +319,7 @@ class App < Roda
|
|
358
319
|
ws = Faye::WebSocket.new(r.env)
|
359
320
|
ws.on :open do |event|
|
360
321
|
ws.send({ return: 'server ready' }.to_json)
|
361
|
-
# ws.send('asking for synchro data'.to_json)
|
362
322
|
end
|
363
|
-
|
364
323
|
ws.on(:message) do |event|
|
365
324
|
json_string = event.data.gsub(/(\w+):/) { "\"#{$1}\":" }.gsub('=>', ':')
|
366
325
|
full_data = JSON.parse(json_string)
|
@@ -369,9 +328,9 @@ class App < Roda
|
|
369
328
|
value = full_data['value']
|
370
329
|
option = full_data['option']
|
371
330
|
current_user = full_data['user']
|
331
|
+
message_id = full_data['message_id']
|
372
332
|
user_pass = full_data['pass']['global']
|
373
|
-
|
374
|
-
return_message = EDen.safe_send(action_requested, data, option, ws, value, current_user, user_pass)
|
333
|
+
return_message = EDen.safe_send(action_requested, data, option, ws, value, current_user, user_pass, message_id)
|
375
334
|
ws.send(return_message.to_json)
|
376
335
|
end
|
377
336
|
|
@@ -380,10 +339,8 @@ class App < Roda
|
|
380
339
|
end
|
381
340
|
ws.rack_response
|
382
341
|
end
|
383
|
-
|
384
342
|
index_content
|
385
343
|
end
|
386
|
-
|
387
344
|
end
|
388
345
|
|
389
346
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
const communication = {
|
2
|
-
// websocket: new WebSocket('ws://localhost:9292'),
|
3
2
|
websocket: null,
|
4
3
|
initialize: function () {
|
5
4
|
this.websocket = new WebSocket('ws://localhost:9292')
|
@@ -10,9 +9,7 @@ const communication = {
|
|
10
9
|
};
|
11
10
|
|
12
11
|
this.websocket.onmessage = function (event) {
|
13
|
-
rubyVMCallback('message', "('" + event.data
|
14
|
-
|
15
|
-
// rubyVMCallback("puts 'object ruby callback : " + event.data + "'")
|
12
|
+
rubyVMCallback('message', "('" + event.data + "')")
|
16
13
|
};
|
17
14
|
|
18
15
|
this.websocket.onclose = function (event) {
|
@@ -65,22 +62,15 @@ const communication = {
|
|
65
62
|
}
|
66
63
|
},
|
67
64
|
connect: function (type, server, user, pass, atomes, particles) {
|
68
|
-
this.websocket = new WebSocket(type+'://'+server);
|
65
|
+
this.websocket = new WebSocket(type + '://' + server);
|
69
66
|
this.websocket.onopen = function (event) {
|
70
67
|
|
71
|
-
//
|
72
|
-
// now new can exec user code : loadApplicationJs in index.html
|
73
|
-
// rubyVMCallback("A.init_database");
|
68
|
+
// now new can exec user code : loadApplicationJs in index.html
|
74
69
|
loadApplicationJs();
|
75
70
|
rubyVMCallback("A.user_login");
|
76
|
-
// rubyVMCallback("A.init_database");
|
77
71
|
};
|
78
72
|
this.websocket.onmessage = function (event) {
|
79
|
-
|
80
|
-
// rubyVMCallback('message', "('" + event.data + "')")
|
81
|
-
// rubyVMCallback("A.callback({ touch: '" + event.data + "' })");
|
82
|
-
rubyVMCallback("A.server_receiver(" + event.data + ")");
|
83
|
-
// alert(event.data)
|
73
|
+
rubyVMCallback("A.server_receiver(" + event.data + ")");
|
84
74
|
};
|
85
75
|
|
86
76
|
this.websocket.onclose = function (event) {
|
@@ -97,6 +87,7 @@ const communication = {
|
|
97
87
|
},
|
98
88
|
ws_sender: function (message) {
|
99
89
|
// now we send the data to the server
|
90
|
+
// puts "--> message : #{message}"
|
100
91
|
this.websocket.send(message)
|
101
92
|
},
|
102
93
|
}
|
@@ -130,8 +121,7 @@ const communication = {
|
|
130
121
|
// }
|
131
122
|
|
132
123
|
|
133
|
-
|
134
|
-
function controller_message(msg){
|
124
|
+
function controller_message(msg) {
|
135
125
|
// message receiver from controller (Vie)
|
136
126
|
console.log(msg)
|
137
127
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.6.2.
|
4
|
+
version: 0.5.6.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Eric Godard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: artoo
|