atome 0.5.3.8.0 → 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.
- checksums.yaml +4 -4
- data/Rakefile +3 -3
- data/exe/atome +2 -3
- data/lib/atome/atome.rb +54 -35
- data/lib/atome/extensions/atome.rb +3 -2
- data/lib/atome/extensions/matrix.rb +27 -16
- data/lib/atome/genesis/generators/atome.rb +131 -88
- data/lib/atome/genesis/generators/identity.rb +82 -51
- data/lib/atome/genesis/generators/spatial.rb +8 -8
- data/lib/atome/genesis/generators/utility.rb +26 -17
- data/lib/atome/genesis/genesis.rb +11 -2
- data/lib/atome/genesis/sparkle.rb +6 -6
- data/lib/atome/helpers/essentials.rb +21 -17
- data/lib/atome/helpers/sanitizer.rb +10 -10
- data/lib/atome/helpers/utilities.rb +84 -28
- data/lib/atome/kernel/batch.rb +0 -1
- data/lib/atome/kernel/universe.rb +1 -1
- data/lib/atome/presets/atome.rb +22 -23
- data/lib/atome/renderers/browser/atome.rb +2 -1
- data/lib/atome/renderers/browser/helpers/browser_helper.rb +17 -0
- data/lib/atome/renderers/browser/helpers/text_helper.rb +10 -2
- data/lib/atome/renderers/browser/identity.rb +23 -5
- data/lib/atome/renderers/browser/utility.rb +5 -4
- data/lib/atome/renderers/renderer.rb +1 -0
- data/lib/atome/version.rb +1 -1
- data/sig/atome.rbs +20 -0
- data/sig/essentials.rbs +11 -0
- data/vendor/assets/src/medias/images/icons/email.svg +12 -12
- data/vendor/assets/src/medias/rubies/examples/!run.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/add.rb +2 -3
- data/vendor/assets/src/medias/rubies/examples/animation.rb +2 -2
- data/vendor/assets/src/medias/rubies/examples/atome_new.rb +18 -6
- data/vendor/assets/src/medias/rubies/examples/{parents.rb → attach.rb} +6 -6
- data/vendor/assets/src/medias/rubies/examples/attached.rb +4 -4
- data/vendor/assets/src/medias/rubies/examples/box.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/code.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/color.rb +20 -4
- data/vendor/assets/src/medias/rubies/examples/delete.rb +2 -2
- data/vendor/assets/src/medias/rubies/examples/drag.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/fullscreen.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/image.rb +2 -2
- data/vendor/assets/src/medias/rubies/examples/link.rb +7 -5
- data/vendor/assets/src/medias/rubies/examples/markers.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/materials.rb +15 -0
- data/vendor/assets/src/medias/rubies/examples/monitoring.rb +44 -18
- data/vendor/assets/src/medias/rubies/examples/read.rb +2 -2
- data/vendor/assets/src/medias/rubies/examples/shadow.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/table.rb +2 -2
- data/vendor/assets/src/medias/rubies/examples/text.rb +4 -4
- data/vendor/assets/src/medias/rubies/examples/time.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/web.rb +2 -2
- metadata +7 -5
- /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: :
|
4
|
-
new({ sanitizer: :
|
5
|
-
|
6
|
-
|
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
|
-
|
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
|
-
|
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
|
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({
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
72
|
+
values
|
50
73
|
end
|
51
74
|
|
52
|
-
new({ particle: :
|
53
|
-
|
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
|
-
|
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: :
|
5
|
-
new({particle: :
|
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
|
-
#
|
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,
|
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,11 +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]
|
36
|
+
# if it doesn't exist
|
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] })
|
39
|
+
end
|
40
|
+
|
41
|
+
# the line below create an empty atome method for each renderer, eg: browser_shape, headless_color, ...
|
35
42
|
auto_render_generator(atome_name)
|
43
|
+
# create_atome(atome_name)
|
36
44
|
new_atome(atome_name, &atome_proc)
|
45
|
+
|
37
46
|
end
|
38
47
|
|
39
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
|
-
|
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,
|
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,
|
78
|
-
attached:
|
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,
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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: {
|
17
|
-
attached:
|
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: {
|
20
|
-
attached:
|
23
|
+
shape: { type: :shape, width: 99, height: 99,
|
24
|
+
attached: :shape_color, attach: [:view],
|
21
25
|
left: 100, top: 100, clones: [] },
|
22
|
-
text: {
|
23
|
-
attached:
|
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 },
|
26
|
-
shadow: {},
|
27
|
-
color: {}
|
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
|
@@ -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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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,8 +6,7 @@ class Atome
|
|
6
6
|
|
7
7
|
def collapse
|
8
8
|
@atome.each do |element, value|
|
9
|
-
|
10
|
-
send(element, value) unless element == :type
|
9
|
+
send(element, value)
|
11
10
|
end
|
12
11
|
end
|
13
12
|
|
@@ -15,22 +14,21 @@ class Atome
|
|
15
14
|
true
|
16
15
|
end
|
17
16
|
|
18
|
-
def sanitize(element, params
|
17
|
+
def sanitize(element, params, &user_proc)
|
19
18
|
bloc_found = Universe.get_sanitizer_method(element)
|
20
|
-
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)
|
21
20
|
params
|
22
21
|
end
|
23
22
|
|
24
|
-
|
25
23
|
def history(property, value)
|
26
24
|
"historize : #{property} #{value}"
|
27
25
|
end
|
28
26
|
|
29
27
|
def broadcasting(element)
|
30
|
-
params=instance_variable_get("@#{element}")
|
28
|
+
params = instance_variable_get("@#{element}")
|
31
29
|
@broadcast.each_value do |particle_monitored|
|
32
30
|
if particle_monitored[:particles].include?(element)
|
33
|
-
code_found=particle_monitored[:code]
|
31
|
+
code_found = particle_monitored[:code]
|
34
32
|
instance_exec(self, element, params, &code_found) if code_found.is_a?(Proc)
|
35
33
|
end
|
36
34
|
end
|
@@ -38,14 +36,14 @@ class Atome
|
|
38
36
|
|
39
37
|
public
|
40
38
|
|
41
|
-
def monitor(params=nil, &proc_monitoring)
|
39
|
+
def monitor(params = nil, &proc_monitoring)
|
42
40
|
if params
|
43
|
-
monitoring=atome[:monitor] ||= {}
|
41
|
+
monitoring = atome[:monitor] ||= {}
|
44
42
|
params[:atomes].each do |atome_id|
|
45
43
|
target_broadcaster = grab(atome_id).instance_variable_get('@broadcast')
|
46
44
|
monitor_id = params[:id] || "monitor#{target_broadcaster.length}"
|
47
|
-
monitoring[monitor_id]=params.merge({code: proc_monitoring})
|
48
|
-
target_broadcaster[monitor_id] = { particles: params[:particles], code:
|
45
|
+
monitoring[monitor_id] = params.merge({ code: proc_monitoring })
|
46
|
+
target_broadcaster[monitor_id] = { particles: params[:particles], code: proc_monitoring }
|
49
47
|
end
|
50
48
|
else
|
51
49
|
atome[:monitor]
|
@@ -60,7 +58,6 @@ class Atome
|
|
60
58
|
instance_variable_set("@#{element}_code", user_proc)
|
61
59
|
end
|
62
60
|
|
63
|
-
|
64
61
|
def particles(particles_found = nil)
|
65
62
|
if particles_found
|
66
63
|
particles_found.each do |particle_found, value_found|
|
@@ -76,7 +73,24 @@ class Atome
|
|
76
73
|
real_atome[property] << value
|
77
74
|
end
|
78
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
|
+
|
79
92
|
def add_to_hash(particle, values, &user_proc)
|
93
|
+
@atome[:add][particle] = true
|
80
94
|
# we update the holder of any new particle if user pass a bloc
|
81
95
|
store_code_bloc(particle, &user_proc) if user_proc
|
82
96
|
values.each do |value_id, value|
|
@@ -85,29 +99,51 @@ class Atome
|
|
85
99
|
end
|
86
100
|
|
87
101
|
def add_to_array(particle, value, &_user_proc)
|
102
|
+
@atome[:add][particle] = true
|
88
103
|
# we update the holder of any new particle if user pass a bloc
|
89
104
|
@atome[particle] << value
|
90
105
|
end
|
91
106
|
|
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)
|
112
|
+
end
|
113
|
+
|
92
114
|
def add(particles, &user_proc)
|
115
|
+
|
116
|
+
@atome[:add] = {} unless @atome[:add]
|
93
117
|
particles.each do |particle, value|
|
94
|
-
particle_type = Universe.particle_list[particle]
|
118
|
+
particle_type = Universe.particle_list[particle] || 'atome'
|
95
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)
|
96
122
|
end
|
97
123
|
end
|
98
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
|
+
|
99
136
|
def refresh
|
100
137
|
collapse
|
101
138
|
end
|
102
139
|
|
103
140
|
def collector(params = {}, &bloc)
|
104
141
|
atome_type = :collector
|
105
|
-
generated_render = params[:renderers] || []
|
106
|
-
generated_id = params[:id] || identity_generator(atome_type)
|
107
|
-
|
108
|
-
generated_parents = params[:parents] || [id.value]
|
109
|
-
|
110
|
-
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)
|
111
147
|
Batch.new({ atome_type => params }, &bloc)
|
112
148
|
end
|
113
149
|
|
@@ -121,18 +157,16 @@ class Atome
|
|
121
157
|
self.value.include?(value)
|
122
158
|
end
|
123
159
|
|
124
|
-
|
125
|
-
|
126
|
-
def each_with_index(*args)
|
127
|
-
self.value.each_with_index do |val, index|
|
128
|
-
yield(val, index)
|
129
|
-
end
|
160
|
+
def each_with_index(*args, &block)
|
161
|
+
value.each_with_index(&block)
|
130
162
|
end
|
131
163
|
|
132
164
|
def [](range)
|
133
|
-
if
|
134
|
-
|
135
|
-
|
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)
|
136
170
|
collector_object = Object.collector({})
|
137
171
|
collected_atomes = []
|
138
172
|
value[range].each do |atome_found|
|
@@ -144,6 +178,7 @@ class Atome
|
|
144
178
|
end
|
145
179
|
|
146
180
|
end
|
181
|
+
|
147
182
|
def []=(params, value)
|
148
183
|
# TODO : it may miss some code, see above
|
149
184
|
self.value[params] = value
|
@@ -165,4 +200,25 @@ class Atome
|
|
165
200
|
end
|
166
201
|
end
|
167
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
|
+
|
168
224
|
end
|
data/lib/atome/kernel/batch.rb
CHANGED
@@ -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 =
|
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
|