atome 0.5.3.8.8 → 0.5.4.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +52 -17
  3. data/app_builder_helpers/Rakefile +20 -3
  4. data/exe/atome +33 -1
  5. data/lib/atome/atome.rb +43 -57
  6. data/lib/atome/extensions/atome.rb +82 -52
  7. data/lib/atome/extensions/mathematic.rb +8 -12
  8. data/lib/atome/extensions/matrix.rb +138 -210
  9. data/lib/atome/genesis/generators/atome.rb +8 -134
  10. data/lib/atome/genesis/generators/communication.rb +0 -1
  11. data/lib/atome/genesis/generators/effect.rb +0 -6
  12. data/lib/atome/genesis/generators/event.rb +64 -77
  13. data/lib/atome/genesis/generators/geometry.rb +0 -18
  14. data/lib/atome/genesis/generators/identity.rb +6 -33
  15. data/lib/atome/genesis/generators/material.rb +3 -54
  16. data/lib/atome/genesis/generators/utility.rb +63 -58
  17. data/lib/atome/genesis/genesis.rb +8 -0
  18. data/lib/atome/genesis/sparkle.rb +35 -16
  19. data/lib/atome/helpers/callbacks.rb +47 -1
  20. data/lib/atome/helpers/essentials.rb +1 -1
  21. data/lib/atome/helpers/sanitizer.rb +0 -10
  22. data/lib/atome/helpers/utilities.rb +74 -28
  23. data/lib/atome/kernel/batch.rb +13 -35
  24. data/lib/atome/kernel/universe.rb +2 -0
  25. data/lib/atome/presets/atome.rb +4 -12
  26. data/lib/atome/renderers/browser/atome.rb +1 -1
  27. data/lib/atome/renderers/browser/browser.rb +2 -0
  28. data/lib/atome/renderers/browser/event.rb +18 -0
  29. data/lib/atome/renderers/browser/helpers/drag_helper.rb +13 -0
  30. data/lib/atome/renderers/browser/helpers/drop_helper.rb +13 -0
  31. data/lib/atome/renderers/browser/helpers/event_helper.rb +16 -11
  32. data/lib/atome/renderers/browser/helpers/over_helper.rb +13 -0
  33. data/lib/atome/renderers/browser/helpers/text_helper.rb +5 -1
  34. data/lib/atome/renderers/browser/spatial.rb +3 -2
  35. data/lib/atome/renderers/browser/utility.rb +7 -7
  36. data/lib/atome/version.rb +2 -2
  37. data/lib/atome.rb +1 -0
  38. data/sig/atome.rbs +16 -0
  39. data/sig/batch.rbs +7 -0
  40. data/sig/browser_helper.rbs +14 -0
  41. data/sig/matrix.rbs +5 -0
  42. data/sig/object.rbs +3 -0
  43. data/vendor/assets/aui.rb +5 -0
  44. data/vendor/assets/src/index.html +15 -3
  45. data/vendor/assets/src/js/atome/atome.js +1 -1
  46. data/vendor/assets/src/js/atome/atome_helpers/atome_animate.js +1 -1
  47. data/vendor/assets/src/js/atome/atome_helpers/atome_communication.js +40 -0
  48. data/vendor/assets/src/js/atome/atome_helpers/atome_drag.js +40 -3
  49. data/vendor/assets/src/js/atome/atome_helpers/atome_drop.js +12 -0
  50. data/vendor/assets/src/js/atome/atome_helpers/atome_events.js +166 -0
  51. data/vendor/assets/src/js/atome/atome_helpers/atome_file.js +6 -1
  52. data/vendor/assets/src/js/atome/atome_helpers/atome_over.js +43 -0
  53. data/vendor/assets/src/medias/rubies/demos.rb +63 -0
  54. data/vendor/assets/src/medias/rubies/examples/add.rb +1 -1
  55. data/vendor/assets/src/medias/rubies/examples/animation.rb +1 -1
  56. data/vendor/assets/src/medias/rubies/examples/atome_new.rb +1 -1
  57. data/vendor/assets/src/medias/rubies/examples/attach.rb +10 -10
  58. data/vendor/assets/src/medias/rubies/examples/attached.rb +2 -3
  59. data/vendor/assets/src/medias/rubies/examples/batch.rb +17 -0
  60. data/vendor/assets/src/medias/rubies/examples/blur.rb +2 -2
  61. data/vendor/assets/src/medias/rubies/examples/box.rb +2 -2
  62. data/vendor/assets/src/medias/rubies/examples/code.rb +1 -1
  63. data/vendor/assets/src/medias/rubies/examples/color.rb +3 -3
  64. data/vendor/assets/src/medias/rubies/examples/delete.rb +17 -1
  65. data/vendor/assets/src/medias/rubies/examples/detached.rb +3 -3
  66. data/vendor/assets/src/medias/rubies/examples/drag.rb +52 -1
  67. data/vendor/assets/src/medias/rubies/examples/drop.rb +26 -0
  68. data/vendor/assets/src/medias/rubies/examples/fullscreen.rb +1 -1
  69. data/vendor/assets/src/medias/rubies/examples/markers.rb +1 -1
  70. data/vendor/assets/src/medias/rubies/examples/matrix.rb +102 -0
  71. data/vendor/assets/src/medias/rubies/examples/matrix_changes.rb +483 -0
  72. data/vendor/assets/src/medias/rubies/examples/matrix_simple.rb +32 -0
  73. data/vendor/assets/src/medias/rubies/examples/monitoring.rb +1 -1
  74. data/vendor/assets/src/medias/rubies/examples/mute.rb +1 -1
  75. data/vendor/assets/src/medias/rubies/examples/on.rb +1 -1
  76. data/vendor/assets/src/medias/rubies/examples/over.rb +6 -4
  77. data/vendor/assets/src/medias/rubies/examples/pause.rb +1 -1
  78. data/vendor/assets/src/medias/rubies/examples/physical.rb +19 -0
  79. data/vendor/assets/src/medias/rubies/examples/play.rb +1 -1
  80. data/vendor/assets/src/medias/rubies/examples/repeat.rb +3 -2
  81. data/vendor/assets/src/medias/rubies/examples/shadow.rb +1 -1
  82. data/vendor/assets/src/medias/rubies/examples/sort.rb +3 -4
  83. data/vendor/assets/src/medias/rubies/examples/tags.rb +10 -0
  84. data/vendor/assets/src/medias/rubies/examples/text.rb +4 -4
  85. data/vendor/assets/src/medias/rubies/examples/time.rb +2 -2
  86. data/vendor/assets/src/medias/rubies/examples/video.rb +2 -2
  87. data/vendor/assets/src/medias/rubies/{examples → unstable}/_2_solve.rb +1 -1
  88. data/vendor/assets/src/medias/rubies/{examples → unstable}/_audio.rb +1 -1
  89. data/vendor/assets/src/medias/rubies/{examples → unstable}/_dataset.rb +4 -4
  90. data/vendor/assets/src/medias/rubies/{examples → unstable}/_table2.rb +2 -2
  91. data/vendor/assets/src/medias/rubies/{examples → unstable}/_vie.rb +2 -2
  92. data/vendor/assets/src/utilities/mode.rb +0 -0
  93. data/vendor/assets/src-tauri/tauri.conf.json +2 -2
  94. metadata +32 -14
  95. data/vendor/assets/src/medias/rubies/examples/table.rb +0 -479
  96. /data/vendor/assets/src/medias/rubies/{examples → unstable}/!run.rb +0 -0
  97. /data/vendor/assets/src/medias/rubies/{examples → unstable}/_attach.rb +0 -0
  98. /data/vendor/assets/src/medias/rubies/{examples → unstable}/_matrix.rb +0 -0
  99. /data/vendor/assets/src/medias/rubies/{examples → unstable}/_os.rb +0 -0
  100. /data/vendor/assets/src/medias/rubies/{examples → unstable}/_test.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e15b6625b3ba6dd5801418dd7dab9f9d0670dedb65e3ea8caa03df984f29541
4
- data.tar.gz: 5a23055c7535a94ebe0c29b4dd226477b99564aa73a7f2640c533447bf24f52e
3
+ metadata.gz: 81fc451e1fa30a44d57e1fb6405f96e3e9fc8930740c750d9267a89bc2952fa0
4
+ data.tar.gz: 9048ed1b43c9a1f8c732a3b63af02a47480a6dd82a33f9c8d0f9e2f36e9a5f57
5
5
  SHA512:
6
- metadata.gz: ca47d04143b5d3cdec3120da89f863f3edaf84cbebee58fc257a8d12c7f1c2d699752ba6cc9e98e080cb10fbebe8900c788bd1c698705a59c7c0dfaa891073db
7
- data.tar.gz: f1757fb74688cddb937f1a40790dd33ca121485a2446e2a5236f8de6ae9b302726b71521d2decd455e3cfca9613e37600075e91f3e96cf0777da3b5d67b4cb88
6
+ metadata.gz: aa62f9692742e709ce866a2b5eb983d198e15d635ff5a47e1e1a5f809942abd9e8b6a7e3328fcf8fd2bb2b41cf3925ec03f03ee6acc15018ebfef424b2fd05de
7
+ data.tar.gz: a2c193b0b0613985aa7c55e425158264dcbd7df127e1b5df5a3b65df2f2a9d2de725059010135f12576604cfe1afb9006f8142bf289c3a70962641ce55df027f
data/Rakefile CHANGED
@@ -11,48 +11,83 @@ end
11
11
 
12
12
  task default: :test
13
13
 
14
- task :re_build do
14
+ task :test_build do
15
15
  FileUtils.copy_entry('vendor/assets/src/js/', 'test/test_app/src/js/')
16
16
  FileUtils.copy_entry('vendor/assets/src/css/', 'test/test_app/src/css/')
17
17
  FileUtils.copy_entry('vendor/assets/src/medias/', 'test/test_app/src/medias/')
18
- `gem cleanup atome;yes | gem uninstall atome;gem build atome.gemspec;gem install atome --local`
18
+
19
+ `rake build`
20
+ `cd pkg; gem install atome --local`
19
21
  `cd test/test_app;atome update`
22
+ `cd test/test_app;atome refresh`
20
23
  puts 'solution re-build!'
21
- # `cd test/test_app;atome update;atome run`
24
+
22
25
  end
23
26
 
24
- task :run_browser do
27
+ task :test_browser do
25
28
  FileUtils.copy_entry('vendor/assets/src/js/', 'test/test_app/src/js/')
26
29
  FileUtils.copy_entry('vendor/assets/src/css/', 'test/test_app/src/css/')
27
30
  FileUtils.copy_entry('vendor/assets/src/medias/', 'test/test_app/src/medias/')
28
- `gem cleanup atome;yes | gem uninstall atome;gem build atome.gemspec;gem install atome --local`
29
31
  `cd test/test_app;atome update;atome run compile`
32
+ `open test/test_app/src/index.html`
30
33
  puts 'atome browser is running'
31
34
  end
32
35
 
36
+ task :test_build_browser do
37
+ FileUtils.copy_entry('vendor/assets/src/js/', 'test/test_app/src/js/')
38
+ FileUtils.copy_entry('vendor/assets/src/css/', 'test/test_app/src/css/')
39
+ FileUtils.copy_entry('vendor/assets/src/medias/', 'test/test_app/src/medias/')
33
40
 
34
- task :test_server do
41
+ `rake build`
42
+ `cd pkg; gem install atome --local`
43
+ `cd test/test_app;atome update`
44
+ `cd test/test_app;atome refresh`
45
+ `cd test/test_app;atome update;atome run browser guard `
46
+ # `open test/test_app/src/index.html`
47
+ puts 'atome browser is running'
48
+ end
49
+
50
+ task :test_build_osx do
35
51
  FileUtils.copy_entry('vendor/assets/src/js/', 'test/test_app/src/js/')
36
52
  FileUtils.copy_entry('vendor/assets/src/css/', 'test/test_app/src/css/')
37
53
  FileUtils.copy_entry('vendor/assets/src/medias/', 'test/test_app/src/medias/')
38
- `gem cleanup atome;yes | gem uninstall atome ;gem build atome.gemspec;gem install atome --local`
39
- `cd test/test_app;atome update;atome run server`
54
+
55
+ `rake build`
56
+ `cd pkg; gem install atome --local`
57
+ `cd test/test_app;atome update`
58
+ `cd test/test_app;atome refresh`
59
+ `cd test/test_app;atome update;atome run osx guard`
60
+ # `cd test/test_app;atome run osx guard`
61
+ puts 'atome osx is running'
62
+ end
63
+
64
+ task :cleanup do
65
+ `gem cleanup atome;yes | gem uninstall atome;cd pkg`
40
66
  end
41
67
 
42
68
 
43
- task :run_server do
44
- `cd test/test_app;atome run server guard`
69
+ task :test_server do
70
+ FileUtils.copy_entry('vendor/assets/src/js/', 'test/test_app/src/js/')
71
+ FileUtils.copy_entry('vendor/assets/src/css/', 'test/test_app/src/css/')
72
+ FileUtils.copy_entry('vendor/assets/src/medias/', 'test/test_app/src/medias/')
73
+ `gem cleanup atome;yes | gem uninstall atome ;gem build atome.gemspec;cd pkg; gem install atome --local`
74
+ `cd test/test_app;atome update;atome run server guard`
45
75
  end
46
76
 
77
+
78
+ # task :run_server do
79
+ # `cd test/test_app;atome run server guard`
80
+ # end
81
+
47
82
  task :refresh do
48
83
  FileUtils.copy_entry('vendor/assets/src/medias/rubies/examples/', 'test/test_app/src/medias/rubies/examples/')
49
84
  `cd test/test_app;atome build`
50
85
  puts "refreshed!"
51
86
  end
52
87
 
53
- task :open_browser do
54
- `open http://127.0.0.1:1430/`
55
- end
88
+ # task :open_server do
89
+ # `open http://127.0.0.1:1430/`
90
+ # end
56
91
 
57
92
  task :run_example_server do
58
93
  FileUtils.copy_entry('vendor/assets/src/medias/rubies/examples/', 'test/test_app/src/medias/rubies/examples/')
@@ -60,11 +95,11 @@ task :run_example_server do
60
95
  end
61
96
 
62
97
 
63
- task :taurification do
64
- `cd test/test_app;cargo tauri dev`
65
- end
98
+ # task :taurification do
99
+ # `cd test/test_app;cargo tauri dev`
100
+ # end
66
101
 
67
- task :osx do
102
+ task :test_osx do
68
103
  `cd test/test_app;atome run osx guard`
69
104
  end
70
105
 
@@ -108,14 +108,29 @@ def build_user_code(user_project_path, source_code)
108
108
  application_js = "#{user_project_path}/src/js/application.js"
109
109
  builder = Opal::Builder.new
110
110
  builder.append_paths("#{user_project_path}/")
111
- application_content = builder.build(source_code).to_s
112
111
 
112
+ builder.build("#{source_code}/src/utilities/mode.rb").to_s
113
+
114
+ # aui = builder.build("#{source_code}/aui.rb").to_s
115
+ application_content = builder.build("#{source_code}/application/index.rb").to_s
116
+
117
+ # full_app=aui+"\n"+system_infos+"\n"+application_content
113
118
  File.open(application_js, 'w') do |f|
114
119
  f.puts application_content
115
120
  end
116
121
  # minimize_application(user_project_path)
117
122
  end
118
123
 
124
+ def build_system_infos(user_project_path, source_code)
125
+ system_infos_js = "#{user_project_path}/src/js/infos.js"
126
+ builder = Opal::Builder.new
127
+ builder.append_paths("#{user_project_path}/")
128
+ system_infos = builder.build("#{source_code}/src/utilities/mode.rb").to_s
129
+ File.open(system_infos_js, 'w') do |f|
130
+ f.puts system_infos
131
+ end
132
+ end
133
+
119
134
  def minimize_aui(user_project_path)
120
135
  aui_js = "#{user_project_path}/src/js/aui.js"
121
136
  aui_content = File.open(aui_js).read
@@ -220,15 +235,17 @@ end
220
235
 
221
236
  task :build_user_code, :user_project_path, :production do |_t, args|
222
237
  user_project_path = args[:user_project_path]
223
- source_code = "#{user_project_path}/application/index.rb"
238
+ source_code = "#{user_project_path}"
239
+ build_system_infos(user_project_path, source_code)
224
240
  build_user_code(user_project_path, source_code)
225
241
  end
226
242
 
227
243
  task :system_builder, :user_project_path, :production do |_t, args|
228
244
  user_project_path = args[:user_project_path]
229
245
  production = args[:production]
230
- source_code = '../vendor/assets/application/index.rb'
246
+ source_code = '../vendor/assets'
231
247
  build_common_libraries(user_project_path, production)
248
+ build_system_infos(user_project_path, source_code)
232
249
  build_user_code(user_project_path, source_code)
233
250
 
234
251
  # TODO: catch and message to user when when there's no force and folder already exist
data/exe/atome CHANGED
@@ -123,7 +123,7 @@ def guard_check
123
123
  end
124
124
 
125
125
  def browser_case(location)
126
- # `cd #{location}/src;open index.html`
126
+ `cd #{location}/src;open index.html`
127
127
  # `echo jello`
128
128
  # guard_check
129
129
  end
@@ -215,27 +215,59 @@ if ARGV.include?('guard')
215
215
  end
216
216
  end
217
217
 
218
+ def set_atome_mode(location, mode)
219
+ mode_file = "#{location}/src/utilities/mode.rb"
220
+ file_found = File.open(mode_file)
221
+ atome_mode=<<~STR
222
+ $host = :#{mode}
223
+ STR
224
+ File.open(file_found, 'w') do |f|
225
+ f.puts atome_mode
226
+ end
227
+ end
228
+
218
229
  if ARGV.include?('run')
219
230
  path = if location != '/'
220
231
  "#{`pwd`.chomp}/#{location}"
221
232
  else
222
233
  found_path('run')
223
234
  end
235
+ demo_location = "#{path}/src/medias/rubies"
236
+
237
+ filenames = Dir.glob(demo_location+'/examples/*.rb')
238
+ demos_list_content=[]
239
+ filenames.each do |path|
240
+ filename= File.basename(path)
241
+ demos_list_content << filename
242
+ end
243
+ demos_list_file = "#{demo_location}/demos_list.rb"
244
+ File.open(demos_list_file, 'w') do |f|
245
+ # f.puts "class Atome_demo\n def demos_list\n #{demos_list_content}\n end\nend"
246
+ f.puts "def demos_list\n #{demos_list_content}\nend"
247
+ end
248
+
249
+
224
250
 
225
251
  case build_target
226
252
  when 'android'
253
+ set_atome_mode(path,'tauri')
227
254
  # TODO: write code here
228
255
  when 'browser'
256
+ set_atome_mode(path,'browser')
229
257
  run_application(:browser, path)
230
258
  when 'freebsd'
259
+ set_atome_mode(path,'native')
231
260
  # TODO: write code here
232
261
  when 'ios'
262
+ set_atome_mode(path,'tauri')
233
263
  # TODO: write code here
234
264
  when 'linux'
235
265
  # TODO: write code here
236
266
  when 'osx'
267
+ set_atome_mode(path,'tauri')
237
268
  run_application(:osx, path)
238
269
  when 'server'
270
+ set_atome_mode(path,'server')
239
271
  config_location = "#{path}/server/config.ru"
240
272
  file = File.open(config_location)
241
273
  text = file.read
data/lib/atome/atome.rb CHANGED
@@ -14,15 +14,21 @@ class Atome
14
14
  def initialize(atomes = {}, &atomes_proc)
15
15
 
16
16
  atomes.each_value do |elements|
17
- # the instance variable below contain the id all any atomes that need to be informed when changes occurs
18
- @broadcast = {}
19
- # now we store the proc in a an atome's property called :bloc
20
- elements[:code] = atomes_proc if atomes_proc
21
-
22
- @atome = elements
23
- # we initiate the rendering suing set_type method,
24
- # eg for for browser we will call :browser_type generate method in identity.rb file
25
- collapse
17
+
18
+ if Universe.atomes.key?(elements[:id])
19
+ puts "The id #{elements[:id]} is already taken, you must change it"
20
+ # `throw new Error("this id is already exist, you must change it");`
21
+ else
22
+ # the instance variable below contain the id all any atomes that need to be informed when changes occurs
23
+ @broadcast = {}
24
+ # # now we store the proc in a an atome's property called :bloc
25
+ elements[:code] = atomes_proc if atomes_proc
26
+
27
+ @atome = elements
28
+ # we initiate the rendering suing set_type method,
29
+ # eg for for browser we will call :browser_type generate method in identity.rb file
30
+ collapse
31
+ end
26
32
  end
27
33
  end
28
34
 
@@ -34,8 +40,12 @@ class Atome
34
40
  params = sanitize(element, params, &user_proc)
35
41
  create_particle(element, store, render)
36
42
  send("set_#{element}", params, &user_proc)
43
+ elsif element == :batch # TODO : find a better solution than a condition if possible
44
+ @atome[:batch]
37
45
  else
38
- get_particle(element, &user_proc)
46
+
47
+ @atome[element]
48
+ # get_particle(element, &user_proc)
39
49
  end
40
50
  end
41
51
  end
@@ -50,51 +60,37 @@ class Atome
50
60
 
51
61
  def atome_parsing(element, params, &user_proc)
52
62
  params = sanitize(element, params)
53
- current_atome = send(element).value
63
+ current_atome = send(element)
54
64
 
55
65
  # The condition below check if we need to add or replace the newly created atome
56
66
  if current_atome && !(@atome[:add] && @atome[:add][element])
57
67
  detached(current_atome)
58
68
  @atome[element] = []
59
69
  end
60
-
61
-
62
70
  # TODO :replace with the line below but need extensive testing as it crash some demos ex: animation
63
71
  params = atome_common(element, params)
64
- # ############ code to remove below
65
- # parent_found = found_parents_and_renderers[:parent]
66
- # render_found = found_parents_and_renderers[:renderers]
67
- # default_params = Essentials.default_params[element] || {}
68
- # generated_id = params[:id] || identity_generator(element)
69
- #
70
- # default_params = { renderers: render_found, id: generated_id, type: element,
71
- # attach: parent_found }.merge(default_params)
72
- # params = default_params.merge(params).merge({ clones: [] })
73
- # ############ code to remove above
74
- # puts params[:renderers]
75
- # puts params[:id]
76
- # new_params= {renderers: params[:renderers], id: params[:id]}.merge(params)
77
- #
78
- # params=new_params
79
- # puts "new_params : #{params}"
80
- ###
81
- ###
82
- # puts "params :\n #{params}\n\n, params2 :\n #{params2}"
83
72
  run_optional_proc("pre_render_#{@atome[:type]}".to_sym, self, params, &user_proc)
84
73
  run_optional_proc("post_render_#{@atome[:type]}".to_sym, self, params, &user_proc)
85
74
  send("set_#{element}", params, &user_proc) # it call Atome.define_method "set_#{element}" in new_atome method
86
75
  end
87
76
 
88
- def new_atome(element, &method_proc)
77
+ def atome_catcher(atome_catch)
78
+ # puts "atome_catch is : #{atome_catch.class}"
79
+ atome_catch
80
+ end
89
81
 
82
+ def new_atome(element, &method_proc)
90
83
  # the method define below is the slowest but params are analysed and sanitized
91
84
  Atome.define_method element do |params = nil, &user_proc|
92
85
  if params
93
86
  instance_exec(params, user_proc, &method_proc) if method_proc.is_a?(Proc)
94
87
  atome_parsing(element, params, &user_proc)
95
88
  else
96
- get_atome(element, &user_proc)
89
+ # puts "******> we are searching for the atome return(noobs) #{element} : #{id}"
90
+ # puts "no atome params"
91
+ atome_catcher(@atome[element])
97
92
  end
93
+
98
94
  end
99
95
 
100
96
  # the method define below is the fastest params are passed directly
@@ -104,11 +100,13 @@ class Atome
104
100
  new_atome = Atome.new({ element => params }, &user_proc)
105
101
  # Now we return the newly created atome instead of the current atome that is the parent cf: b=box; c=b.circle
106
102
  # c must return the circle not the parent box
107
- new_atome
103
+ # puts "******> we are searching for the atome return(set) #{element} : #{id}"
104
+ # puts "no set atome params"
105
+ atome_catcher(new_atome)
106
+
108
107
  end
109
108
  # the method below generate Atome method creation at Object level
110
- create_method_at_object_level(element)
111
-
109
+ # create_method_at_object_level(element)
112
110
  end
113
111
 
114
112
  def new_render_engine(renderer_name, &method_proc)
@@ -120,6 +118,12 @@ class Atome
120
118
  def run_optional_proc(proc_name, atome = self, params, &user_proc)
121
119
  # params = instance_variable_get("@#{element}")
122
120
  option_found = Universe.get_optional_method(proc_name)
121
+
122
+ # if option_found.is_a?(Proc)
123
+ # # alert "#{proc_name} : #{params} "
124
+ # else
125
+ # puts "proc_name : #{proc_name}, \noption_found : (#{option_found})"
126
+ # end
123
127
  atome.instance_exec(params, user_proc, atome, &option_found) if option_found.is_a?(Proc)
124
128
  end
125
129
 
@@ -145,9 +149,9 @@ class Atome
145
149
  store_code_bloc(element, &user_proc) if user_proc
146
150
  # Params is now an instance variable so it should be passed thru different methods
147
151
  instance_variable_set("@#{element}", params) if store
148
- run_optional_proc("pre_render_#{element}".to_sym, self, params, &user_proc)
152
+ run_optional_proc("pre_render_#{element}", self, params, &user_proc)
149
153
  rendering(element, params, &user_proc) if render
150
- run_optional_proc("post_render_#{element}".to_sym, self, params, &user_proc)
154
+ run_optional_proc("post_render_#{element}", self, params, &user_proc)
151
155
  broadcasting(element)
152
156
  store_value(element) if store
153
157
  self
@@ -163,23 +167,5 @@ class Atome
163
167
  @atome[element]
164
168
  end
165
169
 
166
- def get_particle(element, &user_proc)
167
- virtual_atome = Atome.new({})
168
- virtual_atome.value = (@atome[element])
169
- virtual_atome.real_atome = @atome
170
- virtual_atome.property = element
171
- virtual_atome.user_proc = user_proc
172
- virtual_atome
173
- end
174
-
175
- def get_atome(element, &user_proc)
176
- virtual_atome = Atome.new({})
177
- virtual_atome.real_atome = @atome
178
- virtual_atome.property = element
179
- virtual_atome.user_proc = user_proc
180
- virtual_atome.value = @atome[element]
181
- virtual_atome
182
- end
183
-
184
170
  Universe.connected
185
171
  end
@@ -1,53 +1,83 @@
1
1
  # frozen_string_literal: true
2
- def new(params, &bloc)
3
- generator = Genesis.generator
4
- if params.key?(:particle)
5
- # render indicate if the particle needs to be rendered
6
- # store tell the system if it need to store the particle value
7
- # type help the system what type of type the particle will receive and store
8
- generator.build_particle(params[:particle], { render: params[:render],
9
- store: params[:store], type: params[:type] }, &bloc)
10
- elsif params.key?(:atome)
11
- generator.build_atome(params[:atome], &bloc)
12
- elsif params.key?(:sanitizer)
13
- generator.build_sanitizer(params[:sanitizer], &bloc)
14
- elsif params.key?(:pre)
15
- generator.build_option("pre_render_#{params[:pre]}", &bloc)
16
- elsif params.key?(:post)
17
- generator.build_option("post_render_#{params[:post]}", &bloc)
18
- elsif params.key?(:browser)
19
- generator.build_render("browser_#{params[:browser]}", &bloc)
20
- end
21
- end
22
-
23
- def identity_generator(type = :element)
24
- "#{type}_#{Universe.counter}"
25
- # { date: Time.now, location: geolocation }
26
- end
27
-
28
- def grab(atome_to_get)
29
- atome_to_get = atome_to_get.value if atome_to_get.instance_of? Atome
30
- Universe.atomes[atome_to_get]
31
- end
32
-
33
- def box(params = {}, &proc)
34
- grab(:view).box(params, &proc)
35
- end
36
-
37
- def circle(params = {}, &proc)
38
- grab(:view).circle(params, &proc)
39
- end
40
-
41
- def matrix(params = {}, &proc)
42
- grab(:view).matrix(params, &proc)
43
- end
44
-
45
- # the method below generate Atome method creation at Object level
46
- def create_method_at_object_level(element)
47
-
48
- Object.define_method element do |params, &user_proc|
49
- default_parent=Essentials.default_params[element][:attach][0] # we get the first parents
50
- grab(default_parent).send(element, params, &user_proc)
51
- end
52
-
53
- end
2
+
3
+ class Object
4
+ def new(params, &bloc)
5
+ generator = Genesis.generator
6
+ if params.key?(:particle)
7
+ # render indicate if the particle needs to be rendered
8
+ # store tell the system if it need to store the particle value
9
+ # type help the system what type of type the particle will receive and store
10
+ generator.build_particle(params[:particle], { render: params[:render], return: params[:return],
11
+ store: params[:store], type: params[:type] }, &bloc)
12
+ elsif params.key?(:atome)
13
+ atome_return = params[:return] || params[:atome]
14
+ generator.build_atome(params[:atome], &bloc)
15
+ elsif params.key?(:sanitizer)
16
+ generator.build_sanitizer(params[:sanitizer], &bloc)
17
+ elsif params.key?(:pre)
18
+ generator.build_option("pre_render_#{params[:pre]}", &bloc)
19
+ elsif params.key?(:post)
20
+ generator.build_option("post_render_#{params[:post]}", &bloc)
21
+ elsif params.key?(:browser)
22
+ generator.build_render("browser_#{params[:browser]}", &bloc)
23
+ end
24
+ end
25
+
26
+ def batch (atomes)
27
+ grab(:black_matter).batch(atomes)
28
+ end
29
+
30
+ def identity_generator(type = :element)
31
+ "#{attach[0]}_#{type}_#{Universe.counter}"
32
+ end
33
+
34
+ def grab(atome_to_get)
35
+
36
+ Universe.atomes[atome_to_get]
37
+ end
38
+
39
+ def box(params = {}, &proc)
40
+ grab(:view).box(params, &proc)
41
+ end
42
+
43
+ def circle(params = {}, &proc)
44
+ grab(:view).circle(params, &proc)
45
+ end
46
+
47
+ def matrix(params = {}, &proc)
48
+ grab(:view).matrix(params, &proc)
49
+ end
50
+
51
+ # def method_missing(method, *args, &block)
52
+ # args.each do |atome_found|
53
+ # args.each do |arg|
54
+ # default_parent = Essentials.default_params[method][:attach][0] # we get the first parents
55
+ # # create_method_at_object_level(element)
56
+ # atome_found = grab(default_parent).send(method, arg, &block)
57
+ # # we force then return of atome found else its return an hash # TODO : we may find a cleaner solution
58
+ # return atome_found
59
+ # end
60
+ # end
61
+ # end
62
+
63
+ # the method below generate Atome method creation at Object level
64
+ def atome_method_for_object(element)
65
+
66
+ Object.define_method element do |params, &user_proc|
67
+ default_parent = Essentials.default_params[element][:attach][0] # we get the first parents
68
+ grab(default_parent).send(element, params, &user_proc)
69
+ end
70
+ end
71
+
72
+ def atome_method_for_batch(element)
73
+ Batch.define_method element do |params, &user_proc|
74
+ dispatch(element, [params], &user_proc)
75
+ end
76
+ end
77
+ def particle_method_for_batch(element)
78
+ Batch.define_method element do |params, &user_proc|
79
+ dispatch(element, [params], &user_proc)
80
+ end
81
+ end
82
+
83
+ end
@@ -1,24 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Atome
4
- def /val
5
- val=val.value if val.instance_of? Atome
6
- value/val
4
+ def /(val)
5
+ value / val
7
6
  end
8
7
 
9
- def *val
10
- val=val.value if val.instance_of? Atome
11
- value*val
8
+ def *(val)
9
+ value * val
12
10
  end
13
11
 
14
- def -val
15
- val=val.value if val.instance_of? Atome
16
- value-val
12
+ def -(val)
13
+ value - val
17
14
  end
18
15
 
19
16
 
20
- def +val
21
- val=val.value if val.instance_of? Atome
22
- value+val
17
+ def +(val)
18
+ value + val
23
19
  end
24
20
  end