atome 0.5.6.1.4 → 0.5.6.2.0

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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +44 -0
  3. data/documentation/deep learning/basic_infos.txt +6 -0
  4. data/exe/atome +0 -2
  5. data/lib/atome/atome.rb +1 -1
  6. data/lib/atome/extensions/atome.rb +33 -23
  7. data/lib/atome/extensions/sha.rb +8 -8
  8. data/lib/atome/genesis/generators/atome.rb +1 -1
  9. data/lib/atome/genesis/generators/communication.rb +14 -20
  10. data/lib/atome/genesis/generators/effect.rb +2 -2
  11. data/lib/atome/genesis/generators/event.rb +25 -25
  12. data/lib/atome/genesis/generators/geometry.rb +3 -3
  13. data/lib/atome/genesis/generators/hierarchy.rb +6 -6
  14. data/lib/atome/genesis/generators/identity.rb +13 -13
  15. data/lib/atome/genesis/generators/material.rb +24 -11
  16. data/lib/atome/genesis/generators/property.rb +8 -24
  17. data/lib/atome/genesis/generators/security.rb +1 -1
  18. data/lib/atome/genesis/generators/spatial.rb +13 -13
  19. data/lib/atome/genesis/generators/time.rb +1 -1
  20. data/lib/atome/genesis/generators/utility.rb +39 -37
  21. data/lib/atome/genesis/genesis.rb +2 -1
  22. data/lib/atome/genesis/sparkle.rb +31 -11
  23. data/lib/atome/helpers/utilities.rb +108 -49
  24. data/lib/atome/kernel/universe.rb +13 -9
  25. data/lib/atome/version.rb +1 -1
  26. data/lib/eVe/eVe.rb +1 -1
  27. data/lib/eVe/eVe_relative.rb +1 -1
  28. data/lib/platform_specific/opal/extensions/sha.rb +25 -14
  29. data/lib/renderers/html/html.rb +6 -7
  30. data/vendor/assets/application/examples/atome_particle_validation.rb +7 -0
  31. data/vendor/assets/application/examples/attach.rb +3 -3
  32. data/vendor/assets/application/examples/border.rb +1 -1
  33. data/vendor/assets/application/examples/categories.rb +5 -0
  34. data/vendor/assets/application/examples/clones&monitoring.rb +105 -0
  35. data/vendor/assets/application/examples/database_handling.rb +23 -0
  36. data/vendor/assets/application/examples/display_bck.rb +1 -1
  37. data/vendor/assets/application/examples/drag.rb +3 -1
  38. data/vendor/assets/application/examples/encrypt.rb +6 -0
  39. data/vendor/assets/application/examples/find.rb +1 -1
  40. data/vendor/assets/application/examples/import.rb +2 -2
  41. data/vendor/assets/application/examples/read.rb +2 -0
  42. data/vendor/assets/application/examples/shadow.rb +2 -1
  43. data/vendor/assets/server/atome_server.rb +106 -16
  44. data/vendor/assets/server/atome_server_wasm.rb +1 -1
  45. data/vendor/assets/src/index.html +21 -21
  46. data/vendor/assets/src/index_server.html +11 -5
  47. data/vendor/assets/src/index_server_wasm.html +11 -4
  48. data/vendor/assets/src/js/atome/atome.js +1 -1
  49. data/vendor/assets/src/js/atome/atome_helpers/communication.js +39 -30
  50. metadata +7 -4
  51. data/vendor/assets/application/examples/a_concat.rb +0 -19
  52. data/vendor/assets/application/examples/clones.rb +0 -177
@@ -9,29 +9,29 @@ def extract_rgb_alpha(color_string)
9
9
  { red: red, green: green, blue: blue, alpha: alpha }
10
10
  end
11
11
 
12
- new({ particle: :red }) do
12
+ new({ particle: :red, category: :property, type: :string }) do
13
13
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
14
14
  self
15
15
  end
16
- new({ particle: :green }) do
16
+ new({ particle: :green, category: :property, type: :string }) do
17
17
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
18
18
  self
19
19
  end
20
- new({ particle: :blue }) do
20
+ new({ particle: :blue, category: :property, type: :string }) do
21
21
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
22
22
  self
23
23
  end
24
- new({ particle: :alpha }) do
24
+ new({ particle: :alpha, category: :property, type: :string }) do
25
25
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
26
26
  self
27
27
  end
28
- new({ particle: :diffusion }) do
28
+ new({ particle: :diffusion, category: :property, type: :string }) do
29
29
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
30
30
  self
31
31
  end
32
32
 
33
33
 
34
- new({ particle: :clean }) do |params|
34
+ new({ particle: :clean, category: :property, type: :boolean }) do |params|
35
35
  cell = params[:cell]
36
36
  row_nb = cell[0]
37
37
  column_nb = cell[1]
@@ -39,7 +39,7 @@ new({ particle: :clean }) do |params|
39
39
  params
40
40
  end
41
41
 
42
- new({ particle: :insert }) do |params|
42
+ new({ particle: :insert, category: :property, type: :string }) do |params|
43
43
  # cell
44
44
  if params[:cell]
45
45
  content = params[:content]
@@ -56,23 +56,7 @@ new({ particle: :insert }) do |params|
56
56
  params
57
57
  end
58
58
 
59
- new({ particle: :remove }) do |params|
60
-
61
- if params[:row]
62
- data.delete_at(params[:row])
63
-
64
- elsif params[:column]
65
- column = params[:column]
66
- data.map do |hash|
67
- hash.delete(hash.keys[column]) if hash.keys[column]
68
- hash
69
- end
70
- end
71
- params
72
- end
73
-
74
-
75
- new({ particle: :sort }) do |params|
59
+ new({ particle: :sort, category: :property, type: :int }) do |params|
76
60
  column = params[:column]
77
61
  method = params[:method]
78
62
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- new ({ particle: :password })
3
+ new ({ particle: :password, category: :security, type: :string })
4
4
  new ({ sanitizer: :password }) do |params|
5
5
 
6
6
  params = { read: params, write: params } unless params.instance_of? Hash
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- new({ particle: :left })
4
- new({ particle: :right })
5
- new({ particle: :top })
6
- new({ particle: :bottom })
7
- new({ particle: :rotate, type: :integer })
8
- new({ particle: :direction, type: :string })
9
- new({ particle: :depth, type: :integer })
10
- new({ particle: :position })
11
- new({ particle: :organise })
12
- new({ particle: :spacing })
13
- new({ particle: :display }) do |params|
3
+ new({ particle: :left, category: :spatial, type: :int })
4
+ new({ particle: :right, category: :spatial, type: :int })
5
+ new({ particle: :top, category: :spatial, type: :int })
6
+ new({ particle: :bottom, category: :spatial, type: :int })
7
+ new({ particle: :rotate, category: :spacial, type: :integer })
8
+ new({ particle: :direction, category: :spatial, type: :string })
9
+ new({ particle: :depth, category: :spatial, type: :integer })
10
+ new({ particle: :position, category: :spatial, type: :int })
11
+ new({ particle: :organise, category: :spatial, type: :string })
12
+ new({ particle: :spacing, category: :spatial, type: :string })
13
+ new({ particle: :display, category: :spatial, type: :boolean }) do |params|
14
14
  params = { mode: params } unless params.instance_of? Hash
15
15
  params
16
16
  end
17
- new({ particle: :layout }) do |params|
17
+ new({ particle: :layout, category: :spatial, type: :int }) do |params|
18
18
  mode_found = params.delete(:mode) || :list
19
19
  elements_style = params.delete(:element) || {}
20
20
  # now we get the list of the atome to layout
@@ -86,7 +86,7 @@ new({ particle: :layout }) do |params|
86
86
  end
87
87
  params
88
88
  end
89
- new({ particle: :center, type: :hash }) do |params|
89
+ new({ particle: :center, category: :spatial, type: :hash }) do |params|
90
90
  params = { x: 0, y: 0, dynamic: true } if params == true
91
91
  params
92
92
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # create particles
4
- new({ particle: :markers, type: :hash })
4
+ new({ particle: :markers, category: :time, type: :hash })
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- new({ particle: :renderers })
4
- new({ particle: :code })
5
- new({ particle: :run }) do |params|
3
+ new({ particle: :renderers, category: :utility, type: :string })
4
+ new({ particle: :code, category: :utility, type: :string })
5
+ new({ particle: :run, category: :utility, type: :boolean }) do |params|
6
6
  code_found = @code
7
7
  instance_exec(params, &code_found) if code_found.is_a?(Proc)
8
8
  end
@@ -24,7 +24,7 @@ def delete_recursive(atome_id)
24
24
  Universe.delete(atome_id)
25
25
  end
26
26
 
27
- new({ particle: :delete, render: false }) do |params|
27
+ new({ particle: :delete, category: :utility, type: :boolean, render: false }) do |params|
28
28
  if params == true
29
29
  # We use the tag persistent to exclude color of system object and other default colors
30
30
  unless @tag && (@tag[:persistent] || @tag[:system])
@@ -63,7 +63,7 @@ new({ particle: :delete, render: false }) do |params|
63
63
  send(params, 0) unless params == :id
64
64
  end
65
65
  end
66
- new({ particle: :clear })
66
+ new({ particle: :clear, category: :utility, type: :boolean })
67
67
 
68
68
  new({ post: :clear }) do
69
69
  attached_found = []
@@ -76,8 +76,8 @@ new({ post: :clear }) do
76
76
  child_found&.delete(true) unless child_found.tag && child_found.tag[:system]
77
77
  end
78
78
  end
79
- new({ particle: :path })
80
- new({ particle: :schedule }) do |date, proc|
79
+ new({ particle: :path, category: :utility, type: :string })
80
+ new({ particle: :schedule, category: :utility, type: :string }) do |date, proc|
81
81
  date = date.to_s
82
82
  delimiters = [',', ' ', ':', '-']
83
83
  format_date = date.split(Regexp.union(delimiters))
@@ -85,14 +85,14 @@ new({ particle: :schedule }) do |date, proc|
85
85
  send("#{renderer}_schedule", format_date, &proc)
86
86
  end
87
87
  end
88
- new({ particle: :read }) do |file, proc|
89
- Universe.renderer_list.each do |renderer|
90
- send("#{renderer}_reader", file, &proc)
91
- end
92
- end
93
- new({ particle: :cursor })
88
+ # new({ particle: :read, category: :utility, type: :string }) do |file, proc|
89
+ # Universe.renderer_list.each do |renderer|
90
+ # send("#{renderer}_reader", file, &proc)
91
+ # end
92
+ # end
93
+ new({ particle: :cursor, category: :utility, type: :string })
94
94
 
95
- new({ particle: :preset }) do |params|
95
+ new({ particle: :preset, category: :utility, type: :string }) do |params|
96
96
 
97
97
  if params.instance_of? Hash
98
98
  Essentials.new_default_params(params)
@@ -109,24 +109,26 @@ new({ particle: :preset }) do |params|
109
109
  end
110
110
  params_to_send
111
111
  end
112
- new({ particle: :relations, type: :hash })
113
- new({ particle: :tag, render: false, type: :hash })
114
- new({ particle: :web })
112
+ new({ particle: :relations, category: :utility, type: :hash })
113
+ new({ particle: :tag, render: false, category: :utility, type: :hash })
114
+ new({ particle: :web, category: :utility, type: :string })
115
115
  # new({ particle: :metrics, type: :hash })
116
+ # do not change the line below initialise is a special method
116
117
  new({ initialize: :unit, value: {} })
117
- new({ particle: :login }) do |params|
118
+
119
+ new({ particle: :login, category: :utility, type: :string }) do |params|
118
120
  set_current_user(id) if params
119
121
  end
120
- new({ particle: :hypertext })
121
- new({ particle: :hyperedit })
122
- new({ particle: :terminal })
123
- new({ particle: :read })
124
- new({ particle: :browse })
125
- new({ particle: :copies })
126
- new({ particle: :temporary })
127
- new({ particle: :atomes })
122
+ new({ particle: :hypertext, category: :utility, type: :string })
123
+ new({ particle: :hyperedit, category: :utility, type: :string })
124
+ new({ particle: :terminal, category: :utility, type: :string })
125
+ new({ particle: :read, category: :utility, type: :string })
126
+ new({ particle: :browse, category: :utility, type: :string })
127
+ new({ particle: :copies, category: :utility, type: :string})
128
+ new({ particle: :temporary, category: :utility, type: :int })
129
+ new({ particle: :atomes, category: :utility, type: :string })
128
130
 
129
- new({ particle: :match }) do |params, _bloc|
131
+ new({ particle: :match, category: :utility, type: :string }) do |params, _bloc|
130
132
  params
131
133
  end
132
134
 
@@ -135,10 +137,10 @@ new({ sanitizer: :match }) do |params, _bloc|
135
137
  params
136
138
  end
137
139
 
138
- new({ particle: :invert })
139
- new({ particle: :option })
140
+ new({ particle: :invert, category: :utility, type: :boolean })
141
+ new({ particle: :option, category: :utility, type: :string })
140
142
 
141
- new({ particle: :duplicate, store: false }) do |params|
143
+ new({ particle: :duplicate, category: :utility, type: :string, store: false }) do |params|
142
144
  copy_number = if @duplicate
143
145
  @duplicate.length
144
146
  else
@@ -192,12 +194,12 @@ new({ after: :duplicate }) do |params|
192
194
  @duplicate[@duplicate.keys[@duplicate.keys.length - 1]]
193
195
  end
194
196
 
195
- new({ particle: :copy }) do |items_id|
197
+ new({ particle: :copy, category: :utility, type: :string }) do |items_id|
196
198
  items_id = [items_id] unless items_id.instance_of? Array
197
199
  grab(:copy).collect << items_id
198
200
  end
199
201
 
200
- new({ particle: :paste }) do |params|
202
+ new({ particle: :paste, category: :utility, type: :string }) do |params|
201
203
 
202
204
  all_copies = grab(:copy).collect
203
205
  if params == true
@@ -227,25 +229,25 @@ new({ read: :paste }) do |p|
227
229
  @copy
228
230
  end
229
231
 
230
- new({ particle: :backup })
232
+ new({ particle: :backup, category: :utility, type: :string })
231
233
 
232
- new({ particle: :import })
234
+ new({ particle: :import, category: :utility, type: :string })
233
235
 
234
- new({ particle: :compute }) do |params|
236
+ new({ particle: :compute, category: :utility, type: :string }) do |params|
235
237
  params = { particle: params } unless params.instance_of?(Hash)
236
238
  params[:unit] ||= :pixel
237
239
  params[:reference] ||= :view
238
240
  params
239
241
  end
240
242
 
241
- new({ particle: :get }) do |params|
243
+ new({ particle: :get, category: :utility, type: :string }) do |params|
242
244
  cell = params[:cell]
243
245
  row_nb = cell[0]
244
246
  column_nb = cell[1]
245
247
  data[row_nb][data[row_nb].keys[column_nb]] # we get the content of the cell
246
248
  end
247
249
 
248
- new ({ particle: :css })
250
+ new ({ particle: :css, category: :utility, type: :string })
249
251
 
250
252
  new({ read: :css }) do
251
253
  CssProxy.new(js, nil, self)
@@ -12,6 +12,7 @@ class Genesis
12
12
 
13
13
  def build_particle(particle_name, options = {}, &particle_proc)
14
14
  type = options[:type]
15
+ category = options[:category]
15
16
  type = :string if options[:type].nil?
16
17
  store = options[:store]
17
18
  store = true if options[:store].nil?
@@ -19,7 +20,7 @@ class Genesis
19
20
  render = true if options[:render].nil?
20
21
 
21
22
  # we add the new method to the particle's collection of methods
22
- Universe.add_to_particle_list(particle_name, type)
23
+ Universe.add_to_particle_list(particle_name, type, category)
23
24
  # the line below create an empty particle method for each renderer, eg: browser_left, headless_width, ...
24
25
  # the line below create the corresponding particle method for Batch class
25
26
  # particle_method_for_batch(particle_name)
@@ -46,12 +46,12 @@ Atome.new(
46
46
 
47
47
  Atome.new(
48
48
  { renderers: default_render, id: :back_selection, type: :color, tag: ({ system: true, persistent: true }),
49
- red: 0.6, green: 0.6, blue: 0.1, alpha: 0.7}
49
+ red: 0.6, green: 0.6, blue: 0.1, alpha: 0.7 }
50
50
  )
51
51
 
52
52
  Atome.new(
53
53
  { renderers: default_render, id: :text_selection, type: :color, tag: ({ system: true, persistent: true }),
54
- red: 0.3, green: 0.3, blue: 0.3, alpha: 0.9}
54
+ red: 0.3, green: 0.3, blue: 0.3, alpha: 0.9 }
55
55
  )
56
56
 
57
57
  # system object creation
@@ -72,7 +72,7 @@ Atome.new(
72
72
  # unreal port, hold system object and tools
73
73
  Atome.new(
74
74
  { renderers: default_render, id: :intuition, type: :shape, attach: :user_view, tag: { system: true },
75
- left: 0, top: 0, bottom: 0,width: 0, height: :auto, overflow: :visible
75
+ left: 0, top: 0, bottom: 0, width: 0, height: :auto, overflow: :visible
76
76
  }
77
77
  )
78
78
 
@@ -83,15 +83,14 @@ machine_password = { read: { atome: :star_wars }, write: { atome: :star_wars } }
83
83
  # copy basket
84
84
  Atome.new({ renderers: [:html], id: :copy, collect: [], type: :group, tag: { system: true } })
85
85
 
86
-
87
- #machine
86
+ # machine
88
87
  Atome.new({ renderers: default_render, id: machine_id, type: :machine, password: machine_password,
89
88
  name: :macAir, data: { date: '10090717' }, tag: { system: true } })
90
89
 
91
- #user
92
- user_password = {global: :star_win, read: { atome: :star_wars }, write: { atome: :star_wars } }
90
+ # user
91
+ user_password = { global: :star_win, read: { atome: :star_wars }, write: { atome: :star_wars } }
93
92
 
94
- human({ id: :anonymous, login: true, password: user_password, data: { birthday: '10/05/1996' },selection: [], attach: :user_view })
93
+ human({ id: :anonymous, login: true, password: user_password, data: { birthday: '10/05/1996' }, selection: [], attach: :user_view })
95
94
 
96
95
  Universe.current_machine = machine_id
97
96
  # the constant A is used to access alla atomes methods
@@ -116,7 +115,6 @@ def atome_infos
116
115
  puts "server: #{server}"
117
116
  end
118
117
 
119
-
120
118
  # help and example below :
121
119
  #
122
120
  A.example(:left) do
@@ -139,5 +137,27 @@ STR
139
137
  end
140
138
  end
141
139
 
142
- # we init server default address now initialise in index.html for server
143
- # A.server({ address: 'localhost:9292' , type: 'ws'})
140
+ # the method below init the user
141
+ def atome_genesis
142
+ atome_infos
143
+ A.server({ address: 'localhost:9292', type: 'ws' })
144
+ A.init_websocket
145
+ end
146
+
147
+ def init_database # this method is call from JS (atome/communication)
148
+
149
+ particles = Universe.particle_list
150
+ categories = Universe.categories
151
+ atomes = Universe.atomes
152
+ # particles.each do |particle, value|
153
+ # value[:category] = :undefined if value[:category].nil?
154
+ # A.message({ action: :init_db, particle: particle, type: value[:type], category: value[:category] })
155
+ # end
156
+ end
157
+
158
+ def user_login
159
+ user = Universe.current_user
160
+ pass = Black_matter.password
161
+ message({ action: :login, value: user })
162
+ message({ action: :pass, value: pass })
163
+ end
@@ -19,34 +19,37 @@ class Atome
19
19
  JS.eval(js_command)
20
20
  end
21
21
 
22
- # def global_monitoring(instance, methods_to_monitor, variables_to_monitor)
23
- # methods_to_monitor.each do |methode|
24
- # original_method = instance.method(methode)
25
- # instance.define_singleton_method(methode) do |*args, &block|
26
- # value_before = instance.instance_variable_get("@#{methode}")
27
- # result = original_method.call(*args, &block)
28
- # value_after = instance.instance_variable_get("@#{methode}")
29
- # if args.empty?
30
- # # "read monitoring: #{methode}"
31
- # elsif value_before != value_after
32
- # affect.each do |targeted_atome|
33
- # # get the content of the affect instance_variable and send it
34
- # # to the affect method to apply the atome to all atome children
35
- # grab(targeted_atome).render(:apply, self)
36
- # end
37
- # end
38
- # result
39
- # end
40
- # end
41
- # variables_to_monitor.each do |var|
42
- # instance.define_singleton_method(var) do
43
- # instance_variable_get("@#{var}")
44
- # end
45
- # instance.define_singleton_method("#{var}=") do |value|
46
- # instance_variable_set("@#{var}", value)
47
- # end
48
- # end
49
- # end
22
+ # monitoring system
23
+ def monitoring(atomes_to_monitor, particles_to_monitor, &bloc)
24
+ atomes_to_monitor.each do |atome_to_monitor|
25
+ particles_to_monitor.each do |monitored_particle|
26
+ # Store original method
27
+ original_method = atome_to_monitor.method(monitored_particle)
28
+
29
+ # redefine method
30
+ atome_to_monitor.define_singleton_method(monitored_particle) do |*args, &proc|
31
+
32
+ # Monitor before calling original method
33
+ value_before = atome_to_monitor.instance_variable_get("@#{monitored_particle}")
34
+ if args.empty?
35
+ args = nil
36
+ else
37
+ if monitored_particle == :touch
38
+ instance_variable_set("@#{monitored_particle}", { tap: args[0] })
39
+ instance_variable_set("@#{monitored_particle}_code", { touch: proc })
40
+
41
+ args = { tap: args[0] }
42
+ else
43
+ instance_variable_set("@#{monitored_particle}", args[0])
44
+ end
45
+ args = args[0]
46
+ end
47
+ instance_exec({ original: value_before, altered: args, particle: monitored_particle }, &bloc) if bloc.is_a?(Proc)
48
+ original_method.call(*args)
49
+ end
50
+ end
51
+ end
52
+ end
50
53
 
51
54
  end
52
55
 
@@ -203,39 +206,73 @@ class Atome
203
206
  # FIXME : find a better algorithm can be found to avoid test if option is a Hash
204
207
  Object.attr_accessor "#{element}_code"
205
208
  elem_code = "@#{element}_code"
206
- if params.instance_of? Hash
207
- option_found = params.values[0]
208
- instance_variable_get(elem_code)["#{option_found}_code"] = user_proc
209
- else
209
+ # if params.instance_of? Hash
210
+ # option_found = params.values[0]
211
+ # instance_variable_get(elem_code)["#{option_found}_code"] = user_proc
212
+ # else
210
213
  instance_variable_get(elem_code)[element] = user_proc
211
- end
212
- # the commented line below will automatically execute the callback method
213
- # we keep it commented because sometime the execution is conditioned, ex : run callbck on a touch
214
- # send("#{element}_callback")
214
+ # end
215
215
  end
216
216
 
217
- # this method is used to automatically create a callback method sufifxed par '_callbback' ex :.shell => shell_callback
217
+ # ###################### new 1
218
+ # def store_proc(element, params = true, &user_proc)
219
+ # instance_variable_set("@#{element}_code", {}) unless instance_variable_get("@#{element}_code")
220
+ # # TODO : we may have to change this code if we need multiple proc for an particle
221
+ # # FIXME : find a better algorithm can be found to avoid test if option is a Hash
222
+ # Object.attr_accessor "#{element}_code"
223
+ # elem_code = "@#{element}_code"
224
+ # if params.instance_of? Hash
225
+ # option_found = params.values[0]
226
+ # puts "#{instance_variable_get(elem_code)["#{option_found}_code"]}"
227
+ # proc_stored= instance_variable_get(elem_code)["#{option_found}_code"] = []
228
+ # # proc_stored=[]
229
+ # else
230
+ # proc_stored= instance_variable_get(elem_code)[element] = []
231
+ # end
232
+ # proc_stored << user_proc
233
+ # # the commented line below will automatically execute the callback method
234
+ # # we keep it commented because sometime the execution is conditioned, ex : run callbck on a touch
235
+ # # send("#{element}_callback")
236
+ # end
237
+ # ##################### new 1
238
+
239
+ # This method is used to automatically create a callback method suffixed by '_callback'. For example: shell => shell_callback.
218
240
  # it can be override if you create a method like:
219
241
  # new({callback: :shell}) do |params, bloc|
220
242
  # # …write what you want …
221
243
  # end
222
244
  def particle_callback(element)
223
- Atome.define_method "#{element}_callback" do
224
- proc_found = instance_variable_get("@#{element}_code")[element]
225
- # instance_exec(@callback[element], proc_found)if proc_found.is_a? Proc
226
- proc_found.call(@callback[element]) if proc_found.is_a? Proc
245
+ Atome.define_method("#{element}_callback") do |return_params|
246
+ # we test if instance_variable_get("@#{element}_code") is a hash for the can se the particle value is a hash
247
+ proc_found = if instance_variable_get("@#{element}_code").instance_of? Hash
248
+ # Then we get the first item of the hash because the proc is attached to it
249
+ instance_variable_get("@#{element}_code").values.first
250
+ # instance_exec(@callback[element], proc_found)if proc_found.is_a? Proc
251
+ else
252
+ instance_variable_get("@#{element}_code")[element]
253
+ # instance_exec(@callback[element], proc_found)if proc_found.is_a? Proc
254
+ end
255
+ # array_of_proc_found.each do |proc_found|
256
+ proc_found.call(return_params) if proc_found.is_a? Proc
257
+ # end if array_of_proc_found
258
+
259
+ # if array_of_proc_found
260
+ # proc_found= array_of_proc_found.shift
261
+ # proc_found.call(return_params) if proc_found.is_a? Proc
262
+ # end
263
+
227
264
  end
228
265
  end
229
266
 
230
267
  # this method generate the method accessible for end developers
231
268
  # it's the send the method define in "particle_callback"
232
- def call(element)
233
- send("#{element}_callback")
269
+ def callback(element, return_params = nil)
270
+ send("#{element}_callback", return_params)
234
271
  end
235
272
 
236
- def callback(data)
237
- @callback[data.keys[0]] = data[data.keys[0]]
238
- end
273
+ # def callback(data)
274
+ # @callback[data.keys[0]] = data[data.keys[0]]
275
+ # end
239
276
 
240
277
  def particles(particles_found = nil)
241
278
  if particles_found
@@ -341,15 +378,37 @@ class Atome
341
378
  else
342
379
  @current_server
343
380
  end
381
+ end
344
382
 
383
+ def server_receiver(params)
384
+ # alert params
385
+ # alert message_code
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)
345
394
  end
346
395
 
347
396
  def init_websocket
348
- connection(server)
397
+ instance_variable_set('@message_code', {})
398
+ # connection is particle (communication.rb)
399
+ connection(@current_server)
349
400
  end
350
401
 
351
- def init_database # this method is call from JS (atome/communication)
352
- message({action: :init_db, value: {atome: {}, particles: {}} })
402
+
403
+
404
+ def encrypt(string)
405
+ # if RUBY_ENGINE.downcase == 'opal' || 'wasm32-wasi'
406
+ # `sha256(#{string})`
407
+ js_code = "sha256('#{string}')"
408
+ JS.eval(js_code)
409
+ # else
410
+ # Digest::SHA256.hexdigest(string)
411
+ # end
353
412
  end
354
413
  end
355
414
 
@@ -9,6 +9,9 @@ class Universe
9
9
  @renderer_list = %i[html browser headless server log]
10
10
  @sanitizers = {}
11
11
  @specificities = {}
12
+
13
+ @categories = %w[ communication effect event geometry hierarchy identity material
14
+ property security spatial time utility ]
12
15
  @history = {}
13
16
  @users = {}
14
17
  @help = {}
@@ -33,8 +36,12 @@ class Universe
33
36
  @example[particle]
34
37
  end
35
38
 
36
- def add_to_particle_list(particle = nil, type)
37
- instance_variable_get('@particle_list')[particle] = type
39
+ def categories
40
+ @categories
41
+ end
42
+
43
+ def add_to_particle_list(particle = nil, type, category)
44
+ instance_variable_get('@particle_list')[particle] = { type: type, category: category }
38
45
  end
39
46
 
40
47
  def add_atomes_specificities atome_type_to_add
@@ -78,9 +85,7 @@ class Universe
78
85
  def user_atomes
79
86
  collected_id = []
80
87
  @atomes.each do |id_found, atome_found|
81
- unless atome_found.tag && atome_found.tag[:system]
82
- collected_id << id_found
83
- end
88
+ collected_id << id_found unless atome_found.tag && atome_found.tag[:system]
84
89
  end
85
90
  collected_id
86
91
  end
@@ -88,9 +93,7 @@ class Universe
88
93
  def system_atomes
89
94
  collected_id = []
90
95
  @atomes.each do |id_found, atome_found|
91
- if atome_found.tag && atome_found.tag[:system]
92
- collected_id << id_found
93
- end
96
+ collected_id << id_found if atome_found.tag && atome_found.tag[:system]
94
97
  end
95
98
  collected_id
96
99
  end
@@ -153,7 +156,8 @@ class Universe
153
156
  end
154
157
 
155
158
  def current_server
156
- return unless RUBY_ENGINE.downcase == 'opal' # Remplacez 'atome' par la valeur correcte pour votre environnement Atome
159
+ # Remplacez 'atome' par la valeur correcte pour votre environnement Atome
160
+ return unless RUBY_ENGINE.downcase == 'opal'
157
161
  JS.global[:location][:href].to_s
158
162
 
159
163
  end
data/lib/atome/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  # return atome version
4
4
  class Atome
5
- VERSION = '0.5.6.1.4'
5
+ VERSION = '0.5.6.2.0'
6
6
  end
7
7
 
data/lib/eVe/eVe.rb CHANGED
@@ -1 +1 @@
1
- puts "so cool!!!"
1
+ puts "eVe ready!!"
@@ -1 +1 @@
1
- puts "so good!!!"
1
+ puts "eve initialised"