atome 0.5.6.5.7 → 0.5.6.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68520365f777d89089e99069c4aeea1209fd49d16b0c30ece6661e2baeae2b19
4
- data.tar.gz: d0e89c48a346f113eed4e0f6358a06a564979c178832e402ffc7cda26ffb14d3
3
+ metadata.gz: e69d3973a46163db0b12ee3798bf424a134ddd776fefe6073565a89b0ede0424
4
+ data.tar.gz: 282f0b4f60cfd45aa0347742bc43e58397276ecc2d1d01fc89733100f5f6a4c5
5
5
  SHA512:
6
- metadata.gz: 1ee22c49e15973e262a2a6c889070e53055cf6321eefba4651102bb68ee997a6c80cbe5eb3c4bdfff4f40dac3ca18b9419d1a610615ae265b0ed7b6fe76c5bd4
7
- data.tar.gz: 48ee8736a2a7bee1c798352c14b4ba9275f1a0c62ca4dac4351624f673899561d4875db85e6ccc267a6f34ce7e8e94df1261099d9a987b662dc5eea9942d7649
6
+ metadata.gz: ec25093999f6c76f352800e9dd49b30babe2cf5d2816e2a0e3f43c93592be2a76bded2a1327916d1037c582fd08234db9f937c4a87a2ae52c87161822ef6d086
7
+ data.tar.gz: f61645010752da69b7d3e2c62bfb92f8c237e5f3b731f12077949e6daafc466f0c14f3b21982878850a57f006f80e68c989c1b4b29692a0c1304f3587268ec4c
data/lib/atome/atome.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # main Atome entry here
4
+ # used as a callback when the atome is ready
5
+ # Atome.instance_variable_set('@initialized',{})
4
6
  class Atome
5
7
  include Essentials
6
8
 
@@ -8,6 +10,14 @@ class Atome
8
10
  @aid
9
11
  end
10
12
 
13
+ # dummy method to catch a method get all instance variable and try to call a method but initialized is only an
14
+ # instance variable not a method
15
+ # FIXME : replace all
16
+ # def initialized(*_msg)
17
+ #
18
+ # end
19
+
20
+
11
21
  def initialize(new_atome = {}, &atomes_proc)
12
22
  # TODO: atome format should always be as followed : {value: 0.44, unit: :px, opt1: 554}
13
23
  # when using optimised version of atome you must type eg : a.set({left: {value: 33, unit: '%', reference: :center}})
@@ -19,7 +29,6 @@ class Atome
19
29
  # # old_atome.send(element, value)
20
30
  # # end
21
31
  # # return false
22
- # alert "atome found : #{ grab(new_atome[:id])}"
23
32
  # grab(new_atome[:id])
24
33
  # else
25
34
  # the keys :renderers, :type and :id should be placed in the first position in the hash
@@ -46,6 +55,8 @@ class Atome
46
55
  # @backup={} # mainly used to restore particle when using grid /table /list display mode
47
56
  @html = HTML.new(@id, self)
48
57
  @headless = Headless.new(@id, self)
58
+ @initialized={}
59
+ @creator= Universe.current_user
49
60
  # now we store the proc in a an atome's property called :bloc
50
61
  new_atome[:code] = atomes_proc if atomes_proc
51
62
  # we reorder the hash
@@ -53,6 +64,18 @@ class Atome
53
64
  # FIXME : try to remove the condition below (it crash in the method : def generator ... in genesis.rb)
54
65
  collapse(reordered_atome)
55
66
  # end
67
+ # puts "@initialized : #{Atome.instance_variable_get('@initialized')}"
68
+ # puts "****> #{Atome.instance_variable_get('@initialized')}"
69
+
70
+ # if Atome.instance_variable_get('@initialized')
71
+ # puts "-----> #{Atome.instance_variable_get('@initialized')}"
72
+ # Atome.instance_variable_get('@initialized').each do |p_found, bloc|
73
+ # # puts "==> #{p_found}"
74
+ # # instance_exec.call
75
+ # # instance_exec(p_found, &bloc) if bloc.is_a?(Proc)
76
+ # end
77
+ # end
78
+
56
79
 
57
80
  end
58
81
 
@@ -76,7 +99,7 @@ class Atome
76
99
  # post rendering processor
77
100
  params = particle_post(element, params, &user_proc)
78
101
  instance_variable_set("@#{element}", params) if store
79
- # post storage processor
102
+ # after storage processor
80
103
  particle_after(element, params, &user_proc)
81
104
 
82
105
  # self
@@ -91,3 +114,5 @@ class Atome
91
114
  "#<#{self.class}: #{content}>"
92
115
  end
93
116
  end
117
+
118
+
@@ -4,12 +4,12 @@ module ObjectExtension
4
4
  def new(params, &bloc)
5
5
  # Genesis = Genesis.Genesis
6
6
  if params.key?(:atome)
7
- if Universe.atome_list.include?(params[:atome])
8
- puts "atome #{params[:atome]} already exist you can't create it"
9
- else
7
+ # if Universe.atome_list.include?(params[:atome])
8
+ # puts "atome #{params[:atome]} already exist you can't create it"
9
+ # else
10
10
  Universe.add_atomes_specificities params[:atome]
11
11
  Genesis.build_atome(params[:atome], &bloc)
12
- end
12
+ # end
13
13
  elsif params.key?(:particle)
14
14
  if Universe.particle_list[params[:particle]]
15
15
  puts "particle #{params[:particle]} already exist you can't create it"
@@ -31,6 +31,8 @@ module ObjectExtension
31
31
  Atome.instance_variable_set("@post_#{params[:post]}", bloc)
32
32
  elsif params.key?(:after)
33
33
  Atome.instance_variable_set("@after_#{params[:after]}", bloc)
34
+ elsif params.key?(:initialized)
35
+ Atome.initialized[params[:initialized]] = bloc
34
36
  elsif params.key?(:read)
35
37
  Atome.instance_variable_set("@read_#{params[:read]}", bloc)
36
38
  elsif params[:renderer]
@@ -440,9 +442,12 @@ class Object
440
442
  particle_list.delete(:password)
441
443
  particle_list.delete(:selection)
442
444
  infos = {}
445
+ particle_list[:css]=:poil
443
446
  particle_list.each do |particle_found|
444
447
  infos[particle_found[0]] = send(particle_found[0]) unless send(particle_found[0]).nil?
445
448
  end
449
+ # we convert CssProxy object to hash below
450
+ infos[:css]=eval(infos[:css].to_s)
446
451
  infos
447
452
  end
448
453
 
@@ -82,6 +82,10 @@ new({ atome: :border }) do |params|
82
82
  end
83
83
  params
84
84
  end
85
+ new({ post: :border }) do |params|
86
+ # in order to apply the color to the atome border if a color is passed
87
+ color(params[:color])
88
+ end
85
89
  new({ atome: :raw })
86
90
  new({ atome: :shape })
87
91
  new({ atome: :code })
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- new({ particle: :creator, category: :atome, type: :hash })
3
+ new({ particle: :creator, category: :atome, type: :hash, store: false })
4
4
  new({ particle: :aid, category: :atome, type: :string, store: false })
@@ -129,3 +129,8 @@ new({ particle: :sort, category: :property, type: :int }) do |params|
129
129
 
130
130
  params
131
131
  end
132
+
133
+ new({particle: :inside, render: false})
134
+ new({ initialized: :inside }) do |params, &user_proc|
135
+ render(:inside, params, &user_proc)
136
+ end
@@ -86,11 +86,7 @@ new({ particle: :schedule, category: :utility, type: :string }) do |date, proc|
86
86
  send("#{renderer}_schedule", format_date, &proc)
87
87
  end
88
88
  end
89
- # new({ particle: :read, category: :utility, type: :string }) do |file, proc|
90
- # Universe.renderer_list.each do |renderer|
91
- # send("#{renderer}_reader", file, &proc)
92
- # end
93
- # end
89
+
94
90
  new({ particle: :cursor, category: :utility, type: :string })
95
91
 
96
92
  new({ particle: :preset, category: :utility, type: :string }) do |params|
@@ -154,27 +150,8 @@ new({ particle: :duplicate, category: :utility, type: :string, store: false }) d
154
150
  else
155
151
  0
156
152
  end
157
- new_atome_id = "#{@id}_copy_#{copy_number}"
158
- new_atome = Atome.new({ type: @type, renderers: @renderers, id: new_atome_id })
159
-
160
153
  attached_atomes = []
161
154
  attached_found = attached.dup
162
- particles_found = instance_variables.dup
163
-
164
- keys_to_delete = [:@history, :@callback, :@duplicate, :@copy, :@paste, :@touch_code, :@html, :@attached, :@id]
165
- keys_to_delete.each { |key| particles_found.delete(key) }
166
- params[:id] = new_atome_id
167
-
168
- particles_found.each do |particle_found|
169
- particle_name = particle_found.to_s.sub('@', '')
170
-
171
- particle_content = self.send(particle_name)
172
- # FIXME: find a better to attach object when false is found
173
- particle_content = :view if particle_content == false
174
- new_atome.set(particle_name => particle_content)
175
- # new_atome.instance_variable_set('@touch_code',touch_code)
176
- end
177
-
178
155
  attached_found.each do |child_id_found|
179
156
  child_found = grab(child_id_found)
180
157
  if child_found
@@ -183,19 +160,17 @@ new({ particle: :duplicate, category: :utility, type: :string, store: false }) d
183
160
  end
184
161
  end
185
162
  params[:attached] = attached_atomes
186
- # FIXME: below dunno why we have to add this manually
187
- new_atome.height(@height)
188
- new_atome.width(@width)
189
- if params.instance_of? Hash
190
- params.each do |k, v|
191
- new_atome.send(k, v)
192
- end
193
- end
194
-
163
+ infos_found =infos.dup
164
+ keys_to_delete = [ :history, :callback, :duplicate, :copy, :paste, :touch_code, :html, :attached, :aid]
165
+ keys_to_delete.each { |key| infos_found.delete(key) }
166
+ new_atome_id = "#{@id}_copy_#{copy_number}".to_sym
167
+ infos_found[:id]=new_atome_id
168
+ infos_found=infos_found.merge(params)
169
+ new_atome =Atome.new( infos_found)
195
170
  @duplicate ||= {}
196
171
  @duplicate[new_atome_id] = new_atome
197
-
198
172
  new_atome
173
+
199
174
  end
200
175
 
201
176
  new({ after: :duplicate }) do |params|
@@ -113,6 +113,7 @@ def atome_infos
113
113
  server = Universe.current_server
114
114
  server ||= 'disconnected'
115
115
  puts "server: #{server}"
116
+
116
117
  end
117
118
 
118
119
  # help and example below :
@@ -207,6 +208,8 @@ def user_login
207
208
  sync({ action: :authorization, data: { password: password } }) do |pass|
208
209
  puts "password received : #{pass}"
209
210
  end
211
+
210
212
  end
211
213
 
212
- # Universe.allow_history=true
214
+ puts '------------------------'
215
+ Universe.allow_history=true
@@ -242,9 +242,10 @@ class Universe
242
242
 
243
243
  def historicize(id, operation, element, params)
244
244
 
245
- if @allow_history && @database_ready
246
- A.sync({ action: :historicize, data: { table: :user } }) do |_db_state|
247
- end
245
+ # if @allow_history && @database_ready
246
+ if @allow_history
247
+ # A.sync({ action: :historicize, data: { table: :user } }) do |_db_state|
248
+ # end
248
249
  operation_timing = Time.now.strftime("%Y%m%d%H%M%S%3N") + @increment.to_s
249
250
  @increment += 1
250
251
  @increment = @increment % 100
@@ -253,20 +254,21 @@ class Universe
253
254
  end
254
255
  end
255
256
 
256
- def story(filter)
257
- # temp algo awaiting db to be ready, just for POC and tests
258
- return unless filter
259
-
260
- operation = filter[:operation]
261
- atome_id = filter[:id]
262
- particle = filter[:particle]
263
- filtered_history = []
264
- @history.each do |operation_number, alteration|
265
- if alteration[atome_id] && (alteration[atome_id][operation]) && (alteration[atome_id][operation][particle])
266
- filtered_history << { operation: operation_number, filter[:particle] => alteration[atome_id][operation][particle], sync: alteration[:sync], time: alteration[:time] }
267
- end
268
- end
269
- filtered_history
257
+ def story
258
+ @history
259
+ # # temp algo awaiting db to be ready, just for POC and tests
260
+ # return unless filter
261
+ #
262
+ # operation = filter[:operation]
263
+ # atome_id = filter[:id]
264
+ # particle = filter[:particle]
265
+ # filtered_history = []
266
+ # @history.each do |operation_number, alteration|
267
+ # if alteration[atome_id] && (alteration[atome_id][operation]) && (alteration[atome_id][operation][particle])
268
+ # filtered_history << { operation: operation_number, filter[:particle] => alteration[atome_id][operation][particle], sync: alteration[:sync], time: alteration[:time] }
269
+ # end
270
+ # end
271
+ # filtered_history
270
272
  end
271
273
 
272
274
  end
@@ -5,10 +5,9 @@ require 'json'
5
5
 
6
6
  class Atome
7
7
  class << self
8
+ attr_accessor :initialized
8
9
 
9
-
10
-
11
-
10
+ # end
12
11
  def file_handler(parent, content, bloc)
13
12
  grab(parent).instance_exec(content, &bloc)
14
13
  end
@@ -56,6 +55,8 @@ class Atome
56
55
 
57
56
  end
58
57
 
58
+ @initialized = {}
59
+
59
60
  def help(particle, &doc)
60
61
  if doc
61
62
  Universe.set_help(particle, &doc)
@@ -92,10 +93,21 @@ class Atome
92
93
  end
93
94
 
94
95
  def collapse(new_atome)
95
- # TODO : try to optimise the two lines below to avoid conditions
96
+ initialized_procs = []
97
+ initialized = Atome.initialized
98
+
96
99
  new_atome.each do |element, value|
97
100
  send(element, value)
101
+ initialized_proc = initialized[element]
102
+ initialized_procs << {value => initialized_proc } if initialized_proc.is_a?(Proc)
103
+ end
104
+
105
+ initialized_procs.each do |value|
106
+ value.each do |val, proc|
107
+ instance_exec(val, &proc)
108
+ end
98
109
  end
110
+
99
111
  end
100
112
 
101
113
  def particle_main(element, params, &user_proc)
@@ -154,7 +166,7 @@ class Atome
154
166
  end
155
167
 
156
168
  def atome_sanitizer(element, params, &user_proc)
157
- # Attention: the method is the same as the one used for the partcicle
169
+ # Attention: the method is the same as the one used for the particle
158
170
  particle_sanitizer(element, params)
159
171
  end
160
172
 
@@ -188,9 +200,14 @@ class Atome
188
200
  #
189
201
  # end
190
202
 
191
- def history(filter = {})
192
- filter[:id] = @id
193
- Universe.story(filter)
203
+ # def history(filter = {})
204
+ #
205
+ # filter[:id] = @id
206
+ # Universe.story(filter)
207
+ # end
208
+
209
+ def history
210
+ Universe.story
194
211
  end
195
212
 
196
213
  # def broadcasting(element)
@@ -294,10 +311,10 @@ class Atome
294
311
  end
295
312
  end
296
313
 
297
- def to_hash
314
+ def particles_to_hash
298
315
  hash = {}
299
316
  instance_variables.each do |var|
300
- next if %i[@html_object @history].include?(var)
317
+ next if %i[@html_object @history, @initialized].include?(var)
301
318
 
302
319
  hash[var.to_s.delete('@').to_sym] = instance_variable_get(var)
303
320
  end
@@ -306,13 +323,13 @@ class Atome
306
323
 
307
324
  def refresh
308
325
  # we get the current color because they will be removed
309
- particles_found = to_hash
326
+ particles_found = particles_to_hash
310
327
  particles_found.each do |particle_found, value_found|
311
328
  send(particle_found, value_found)
312
329
  end
313
- color.each do |col|
314
- apply(col)
315
- end
330
+ color.each do |col|
331
+ apply(col)
332
+ end
316
333
  end
317
334
 
318
335
  def each(&proc)
@@ -404,10 +421,11 @@ class Atome
404
421
  # Digest::SHA256.hexdigest(string)
405
422
  # end
406
423
  end
424
+
407
425
  def get_localstorage_content
408
- storage= JS.global[:localStorage]
409
- storage_array= storage.to_a
410
- storage_items={}
426
+ storage = JS.global[:localStorage]
427
+ storage_array = storage.to_a
428
+ storage_items = {}
411
429
  storage_array.each_with_index do |_i, index|
412
430
  key = JS.global[:localStorage].key(index)
413
431
  value = JS.global[:localStorage].getItem(key)
@@ -417,7 +435,7 @@ class Atome
417
435
  end
418
436
 
419
437
  def sanitize_data_for_json(data)
420
- data=data.gsub('"', '\\"')
438
+ data = data.gsub('"', '\\"')
421
439
  # case data
422
440
  # when String
423
441
  # data.gsub('"', '\\"')
@@ -432,8 +450,8 @@ class Atome
432
450
  end
433
451
 
434
452
  def send_localstorage_content
435
- storage= JS.global[:localStorage]
436
- storage_array= storage.to_a
453
+ storage = JS.global[:localStorage]
454
+ storage_array = storage.to_a
437
455
  # storage_items={}
438
456
  storage_array.each_with_index do |_i, index|
439
457
  key = JS.global[:localStorage].key(index)
@@ -450,16 +468,16 @@ class Atome
450
468
  # end
451
469
  end
452
470
 
453
- def to_sym
454
- puts "sanitizer temp patch when an atome is passed instead of an id"
455
- @id
456
- end
471
+ # def to_sym
472
+ # puts "sanitizer temp patch when an atome is passed instead of an id"
473
+ # @id
474
+ # end
457
475
 
458
476
  def sync(params, &bloc)
459
477
  params = { data: params } unless params.instance_of? Hash
460
- message_id= "msg_#{Universe.messages.length}"
461
- params[:message_id]=message_id
462
- Universe.store_messages({msg_nb:message_id, proc: bloc })
478
+ message_id = "msg_#{Universe.messages.length}"
479
+ params[:message_id] = message_id
480
+ Universe.store_messages({ msg_nb: message_id, proc: bloc })
463
481
  html.send_message(params)
464
482
  end
465
483
  end
data/lib/atome/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  # return atome version
4
4
  class Atome
5
- VERSION = '0.5.6.5.7'
5
+ VERSION = '0.5.6.6.0'
6
6
  end
data/lib/atome.rb CHANGED
@@ -15,6 +15,7 @@ require 'atome/extensions/mathematics'
15
15
  require 'atome/atome'
16
16
  require 'atome/genesis/atomes'
17
17
  require 'atome/presets/atome'
18
+ require 'atome/utilities/utilities'
18
19
  require 'atome/genesis/particles/atome'
19
20
  require 'atome/genesis/particles/communication'
20
21
  require 'atome/genesis/particles/effect'
@@ -28,7 +29,6 @@ require 'atome/genesis/particles/security'
28
29
  require 'atome/genesis/particles/spatial'
29
30
  require 'atome/genesis/particles/time'
30
31
  require 'atome/genesis/particles/utility'
31
- require 'atome/utilities/utilities'
32
32
  require 'atome/utilities/security'
33
33
  require 'renderers/html/index'
34
34
  require 'renderers/headless/index'
@@ -36,4 +36,3 @@ require 'renderers/server/index'
36
36
  require 'atome/utilities/sanitizer'
37
37
  require 'atome/genesis/sparkle'
38
38
  require 'molecules/init'
39
- # require 'eVe/lib/eVe'
@@ -14,6 +14,7 @@ require_relative './atome/extensions/mathematics'
14
14
  require_relative './atome/atome'
15
15
  require_relative './atome/genesis/atomes'
16
16
  require_relative './atome/presets/atome'
17
+ require_relative './atome/utilities/utilities'
17
18
  require_relative './atome/genesis/particles/atome'
18
19
  require_relative './atome/genesis/particles/communication'
19
20
  require_relative './atome/genesis/particles/effect'
@@ -27,7 +28,6 @@ require_relative './atome/genesis/particles/security'
27
28
  require_relative './atome/genesis/particles/spatial'
28
29
  require_relative './atome/genesis/particles/time'
29
30
  require_relative './atome/genesis/particles/utility'
30
- require_relative './atome/utilities/utilities'
31
31
  require_relative './atome/utilities/security'
32
32
  require_relative './renderers/html/index_relative'
33
33
  require_relative './renderers/headless/index_relative'
@@ -35,4 +35,3 @@ require_relative './renderers/server/index_relative'
35
35
  require_relative './atome/utilities/sanitizer'
36
36
  require_relative './atome/genesis/sparkle'
37
37
  require_relative './molecules/init'
38
- # require_relative './eVe/lib/eVe'