atome 0.5.3.8.1 → 0.5.3.8.8

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +3 -3
  3. data/lib/atome/atome.rb +49 -46
  4. data/lib/atome/extensions/atome.rb +2 -2
  5. data/lib/atome/extensions/matrix.rb +27 -16
  6. data/lib/atome/genesis/generators/atome.rb +128 -85
  7. data/lib/atome/genesis/generators/identity.rb +82 -51
  8. data/lib/atome/genesis/generators/spatial.rb +8 -8
  9. data/lib/atome/genesis/generators/utility.rb +26 -17
  10. data/lib/atome/genesis/genesis.rb +7 -4
  11. data/lib/atome/genesis/sparkle.rb +6 -6
  12. data/lib/atome/helpers/essentials.rb +21 -18
  13. data/lib/atome/helpers/sanitizer.rb +10 -10
  14. data/lib/atome/helpers/utilities.rb +81 -29
  15. data/lib/atome/kernel/batch.rb +0 -1
  16. data/lib/atome/kernel/universe.rb +1 -1
  17. data/lib/atome/presets/atome.rb +22 -23
  18. data/lib/atome/renderers/browser/atome.rb +2 -1
  19. data/lib/atome/renderers/browser/helpers/browser_helper.rb +17 -0
  20. data/lib/atome/renderers/browser/helpers/text_helper.rb +10 -2
  21. data/lib/atome/renderers/browser/identity.rb +23 -5
  22. data/lib/atome/renderers/browser/utility.rb +5 -4
  23. data/lib/atome/renderers/renderer.rb +1 -0
  24. data/lib/atome/version.rb +1 -1
  25. data/sig/atome.rbs +20 -0
  26. data/sig/essentials.rbs +11 -0
  27. data/vendor/assets/src/medias/images/icons/email.svg +12 -12
  28. data/vendor/assets/src/medias/rubies/examples/add.rb +2 -3
  29. data/vendor/assets/src/medias/rubies/examples/animation.rb +2 -2
  30. data/vendor/assets/src/medias/rubies/examples/atome_new.rb +18 -6
  31. data/vendor/assets/src/medias/rubies/examples/{parents.rb → attach.rb} +6 -6
  32. data/vendor/assets/src/medias/rubies/examples/attached.rb +4 -4
  33. data/vendor/assets/src/medias/rubies/examples/box.rb +1 -1
  34. data/vendor/assets/src/medias/rubies/examples/code.rb +1 -1
  35. data/vendor/assets/src/medias/rubies/examples/color.rb +20 -4
  36. data/vendor/assets/src/medias/rubies/examples/delete.rb +2 -2
  37. data/vendor/assets/src/medias/rubies/examples/drag.rb +1 -1
  38. data/vendor/assets/src/medias/rubies/examples/fullscreen.rb +1 -1
  39. data/vendor/assets/src/medias/rubies/examples/image.rb +2 -2
  40. data/vendor/assets/src/medias/rubies/examples/link.rb +7 -5
  41. data/vendor/assets/src/medias/rubies/examples/markers.rb +1 -1
  42. data/vendor/assets/src/medias/rubies/examples/materials.rb +15 -0
  43. data/vendor/assets/src/medias/rubies/examples/monitoring.rb +44 -18
  44. data/vendor/assets/src/medias/rubies/examples/read.rb +2 -2
  45. data/vendor/assets/src/medias/rubies/examples/shadow.rb +1 -1
  46. data/vendor/assets/src/medias/rubies/examples/table.rb +2 -2
  47. data/vendor/assets/src/medias/rubies/examples/text.rb +4 -4
  48. data/vendor/assets/src/medias/rubies/examples/time.rb +1 -1
  49. data/vendor/assets/src/medias/rubies/examples/web.rb +2 -2
  50. metadata +7 -5
  51. /data/vendor/assets/src/medias/rubies/examples/{matrix.rb → _matrix.rb} +0 -0
@@ -1,56 +1,99 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- new({ particle: :attached })
4
- new({ sanitizer: :attached }) do |params|
5
- params = [params] unless params.instance_of? Array
6
- params
3
+ new({ particle: :attach })
4
+ new({ sanitizer: :attach }) do |parents_ids|
5
+ parents_ids = parents_ids.value if parents_ids.instance_of? Atome
6
+ parents_ids = [parents_ids] unless parents_ids.instance_of?(Array)
7
+ parents_ids.each do |parents_id|
8
+ parents_id = parents_id.value if parents_id.instance_of? Atome
9
+ parents_found = grab(parents_id)
10
+ # TODO : factorise the code below
11
+ current_type = atome[:type]
12
+ parents_found.atome[current_type] = [] unless parents_found.atome[current_type]
13
+
14
+ # the condition below is needed when user passed a hash instead of the id of the child cf :
15
+ parent_type_container = if parents_found.atome[current_type].instance_of? Array
16
+ parents_found.atome[current_type]
17
+ else
18
+ [parents_found.atome[current_type][:id]]
19
+ end
20
+ # here we add the child into it's parents type container
21
+ parent_type_container << atome[:id]
22
+ # TODO : factorise the code above
23
+ parents_found.atome[:attached] = [] unless parents_found.atome[:attached]
24
+ parents_found.atome[:attached] << atome[:id]
25
+ end
26
+ # atome[:parents]=atome[:parents] | parents_ids
27
+ # atome[:parents].concat(parents_ids).uni
28
+ # puts "==> #{id} : #{self}"
29
+ # puts "====> id : #{id}, #{parents_ids} #{atome[:parents]}, #{atome[:parents].class} : #{atome[:parents].class}"
30
+ parents_ids
7
31
  end
8
- new({ pre: :attached }) do |children_ids|
32
+
33
+ new({ particle: :attached })
34
+ new({ sanitizer: :attached }) do |children_ids|
35
+ children_ids = children_ids.value if children_ids.instance_of? Atome
36
+ children_ids = [children_ids] unless children_ids.instance_of?(Array)
9
37
  children_ids.each do |child_id|
10
38
  child_id = child_id.value if child_id.instance_of? Atome
11
39
  child_found = grab(child_id)
12
40
  parents_found = @atome[:id]
13
- child_found.family(parents_found)
41
+ # TODO : factorise the code below
42
+ child_found_type = child_found.type.value
43
+ @atome[child_found_type] = [] unless @atome[child_found_type]
44
+
45
+ # the condition below is needed when user passed a hash instead of the id of the child cf :
46
+ # circle(color: {red: 0, green: 1}) instead of color({id: :the_col}); circle(color: [:the_col])
47
+ child_type_container = if @atome[child_found_type].instance_of? Array
48
+ @atome[child_found_type]
49
+ else
50
+ [@atome[child_found_type][:id]]
51
+ end
52
+ child_type_container << child_id
53
+ # TODO : factorise the code above
54
+
55
+ # child_found.family(parents_found)
14
56
  child_found.atome[:attach] = [parents_found]
15
57
  end
16
58
  end
17
- new({ particle: :type })
18
- new({ particle: :children })
19
59
 
20
- new ({ sanitizer: :children }) do |params|
21
- # TODO factorise the line below and 'sanitized_params' for all particle type of Array
22
- params = [params] unless params.instance_of? Array
23
- sanitized_params = []
24
- params.each do |child_id|
25
- child_id = child_id.value if child_id.instance_of? Atome
26
- sanitized_params << child_id
27
- child_found = grab(child_id)
28
- parents_found = @atome[:id]
29
- # FIXME : broadcast may malfunction because of the commented line below,
30
- # FIXME suite : if uncomment object hierarchy is broken (cf Vie Project)
31
- # FIXME : parent child problem may be caused by th eline below
32
- child_found.family(parents_found)
33
- child_found.atome[:parents] = [parents_found]
34
- end
35
- sanitized_params
36
- end
60
+ new({ particle: :detached, store: false })
37
61
 
38
- new({ particle: :parents })
39
- new({ sanitizer: :parents }) do |params|
40
- params = [params] unless params.instance_of? Array
41
- sanitized_params = []
42
- params.each do |parents_id|
43
- parents_id = parents_id.value if parents_id.instance_of? Atome
44
- sanitized_params << parents_id
45
- parents_found = grab(parents_id)
46
- family(parents_id)
47
- parents_found.atome[:children] << atome[:id]
62
+ new({ sanitizer: :detached }) do |values|
63
+ if values.instance_of? Array
64
+ values.each do |value|
65
+ detach_atome(value)
66
+ end
67
+ else
68
+ detach_atome(values)
69
+ # we sanitize the values so it always return an array to the renderer
70
+ values=[values]
48
71
  end
49
- sanitized_params
72
+ values
50
73
  end
51
74
 
52
- new({ particle: :family })
53
- new({ particle: :link })
75
+ new({ particle: :type })
76
+
77
+ # new({ particle: :parents })
78
+ # new({ sanitizer: :parents }) do |params|
79
+ # params = [params] unless params.instance_of? Array
80
+ # sanitized_params = []
81
+ # params.each do |parents_id|
82
+ # parents_id = parents_id.value if parents_id.instance_of? Atome
83
+ # sanitized_params << parents_id
84
+ # parents_found = grab(parents_id)
85
+ # # TODO : factorise the code below
86
+ # current_type = atome[:type]
87
+ # parents_found.atome[current_type] = [] unless parents_found.atome[current_type]
88
+ # parents_found.atome[current_type] << atome[:id]
89
+ # # TODO : factorise the code above
90
+ # # TODO : check if we can remove the family
91
+ # family(parents_id)
92
+ # end
93
+ # sanitized_params
94
+ # end
95
+
96
+ # new({ particle: :family })
54
97
  new({ particle: :id })
55
98
  new({ sanitizer: :id }) do |params|
56
99
  if @atome[:id] != params
@@ -62,19 +105,7 @@ new({ sanitizer: :id }) do |params|
62
105
  end
63
106
  new({ particle: :name })
64
107
  new({ particle: :active })
65
- new({ particle: :attach })
66
- new({ pre: :attach }) do |parents_ids|
67
- parents_ids.each do |parents_id|
68
- parents_id = parents_id.value if parents_id.instance_of? Atome
69
- parents_found = grab(parents_id)
70
- family(parents_id)
71
- parents_found.atome[:attached] = [] unless parents_found.atome[:attached]
72
- parents_found.atome[:attached] << atome[:id]
73
- end
74
- end
75
- new({ particle: :detached }) do |value|
76
- attached.value.delete(value)
77
- end
108
+
78
109
  new({ particle: :intricate, type: :array })
79
110
  new({ particle: :clones }) do |clones_found|
80
111
  clones_found.each_with_index do |clone_found, index|
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- new({ particle: :left }) do |_params, user_proc|
3
+ new({ particle: :left, type: :integer }) do |_params, user_proc|
4
4
  instance_exec(&user_proc) if user_proc.is_a?(Proc)
5
5
  end
6
- new({ particle: :right })
7
- new({ particle: :top })
8
- new({ particle: :bottom })
9
- new({ particle: :rotate })
10
- new({ particle: :direction })
11
- new({ particle: :center })
12
- new ({particle: :depth})
6
+ new({ particle: :right, type: :integer })
7
+ new({ particle: :top, type: :integer })
8
+ new({ particle: :bottom, type: :integer })
9
+ new({ particle: :rotate, type: :integer })
10
+ new({ particle: :direction, type: :string })
11
+ new({ particle: :center, type: :string})
12
+ new ({particle: :depth, type: :integer})
13
13
 
@@ -1,19 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
-
4
- new({particle: :renderers })
5
- new({particle: :code })
6
- new({particle: :run }) do |params|
3
+ new({ particle: :renderers })
4
+ new({ particle: :code })
5
+ new({ particle: :run }) do |params|
7
6
  code_found = @atome[:code]
8
7
  instance_exec(params, &code_found) if code_found.is_a?(Proc)
9
8
  end
10
- new({particle: :broadcast })
11
- new({particle: :data })
12
- new({particle: :additional })
13
- new({particle: :delete }) do |params|
9
+ new({ particle: :broadcast })
10
+ new({ particle: :data })
11
+ # new({particle: :additional })
12
+ new({ particle: :delete }) do |params|
14
13
  if params == true
15
- # the machine delete the current atome
14
+ # now we detach the atome from it's parent
15
+ parents_found = @atome[:attach]
16
+ parents_found.each do |parent_found|
17
+ grab(parent_found).detached(@atome[:id])
18
+ end
19
+
20
+ # the machine delete the current atome from the universe
16
21
  Universe.delete(@atome[:id])
22
+ elsif params == :materials
23
+ # this will delete any child with a visual type cf : images, shapes, videos, ...
24
+ materials.each do |atome_id_found|
25
+ grab(atome_id_found).delete(true)
26
+ end
17
27
  elsif params[:id]
18
28
  # the machine try to an atome by it's ID and delete it
19
29
  grab(params[:id]).delete(true)
@@ -28,9 +38,9 @@ new({particle: :delete }) do |params|
28
38
  send(params, 0)
29
39
  end
30
40
  end
31
- new({particle: :clear })
32
- new({particle: :path })
33
- new({particle: :schedule }) do |date, proc|
41
+ new({ particle: :clear })
42
+ new({ particle: :path })
43
+ new({ particle: :schedule }) do |date, proc|
34
44
  date = date.to_s
35
45
  delimiters = [',', ' ', ':', '-']
36
46
  format_date = date.split(Regexp.union(delimiters))
@@ -38,15 +48,14 @@ new({particle: :schedule }) do |date, proc|
38
48
  send("#{renderer}_schedule", format_date, &proc)
39
49
  end
40
50
  end
41
- new({particle: :read }) do |file, proc|
51
+ new({ particle: :read }) do |file, proc|
42
52
  Universe.renderer_list.each do |renderer|
43
53
  send("#{renderer}_reader", file, &proc)
44
54
  end
45
55
  end
46
- new({particle: :cursor })
47
- new({particle: :preset })
48
- new({particle: :relations,type: :hash })
49
-
56
+ new({ particle: :cursor })
57
+ new({ particle: :preset })
58
+ new({ particle: :relations, type: :hash })
50
59
 
51
60
  # generator = Genesis.generator
52
61
  #
@@ -21,7 +21,7 @@ class Atome
21
21
 
22
22
  # we add the new method to the particle's collection of methods
23
23
  Universe.add_to_particle_list(particle_name, type)
24
- # the line below create an empty particle method for each renderer, eg: browser_left, headless_left, ...
24
+ # the line below create an empty particle method for each renderer, eg: browser_left, headless_width, ...
25
25
  auto_render_generator(particle_name) if render
26
26
  new_particle(particle_name, store, render, &particle_proc)
27
27
  # the line below create all alternatives methods such as create 'method='
@@ -29,17 +29,20 @@ class Atome
29
29
  end
30
30
 
31
31
  def build_atome(atome_name, &atome_proc)
32
+ # TODO : atomes should tell the Universe if they're parts of materials category or else
32
33
  # we add the new method to the atome's collection of methods
33
34
  Universe.add_to_atome_list(atome_name)
34
35
  unless Essentials.default_params[atome_name]
35
36
  # if it doesn't exist
36
- # we create default params for the new created atome, adding the hash to : module essential , @default_params
37
- Essentials.new_default_params(atome_name => { type: atome_name, children: [], parents: [:view] })
37
+ # we create default params for the new created atome, adding the hash to : module essential, @default_params
38
+ Essentials.new_default_params(atome_name => { type: atome_name, attach: [:view] })
38
39
  end
39
40
 
40
- # the line below create an empty atome method for each renderer, eg: browser_left, headless_left, ...
41
+ # the line below create an empty atome method for each renderer, eg: browser_shape, headless_color, ...
41
42
  auto_render_generator(atome_name)
43
+ # create_atome(atome_name)
42
44
  new_atome(atome_name, &atome_proc)
45
+
43
46
  end
44
47
 
45
48
  def auto_render_generator(element)
@@ -26,13 +26,12 @@ puts "current user: #{Universe.current_user}"
26
26
  puts "current server: #{Universe.current_server}"
27
27
 
28
28
  Atome.new(
29
- { element: { renderers: [], id: :eDen, type: :element,
30
- parents: [], children: [] } }
29
+ { element: { renderers: [], id: :eDen, type: :element} }
31
30
  )
32
31
 
33
32
  Atome.new(
34
33
  { element: { renderers: [], id: :user_view, type: :element,
35
- parents: [:eDen], children: [] } }
34
+ attach: [:eDen] } }
36
35
  )
37
36
 
38
37
  # color creation
@@ -62,6 +61,7 @@ Atome.new(
62
61
  )
63
62
 
64
63
  Atome.new(
64
+
65
65
  { color: { renderers: default_render, id: :matrix_color, type: :color,
66
66
  left: 0, top: 0, red: 0.7, green: 0.7, blue: 0.7, alpha: 1, diffusion: :linear } }
67
67
  )
@@ -69,13 +69,13 @@ Atome.new(
69
69
  # system object creation
70
70
  # the black_matter is used to store un materialized atomes
71
71
  Atome.new(
72
- { shape: { renderers: default_render, id: :black_matter, type: :shape, parents: [:user_view], children: [],
72
+ { shape: { renderers: default_render, id: :black_matter, type: :shape, attach: [:user_view],
73
73
  left: 0, right: 0, top: 0, bottom: 0, width: 0, height: 0, overflow: :hidden
74
74
  } })
75
75
  # view port
76
76
  Atome.new(
77
- { shape: { renderers: default_render, id: :view, type: :shape, parents: [:user_view], children: [],
78
- attached: [:view_color], left: 0, right: 0, top: 0, bottom: 0, width: :auto, height: :auto, overflow: :auto
77
+ { shape: { renderers: default_render, id: :view, type: :shape, attach: [:user_view],
78
+ attached: :view_color, left: 0, right: 0, top: 0, bottom: 0, width: :auto, height: :auto, overflow: :auto,
79
79
  }
80
80
  }
81
81
  )
@@ -3,28 +3,32 @@
3
3
  # use to sanitize and secure user input
4
4
  module Essentials
5
5
  @default_params = {
6
+ # Warning : type must be define first
6
7
  render_engines: [:browser],
7
- collector: { type: :element, renderers: [], children: [], parents: [:black_matter] },
8
- animation: { type: :animation, children: [] , parents: [:black_matter]},
9
- element: { type: :element, renderers: [], children: [] , parents: [:black_matter]},
10
- matrix: { renderers: [], id: '', type: :shape, width: 99, height: 99,
11
- attached: [:matrix_color], children: [],
12
- left: 100, top: 100, clones: [], preset: :matrix, parents: [:view] },
13
- box: { renderers: [], id: '', type: :shape, width: 99, height: 99,
14
- attached: [:box_color], children: [], parents: [:view],
8
+ collector: { type: :element, attach: [:black_matter] },
9
+ image: { type: :image, attach: [:view] },
10
+ web: { type: :web, attach: [:view] },
11
+ video: { type: :video, attach: [:view] },
12
+ animation: { type: :animation, attach: [:black_matter] },
13
+ element: { type: :element, renderers: [], attach: [:black_matter] },
14
+ matrix: { type: :shape, width: 99, height: 99,
15
+ attached: :matrix_color,
16
+ left: 100, top: 100, clones: [], preset: :matrix, attach: [:view] },
17
+ box: { type: :shape, width: 99, height: 99,
18
+ attached: :box_color, attach: [:view],
15
19
  left: 100, top: 100, clones: [], preset: :box },
16
- circle: { renderers: [], id: '', type: :shape, width: 99, height: 99, smooth: '100%',
17
- attached: [:circle_color], children: [], parents: [:view],
20
+ circle: { type: :shape, width: 99, height: 99, smooth: '100%',
21
+ attached: :circle_color, attach: [:view],
18
22
  left: 100, top: 100, clones: [], preset: :circle },
19
- shape: { renderers: [], id: '', type: :shape, width: 99, height: 99,
20
- attached: [:shape_color], children: [], parents: [:view],
23
+ shape: { type: :shape, width: 99, height: 99,
24
+ attached: :shape_color, attach: [:view],
21
25
  left: 100, top: 100, clones: [] },
22
- text: { renderers: [], id: '', type: :text, visual: { size: 25 },
23
- attached: [:text_color], children: [], parents: [:view],
26
+ text: { type: :text, visual: { size: 25 },
27
+ attached: :text_color, attach: [:view],
24
28
  data: 'this is a text sample', width: 199, height: 33, clones: [] },
25
- drm: { type: :drm,parents: [:black_matter] },
26
- shadow: {parents: [:black_matter]},
27
- color: {parents: [:black_matter]}
29
+ drm: { type: :drm, attach: [:black_matter] },
30
+ shadow: { type: :shadow, attach: [:black_matter] },
31
+ color: { type: :color,attach: [:black_matter], red: 0, green: 0, blue: 0, alpha: 1 }
28
32
  }
29
33
 
30
34
  def self.default_params
@@ -32,7 +36,6 @@ module Essentials
32
36
  end
33
37
 
34
38
  def self.new_default_params(new_default)
35
- # puts "=====+====> #{new_default}, #{new_default.class}"
36
39
  @default_params.merge!(new_default)
37
40
  end
38
41
 
@@ -10,14 +10,14 @@ class Atome
10
10
  { red: split_data[0].to_f / 100, green: split_data[1].to_f / 100, blue: split_data[2].to_f / 100 }
11
11
  end
12
12
 
13
- def found_parents_and_renderers
14
- if @atome
15
- parent_found = [@atome[:id]]
16
- render_found = @atome[:renderers]
17
- else
18
- parent_found = []
19
- render_found = Essentials.default_params[:render_engines]
20
- end
21
- { parent: parent_found, renderers: render_found }
22
- end
13
+ # def found_parents_and_renderers
14
+ # if @atome
15
+ # parent_found = [@atome[:id]]
16
+ # render_found = @atome[:renderers]
17
+ # else
18
+ # parent_found = []
19
+ # render_found = Essentials.default_params[:render_engines]
20
+ # end
21
+ # { parent: parent_found, renderers: render_found }
22
+ # end
23
23
  end
@@ -6,7 +6,7 @@ class Atome
6
6
 
7
7
  def collapse
8
8
  @atome.each do |element, value|
9
- send(element, value) unless element == :type
9
+ send(element, value)
10
10
  end
11
11
  end
12
12
 
@@ -14,22 +14,21 @@ class Atome
14
14
  true
15
15
  end
16
16
 
17
- def sanitize(element, params,&user_proc)
17
+ def sanitize(element, params, &user_proc)
18
18
  bloc_found = Universe.get_sanitizer_method(element)
19
- params = instance_exec(params,user_proc, &bloc_found) if bloc_found.is_a?(Proc)
19
+ params = instance_exec(params, user_proc, &bloc_found) if bloc_found.is_a?(Proc)
20
20
  params
21
21
  end
22
22
 
23
-
24
23
  def history(property, value)
25
24
  "historize : #{property} #{value}"
26
25
  end
27
26
 
28
27
  def broadcasting(element)
29
- params=instance_variable_get("@#{element}")
28
+ params = instance_variable_get("@#{element}")
30
29
  @broadcast.each_value do |particle_monitored|
31
30
  if particle_monitored[:particles].include?(element)
32
- code_found=particle_monitored[:code]
31
+ code_found = particle_monitored[:code]
33
32
  instance_exec(self, element, params, &code_found) if code_found.is_a?(Proc)
34
33
  end
35
34
  end
@@ -37,14 +36,14 @@ class Atome
37
36
 
38
37
  public
39
38
 
40
- def monitor(params=nil, &proc_monitoring)
39
+ def monitor(params = nil, &proc_monitoring)
41
40
  if params
42
- monitoring=atome[:monitor] ||= {}
41
+ monitoring = atome[:monitor] ||= {}
43
42
  params[:atomes].each do |atome_id|
44
43
  target_broadcaster = grab(atome_id).instance_variable_get('@broadcast')
45
44
  monitor_id = params[:id] || "monitor#{target_broadcaster.length}"
46
- monitoring[monitor_id]=params.merge({code: proc_monitoring})
47
- target_broadcaster[monitor_id] = { particles: params[:particles], code: proc_monitoring }
45
+ monitoring[monitor_id] = params.merge({ code: proc_monitoring })
46
+ target_broadcaster[monitor_id] = { particles: params[:particles], code: proc_monitoring }
48
47
  end
49
48
  else
50
49
  atome[:monitor]
@@ -59,7 +58,6 @@ class Atome
59
58
  instance_variable_set("@#{element}_code", user_proc)
60
59
  end
61
60
 
62
-
63
61
  def particles(particles_found = nil)
64
62
  if particles_found
65
63
  particles_found.each do |particle_found, value_found|
@@ -75,7 +73,24 @@ class Atome
75
73
  real_atome[property] << value
76
74
  end
77
75
 
76
+ def add_to_integer(_atome_found, _particle_found, &_user_proc)
77
+ puts "there's no interest to add anything to an integer!"
78
+ end
79
+
80
+ def add_to_float(_atome_found, _particle_found, &_user_proc)
81
+ puts "there's no interest to add anything to an integer!"
82
+ end
83
+
84
+ def add_to_bignum(_atome_found, _particle_found, &_user_proc)
85
+ puts "there's no interest to add anything to an integer!"
86
+ end
87
+
88
+ def add_to_string(_atome_found, _particle_found, &_user_proc)
89
+ puts "there's no interest to add anything to an string!"
90
+ end
91
+
78
92
  def add_to_hash(particle, values, &user_proc)
93
+ @atome[:add][particle] = true
79
94
  # we update the holder of any new particle if user pass a bloc
80
95
  store_code_bloc(particle, &user_proc) if user_proc
81
96
  values.each do |value_id, value|
@@ -84,34 +99,51 @@ class Atome
84
99
  end
85
100
 
86
101
  def add_to_array(particle, value, &_user_proc)
102
+ @atome[:add][particle] = true
87
103
  # we update the holder of any new particle if user pass a bloc
88
104
  @atome[particle] << value
89
105
  end
90
106
 
91
- def add_to_atome(atome_found, particle_found, &user_proc)
92
- puts "we add : #{particle_found} to #{send(atome_found)} "
93
- send(atome_found,particle_found,:adder, &user_proc)
107
+ def add_to_atome(atome_type, particle_found, &user_proc)
108
+ # puts "-----> atome_type : #{atome_type}, particle_found : #{particle_found}"
109
+ # @atome[:add] = [] unless @atome[:add]
110
+ @atome[:add][atome_type] = particle_found
111
+ send(atome_type, particle_found, &user_proc)
94
112
  end
95
113
 
96
114
  def add(particles, &user_proc)
115
+
116
+ @atome[:add] = {} unless @atome[:add]
97
117
  particles.each do |particle, value|
98
118
  particle_type = Universe.particle_list[particle] || 'atome'
99
119
  send("add_to_#{particle_type}", particle, value, &user_proc)
120
+ # now we remove systematically the added hash so next particle won't be automatically added
121
+ @atome[:add].delete(particle)
100
122
  end
101
123
  end
102
124
 
125
+ def substract(_particles, &_user_proc)
126
+ # TODO : write code here to remove add elements"
127
+ puts "write code here to remove add elements"
128
+ # @atome[:add]=:poi
129
+ # particles.each do |particle, value|
130
+ # particle_type = Universe.particle_list[particle] || 'atome'
131
+ # puts "<<<<<< this the place to b ....>>>>>>#{particles} #{particle_type}"
132
+ # send("add_to_#{particle_type}", particle, value, &user_proc)
133
+ # end
134
+ end
135
+
103
136
  def refresh
104
137
  collapse
105
138
  end
106
139
 
107
140
  def collector(params = {}, &bloc)
108
141
  atome_type = :collector
109
- generated_render = params[:renderers] || []
110
- generated_id = params[:id] || identity_generator(atome_type)
111
-
112
- generated_parents = params[:parents] || [id.value]
113
- generated_children = params[:children] || []
114
- params = atome_common(atome_type, generated_id, generated_render, generated_parents, generated_children, params)
142
+ # generated_render = params[:renderers] || []
143
+ # generated_id = params[:id] || identity_generator(atome_type)
144
+ #
145
+ # generated_parents = params[:parents] || [id.value]
146
+ params = atome_common(atome_type, params)
115
147
  Batch.new({ atome_type => params }, &bloc)
116
148
  end
117
149
 
@@ -125,18 +157,16 @@ class Atome
125
157
  self.value.include?(value)
126
158
  end
127
159
 
128
-
129
-
130
- def each_with_index(*args)
131
- self.value.each_with_index do |val, index|
132
- yield(val, index)
133
- end
160
+ def each_with_index(*args, &block)
161
+ value.each_with_index(&block)
134
162
  end
135
163
 
136
164
  def [](range)
137
- if value[range].class == Atome
138
- return value[range]
139
- elsif value[range].class == Array
165
+ if instance_of?(Atome)
166
+ value[range]
167
+ # elsif value[range].instance_of?(Atome)
168
+ # return value[range]
169
+ elsif value[range].instance_of?(Array)
140
170
  collector_object = Object.collector({})
141
171
  collected_atomes = []
142
172
  value[range].each do |atome_found|
@@ -148,6 +178,7 @@ class Atome
148
178
  end
149
179
 
150
180
  end
181
+
151
182
  def []=(params, value)
152
183
  # TODO : it may miss some code, see above
153
184
  self.value[params] = value
@@ -169,4 +200,25 @@ class Atome
169
200
  end
170
201
  end
171
202
 
203
+ def materials
204
+ # TODO: the code below need a rewrite, we must find a new algorythm to avoid all those conditions
205
+ images_found = atome[:image] || []
206
+ videos_found = atome[:video] || []
207
+ shapes_found = atome[:shape] || []
208
+ web_found = atome[:web] || []
209
+ texts_found = atome[:text] || []
210
+ images_found.concat(videos_found).concat(shapes_found).concat(web_found).concat(texts_found)
211
+ end
212
+
213
+ def detach_atome(atome_id_to_detach)
214
+ atome_to_detach = grab(atome_id_to_detach)
215
+ # TODO: remove the condition below and find why it try to detach an atome that doesn't exist
216
+ if atome_to_detach
217
+ atome_type_found = atome_to_detach.atome[:type]
218
+ atome_id_found = atome_to_detach.atome[:id]
219
+ @atome[atome_type_found].delete(atome_id_found)
220
+ @atome[:attached].delete(atome_id_to_detach)
221
+ end
222
+ end
223
+
172
224
  end
@@ -19,7 +19,6 @@ class Batch
19
19
  def initialize(params)
20
20
  @id = params[:id] || identity_generator(:batch)
21
21
  Universe.add_to_atomes(@id, self)
22
- Universe.add_to_atomes(@id, self)
23
22
  end
24
23
 
25
24
  def dispatch (method, *args, &block)
@@ -54,7 +54,7 @@ class Universe
54
54
 
55
55
  def app_identity
56
56
  # each app hav its own identity, this allow to generate new user identities from th
57
- @app_identity = 3
57
+ @app_identity = 369
58
58
  # the identity is define as follow : parentsCreatorID_softwareInstanceID_objetID
59
59
  # in this case parents is eve so 0, Software instance number is main eVe server which is also 0,
60
60
  # and finally the object is 3 as this the third object created by the main server