atome 0.5.6.2.3 → 0.5.6.2.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02c478a58bfcce998a040779efdc8970c38a1d5286f8ca942231132493707f7d
4
- data.tar.gz: 930ebabe49f5824c66e03b3b1b8b53e1def6ad0ce26ff40f2110c07461970f8b
3
+ metadata.gz: 217af8e71c3443f96a514acb39e6b8aaf0b45ebdfe993ebe3dcf521bf4b0e2da
4
+ data.tar.gz: 3a3cd6668641eadc8261232a3eac694ff7ccdeeb8dc0cf176e930ca28f9c8114
5
5
  SHA512:
6
- metadata.gz: 9161e9c2364dd6eb8e85d44d93872ea43f52e241a19aac7f1f4697890b1d638faa0891a94e85d917a2f8e4e75e5e322170e1bbfab1223ea0d26c1ee32ee33797
7
- data.tar.gz: 2136de3b80e45cff68ad2c0345baf11d2565473f591c27261c6f2942414ca5d4442338597ee4d29936bb306e707846da991337cd915535a2dce705fd6dc1756a
6
+ metadata.gz: d20a7b73008b1af5d162ee08874de58af73e0c2d7e0fc4356f248997564d144e44207807a5ac03a240a72f58f57ba1fbbf6efda606aa2e1d5e43d441f11aa949
7
+ data.tar.gz: 5fff6175f1f55315119d56eba445a7b39b75954afcfa03cf5749da48d25fec6ad5fd85577c5a92bde5addc5da966cb78c4d06be7cf93d7627efffeb3ecc5ac96
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
+ module ObjectExtension
2
3
 
3
- # atome extensions
4
- class Object
5
4
  def new(params, &bloc)
6
5
  # Genesis = Genesis.Genesis
7
6
  if params.key?(:atome)
@@ -42,15 +41,69 @@ class Object
42
41
  end
43
42
  render_method = "#{renderer_found}_#{params[:specific]}#{params[:method]}"
44
43
  Genesis.build_render(render_method, &bloc)
45
- # elsif params.key?(:callback)
46
- # particle_targetted = params[:callback]
47
- # Atome.define_method("#{particle_targetted}_callback", option) do
48
- # alert option
49
- # bloc.call(option)
50
- # end
44
+ # elsif params.key?(:callback)
45
+ # particle_targetted = params[:callback]
46
+ # Atome.define_method("#{particle_targetted}_callback", option) do
47
+ # alert option
48
+ # bloc.call(option)
49
+ # end
51
50
  end
51
+ super if defined?(super)
52
52
  end
53
53
 
54
+ end
55
+ # atome extensions
56
+ class Object
57
+ include ObjectExtension
58
+ # def new(params, &bloc)
59
+ # # Genesis = Genesis.Genesis
60
+ # if params.key?(:atome)
61
+ # if Universe.atome_list.include?(params[:atome])
62
+ # puts "atome #{params[:atome]} already exist you can't create it"
63
+ # else
64
+ # Universe.add_atomes_specificities params[:atome]
65
+ # Genesis.build_atome(params[:atome], &bloc)
66
+ # end
67
+ # elsif params.key?(:particle)
68
+ # if Universe.particle_list[params[:particle]]
69
+ # puts "particle #{params[:particle]} already exist you can't create it"
70
+ # else
71
+ # Atome.instance_variable_set("@main_#{params[:particle]}", bloc)
72
+ # # render indicate if the particle needs to be rendered
73
+ # # store tell the system if it need to store the particle value
74
+ # # type help the system what type of type the particle will receive and store
75
+ # Genesis.build_particle(params[:particle], { render: params[:render], return: params[:return],
76
+ # store: params[:store], type: params[:type],
77
+ # category: params[:category] }, &bloc)
78
+ # end
79
+ #
80
+ # elsif params.key?(:sanitizer)
81
+ # Genesis.build_sanitizer(params[:sanitizer], &bloc)
82
+ # elsif params.key?(:pre)
83
+ # Atome.instance_variable_set("@pre_#{params[:pre]}", bloc)
84
+ # elsif params.key?(:post)
85
+ # Atome.instance_variable_set("@post_#{params[:post]}", bloc)
86
+ # elsif params.key?(:after)
87
+ # Atome.instance_variable_set("@after_#{params[:after]}", bloc)
88
+ # elsif params.key?(:read)
89
+ # Atome.instance_variable_set("@read_#{params[:read]}", bloc)
90
+ # elsif params[:renderer]
91
+ # renderer_found = params[:renderer]
92
+ # if params[:specific]
93
+ # Universe.set_atomes_specificities(params)
94
+ # params[:specific] = "#{params[:specific]}_"
95
+ # end
96
+ # render_method = "#{renderer_found}_#{params[:specific]}#{params[:method]}"
97
+ # Genesis.build_render(render_method, &bloc)
98
+ # # elsif params.key?(:callback)
99
+ # # particle_targetted = params[:callback]
100
+ # # Atome.define_method("#{particle_targetted}_callback", option) do
101
+ # # alert option
102
+ # # bloc.call(option)
103
+ # # end
104
+ # end
105
+ # end
106
+
54
107
  def reorder_particles(hash_to_reorder)
55
108
  # we reorder the hash
56
109
  ordered_keys = %i[renderers id alien type attach int8 unit]
@@ -8,8 +8,8 @@ end
8
8
 
9
9
  new({ particle: :message, category: :communication, type: :hash }) do |params, bloc|
10
10
  params = { data: params } unless params.instance_of? Hash
11
- params[:user] = 'dfghg4df5gdfgh654'
12
- params[:pass] = 'gfhkzrhgzr4h98948'
11
+ # params[:user] = 'dfghg4df5gdfgh654'
12
+ # params[:pass] = 'gfhkzrhgzr4h98948'
13
13
  # instance_variable_set('@message_code', {}) unless instance_variable_get('@message_code')
14
14
  # store_proc= instance_variable_get('@message_code')
15
15
  message_id= "msg_#{Universe.messages.length}"
@@ -61,4 +61,6 @@ new(particle: :selected, category: :identity, type: :boolean) do |params|
61
61
  end
62
62
 
63
63
  new({ particle: :format, category: :identity, type: :string })
64
- new({ particle: :alien, category: :identity, type: :string }) #special particel that old alien object
64
+ new({ particle: :alien, category: :identity, type: :string }) #special particel that old alien object
65
+
66
+ new({ particle: :email, category: :identity, type: :string })
@@ -115,7 +115,14 @@ new({ particle: :web, category: :utility, type: :string })
115
115
  # new({ particle: :metrics, type: :hash })
116
116
  # do not change the line below initialise is a special method
117
117
  new({ initialize: :unit, value: {} })
118
-
118
+ new({ particle: :unit, store: false, type: :string, category: :utility }) do |params|
119
+ params.each do |k, v|
120
+ @unit[k] = v
121
+ # now we refresh the particle
122
+ send(k, send(k))
123
+ end
124
+ @unit
125
+ end
119
126
  new({ particle: :login, category: :utility, type: :string }) do |params|
120
127
  set_current_user(id) if params
121
128
  end
@@ -124,7 +131,7 @@ new({ particle: :hyperedit, category: :utility, type: :string })
124
131
  new({ particle: :terminal, category: :utility, type: :string })
125
132
  new({ particle: :read, category: :utility, type: :string })
126
133
  new({ particle: :browse, category: :utility, type: :string })
127
- new({ particle: :copies, category: :utility, type: :string})
134
+ new({ particle: :copies, category: :utility, type: :string })
128
135
  new({ particle: :temporary, category: :utility, type: :int })
129
136
  new({ particle: :atomes, category: :utility, type: :string })
130
137
 
@@ -147,15 +147,33 @@ def atome_genesis
147
147
  end
148
148
 
149
149
  def init_database # this method is call from JS (atome/communication)
150
+ # we init the db file eDen
151
+ A.message({ action: :init_db, data: { database: :eDen } }) do |db_state|
152
+ puts db_state
153
+ end
150
154
 
151
155
  particles = Universe.particle_list
152
156
  categories = Universe.categories
153
- atomes = Universe.atomes
154
- puts "we are here!!"
155
- # particles.each do |particle, value|
156
- # value[:category] = :undefined if value[:category].nil?
157
- # A.message({ action: :init_db, particle: particle, type: value[:type], category: value[:category] })
158
- # end
157
+ categories.each do |category|
158
+ A.message({ action: :crate_db_table, data: { table: category } }) do |db_state|
159
+ puts db_state
160
+ end
161
+ end
162
+ particles_length=particles.length
163
+ particles.each_with_index do |(particle, infos), index|
164
+ type = infos[:type]
165
+ table = infos[:category]
166
+ @i=1
167
+ A.message({ action: :create_db_column, data: { table: table, column: particle, type: type } }) do |db_state|
168
+ @i+=1
169
+ if @i==particles_length
170
+ user_login
171
+ end
172
+ puts db_state
173
+ end
174
+
175
+ end
176
+
159
177
  end
160
178
 
161
179
  def user_login
@@ -164,7 +182,7 @@ def user_login
164
182
  message({ action: :authentication, data: { email: 'jeezs@atome.one' } }) do |email|
165
183
  puts "email received : #{email}"
166
184
  end
167
- message({ action: :authorization, data: { password: password } }) do |p|
168
- puts "2 : #{p}"
185
+ message({ action: :authorization, data: { password: password } }) do |pass|
186
+ puts "password recieved : #{pass}"
169
187
  end
170
188
  end
data/lib/atome/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  # return atome version
4
4
  class Atome
5
- VERSION = '0.5.6.2.3'
5
+ VERSION = '0.5.6.2.5'
6
6
  end
7
7
 
data/lib/atome.rb CHANGED
@@ -33,5 +33,5 @@ require 'renderers/html/index'
33
33
  require 'renderers/headless/index'
34
34
  require 'renderers/server/index'
35
35
  require 'atome/helpers/sanitizer'
36
- require 'eVe/eVe'
37
36
  require 'atome/genesis/sparkle'
37
+ require 'eVe/eVe'
@@ -32,5 +32,6 @@ require_relative './renderers/html/index_relative'
32
32
  require_relative './renderers/headless/index_relative'
33
33
  require_relative './renderers/server/index_relative'
34
34
  require_relative './atome/helpers/sanitizer'
35
- require_relative './eVe/eVe_relative'
36
35
  require_relative './atome/genesis/sparkle'
36
+ require_relative './eVe/eVe_relative'
37
+
data/lib/eVe/eVe.rb CHANGED
@@ -1 +1,3 @@
1
- puts "eVe ready!!"
1
+ # frozen_string_literal: true
2
+
3
+ require 'eVe/lib/init'
@@ -1 +1,3 @@
1
- puts "eve initialised"
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './lib/init'
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EveExtension
4
+ def new(params, &bloc)
5
+ if params[:page]
6
+ alert "alert salut"
7
+ elsif params[:application]
8
+ box({ left: 0, right: 0, width: :auto, top: 0, bottom: 0, height: :auto, id: :toto })
9
+ elsif params[:master]
10
+
11
+ end
12
+ super if defined?(super)
13
+ end
14
+ end
15
+
16
+ class Object
17
+ include EveExtension # Ajoutez d'abord les extensions de base
18
+ end
19
+
20
+ puts 'eVe ready'
@@ -51,11 +51,3 @@ new({ method: :sort, renderer: :html, type: :hash }) do |params|
51
51
  html.refresh_table(params)
52
52
  end
53
53
 
54
- new({ particle: :unit, store: false }) do |params|
55
- params.each do |k, v|
56
- @unit[k] = v
57
- # now we refresh the particle
58
- send(k, send(k))
59
- end
60
- @unit
61
- end
@@ -1,39 +1,39 @@
1
- # frozen_string_literal: true
2
-
3
- A.message({ action: :insert, data: { table: :security, particle: :password, data: 'my_pass'} }) do |datas|
4
- puts "0 data received: #{datas}"
5
- end
6
-
7
- A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs' } }) do |data_received_from_server|
8
- puts "1 my first insert #{data_received_from_server}"
9
- end
10
-
11
- A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs2' } })
12
-
13
- A.message({ action: :query, data: { table: :identity } }) do |data_received_from_server|
14
- puts "2 another insert : #{data_received_from_server}"
15
- end
16
-
17
- A.message({ action: :query, data: { table: :identity } }) do |data_received|
18
- puts "3 received : #{data_received}"
19
- end
20
-
21
- A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs3' } }) do |result|
22
- puts "4 insert done : #{result}"
23
- end
24
-
25
- A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs4' } }) do |result|
26
- puts "5 last message received: #{result}"
27
- end
28
-
29
- A.message({ action: :insert, data: { table: :security, particle: :name, data: 'john doe' } }) do |data_received_from_server|
30
- puts "6 test 1 : #{data_received_from_server}"
31
- end
32
-
33
- A.message({ action: :insert, data: { table: :identity, particle: :tit, data: 'dummy' } }) do |data_received_from_server|
34
- puts "7 test 2 : #{data_received_from_server}"
35
- end
36
-
37
- A.message({ action: :insert, data: { table: :unknown, particle: :name, data: 'dummy2' } }) do |data_received_from_server|
38
- puts "test 3 : #{data_received_from_server}"
39
- end
1
+ # # frozen_string_literal: true
2
+ #
3
+ # A.message({ action: :insert, data: { table: :security, particle: :password, data: 'my_pass'} }) do |datas|
4
+ # puts "0 data received: #{datas}"
5
+ # end
6
+ #
7
+ # A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs' } }) do |data_received_from_server|
8
+ # puts "1 my first insert #{data_received_from_server}"
9
+ # end
10
+ #
11
+ # A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs2' } })
12
+ #
13
+ # A.message({ action: :query, data: { table: :identity } }) do |data_received_from_server|
14
+ # puts "2 another insert : #{data_received_from_server}"
15
+ # end
16
+ #
17
+ # A.message({ action: :query, data: { table: :identity } }) do |data_received|
18
+ # puts "3 received : #{data_received}"
19
+ # end
20
+ #
21
+ # A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs3' } }) do |result|
22
+ # puts "4 insert done : #{result}"
23
+ # end
24
+ #
25
+ # A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs4' } }) do |result|
26
+ # puts "5 last message received: #{result}"
27
+ # end
28
+ #
29
+ # A.message({ action: :insert, data: { table: :security, particle: :name, data: 'john doe' } }) do |data_received_from_server|
30
+ # puts "6 test 1 : #{data_received_from_server}"
31
+ # end
32
+ #
33
+ # A.message({ action: :insert, data: { table: :identity, particle: :tit, data: 'dummy' } }) do |data_received_from_server|
34
+ # puts "7 test 2 : #{data_received_from_server}"
35
+ # end
36
+ #
37
+ # A.message({ action: :insert, data: { table: :unknown, particle: :name, data: 'dummy2' } }) do |data_received_from_server|
38
+ # puts "test 3 : #{data_received_from_server}"
39
+ # end
@@ -26,43 +26,43 @@ class String
26
26
  end
27
27
  end
28
28
 
29
- class Database
30
- def self.connect_database
31
- if File.exist?("eden.sqlite3")
32
- eden = Sequel.connect("sqlite://eden.sqlite3")
33
- else
34
- eden = Sequel.connect("sqlite://eden.sqlite3")
35
- eden.create_table :atome do
36
- primary_key :atome_id
37
- String :aui
38
- String :id
39
- String :type
40
- String :name
41
- String :content
42
- String :position
43
- String :dimension
44
- String :color
45
- String :right
46
- String :effect
47
- String :shadow
48
- String :border
49
- String :fill
50
- Float :x
51
- Float :xx
52
- Float :y
53
- Float :yy
54
- Float :z
55
- Float :zz
56
- Float :width
57
- Float :height
58
- Float :depth
59
- end
60
-
61
- end
62
- eden
63
- end
64
-
65
- end
29
+ # class Database
30
+ # def self.connect_database
31
+ # if File.exist?("eden.sqlite3")
32
+ # eden = Sequel.connect("sqlite://eden.sqlite3")
33
+ # else
34
+ # eden = Sequel.connect("sqlite://eden.sqlite3")
35
+ # eden.create_table :atome do
36
+ # primary_key :atome_id
37
+ # String :aui
38
+ # String :id
39
+ # String :type
40
+ # String :name
41
+ # String :content
42
+ # String :position
43
+ # String :dimension
44
+ # String :color
45
+ # String :right
46
+ # String :effect
47
+ # String :shadow
48
+ # String :border
49
+ # String :fill
50
+ # Float :x
51
+ # Float :xx
52
+ # Float :y
53
+ # Float :yy
54
+ # Float :z
55
+ # Float :zz
56
+ # Float :width
57
+ # Float :height
58
+ # Float :depth
59
+ # end
60
+ #
61
+ # end
62
+ # eden
63
+ # end
64
+ #
65
+ # end
66
66
 
67
67
  class App < Roda
68
68
  # comment below when test will be done
@@ -1,217 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # database handling for eDen Db
4
-
5
4
  class Database
5
+ class << self
6
+ Sequel.extension :migration
6
7
 
7
- def self.table_exists?(table_name)
8
- eden = Sequel.connect("sqlite://eden.sqlite3")
9
- if eden.table_exists?(table_name)
10
- puts "La table #{table_name} existe dans la base de données."
11
- else
12
- puts "La table suivante : #{table_name} n'existe pas dans la base de données."
8
+ def db_access
9
+ Sequel.connect("sqlite://eden.sqlite3")
13
10
  end
14
11
 
15
- end
16
-
17
- # def self.create_table(table_name)
18
- def self.connect_database
19
- if File.exist?("eden.sqlite3")
12
+ def create_table(table_name)
20
13
  eden = Sequel.connect("sqlite://eden.sqlite3")
21
- # now we test if the table exist
22
- table_exists?(:table_name)
23
- else
24
- eden = Sequel.connect("sqlite://eden.sqlite3")
25
- eden.create_table :atome do
26
- primary_key :atome_id
27
- String :creator
28
- end
29
-
30
- eden.create_table :communication do
31
- primary_key :communication_id
32
- String :connection
33
- JSON :data
34
- JSON :controller
35
- end
36
-
37
- ###################
38
-
39
- Sequel.extension :migration
40
-
41
- Sequel.migration do
42
- change do
43
- add_column :communication, :jesaispas, String
14
+ unless eden.table_exists?(table_name)
15
+ eden.create_table table_name.to_sym do
16
+ primary_key "#{table_name}_id".to_sym
44
17
  end
45
- end.apply(eden, :up)
46
-
47
- ###################
48
-
49
- eden.create_table :effect do
50
- primary_key :effect_id
51
- Int :smooth
52
- Int :blur
53
- end
54
-
55
- eden.create_table :event do
56
- primary_key :event_id
57
- JSON :touch
58
- Boolean :play
59
- Boolean :pause
60
- Int :time
61
- Boolean :on
62
- Boolean :fullscreen
63
- Boolean :mute
64
- Boolean :drag
65
- Boolean :drop
66
- Boolean :over
67
- String :targets
68
- Boolean :start
69
- Boolean :stop
70
- Time :begin
71
- Time :end
72
- Int :duration
73
- Int :mass
74
- Int :damping
75
- Int :stiffness
76
- Int :velocity
77
- Boolean :repeat
78
- Boolean :ease
79
- Boolean :keyboard
80
- Boolean :resize
81
- Boolean :overflow
82
- end
83
-
84
- eden.create_table :geometry do
85
- primary_key :geometry_id
86
- Int :width
87
- Int :height
88
- Int :size
89
- end
90
-
91
- eden.create_table :hierarchy do
92
- primary_key :hierarchy_id
93
- String :attach
94
- String :attached
95
- String :apply
96
- String :affect
97
- String :detached
98
- String :collect
99
- end
100
-
101
- eden.create_table :identity do
102
- primary_key :identity_id
103
- String :real
104
- String :type
105
- Int :id
106
- String :name
107
- String :firstname
108
- String :email
109
- String :nickname
110
- Boolean :active
111
- String :markup
112
- String :bundle
113
- String :data
114
- String :category
115
- String :selection
116
- Boolean :selected
117
- String :format
118
- String :alien
119
- end
120
-
121
- eden.create_table :material do
122
- primary_key :material_id
123
- String :component
124
- Boolean :edit
125
- String :style
126
- Boolean :hide
127
- Boolean :remove
128
- JSON :classes
129
- Boolean :remove_classes
130
- Int :opacity
131
- String :definition
132
- Int :gradient
133
- Int :border
134
- end
135
-
136
- eden.create_table :property do
137
- primary_key :property_id
138
- String :red
139
- String :green
140
- String :blue
141
- String :alpha
142
- String :diffusion
143
- Boolean :clean
144
- String :insert
145
- Boolean :remove
146
- Int :sort
147
- end
148
-
149
- eden.create_table :security do
150
- primary_key :security_id
151
- String :password
152
- end
153
-
154
- eden.create_table :spatial do
155
- primary_key :spatial_id
156
- Int :left
157
- Int :right
158
- Int :top
159
- Int :bottom
160
- Int :rotate
161
- String :direction
162
- String :center
163
- Int :depth
164
- Int :position
165
- String :organise
166
- String :spacing
167
- Boolean :display
168
- String :layout
169
- end
170
-
171
- eden.create_table :time do
172
- primary_key :time_id
173
- JSON :markers
174
18
  end
19
+ end
175
20
 
176
- eden.create_table :utility do
177
- primary_key :utility_id
178
- String :renderers
179
- String :code
180
- Boolean :run
181
- Boolean :delete
182
- Boolean :clear
183
- String :path
184
- String :schedule
185
- String :read
186
- String :cursor
187
- String :preset
188
- JSON :relations
189
- JSON :tag
190
- String :web
191
- JSON :unit
192
- String :initialize
193
- String :login
194
- String :hypertext
195
- String :hyperedit
196
- String :terminal
197
- String :browse
198
- String :copies
199
- Int :temporary
200
- String :atomes
201
- String :match
202
- Boolean :invert
203
- String :option
204
- String :duplicate
205
- String :copy
206
- String :paste
207
- String :backup
208
- String :import
209
- String :compute
210
- String :get
21
+ def create_column(table, column_name, type)
22
+ eden = Sequel.connect("sqlite://eden.sqlite3")
23
+ if eden.table_exists?(table)
24
+ unless eden.schema(table).any? { |column| column.first == column_name }
25
+ Sequel.migration do
26
+ change do
27
+ add_column table, column_name, type
28
+ end
29
+ end.apply(eden, :up)
30
+ end
211
31
  end
212
-
213
32
  end
214
- eden
215
33
  end
216
34
 
217
35
  end
@@ -3,63 +3,110 @@
3
3
  # server utils to handle eDen Db
4
4
 
5
5
  class EDen
6
+ class << self
7
+ def db_access
8
+ Database.db_access
9
+ end
6
10
 
7
- def self.db_access
8
- Database.connect_database
9
- end
11
+ def terminal(data, message_id)
12
+ { data: { message: `#{data}` }, message_id: message_id }
13
+ end
10
14
 
11
- def self.terminal(data, message_id)
12
- { data: { message: `#{data}` }, message_id: message_id }
13
- end
15
+ def authorization(data, message_id)
16
+ db = db_access
17
+ security_items = db[:security]
18
+ user_password = data["password"]
19
+ user_exists = security_items.where(password: user_password).first
14
20
 
15
- def self.authorization(_data, message_id)
16
- { data: { message: 'password received'}, message_id: message_id }
17
- end
21
+ if !user_exists
22
+ { return: 'Password not found', message_id: message_id }
23
+ # Ask to the user if he wants to subscribe
24
+ # Send the basic template
25
+ else
26
+ { return: 'Password found, connected', message_id: message_id }
27
+ # Send the user account template
28
+ end
29
+ end
18
30
 
19
- def self.authentication(_data, message_id)
20
- { data: { message: 'login received' }, message_id: message_id }
21
- end
31
+ def authentication(data, message_id)
32
+ # { data: { message: 'login received' }, message_id: message_id }
33
+ db = db_access
34
+ identity_items = db[:identity]
35
+ user_email = data["email"]
36
+ mail_exists = identity_items.where(email: user_email).first
22
37
 
23
- def self.init_db(_data, message_id)
24
- { data: { message: 'database initialised' }, message_id: message_id }
25
- end
38
+ if !mail_exists
39
+ { return: 'Email not found', message_id: message_id }
40
+ # { return: user_email, message_id: message_id }
41
+ # Ask to the user if he wants to subscribe
42
+ # Send the basic template
43
+ else
44
+ { return: 'Email found, looking for pass', message_id: message_id }
45
+ # Verify password
46
+ # If password isn't ok, send error
47
+ # If the password is ok, send the user account template
48
+ end
49
+ end
26
50
 
27
- def self.query(data, message_id)
28
- identity_table = db_access[data['table'].to_sym]
29
- result = identity_table.send(:all).send(:select)
30
- { data: { table: data['table'], infos: result }, message_id: message_id }
31
- end
51
+ def init_db(_data, message_id)
52
+ unless File.exist?("eden.sqlite3")
53
+ Sequel.connect("sqlite://eden.sqlite3")
54
+ end
55
+ { data: { message: 'database initialised' }, message_id: message_id }
56
+ end
57
+
58
+ def crate_db_table(data, message_id)
59
+ table = data['table']
60
+ Database.create_table(table)
61
+ { data: { message: "table #{table} added" }, message_id: message_id }
62
+ end
63
+
64
+ def create_db_column(data, message_id)
65
+ table = data['table']
66
+ column = data['column']
67
+ type = data['type']
68
+ Database.create_column(table, column, type)
69
+ { data: { message: "column #{column} with type : #{type} added" }, message_id: message_id }
70
+ end
71
+
72
+ def query(data, message_id)
73
+ identity_table = db_access[data['table'].to_sym]
74
+ result = identity_table.send(:all).send(:select)
75
+ { data: { table: data['table'], infos: result }, message_id: message_id }
76
+ end
32
77
 
33
- def self.insert(data, message_id)
34
- table = data['table'].to_sym
35
- particle = data['particle'].to_sym
36
- data = data['data']
37
- if db_access.table_exists?(table)
38
- schema = db_access.schema(table)
39
- if schema.any? { |col_def| col_def.first == particle }
40
- identity_table = db_access[table.to_sym]
41
- identity_table.insert(particle => data)
42
- { data: { message: "column : #{particle}, in table : #{table}, updated with : #{data}"}, message_id: message_id }
78
+ def insert(data, message_id)
79
+ table = data['table'].to_sym
80
+ particle = data['particle'].to_sym
81
+ data = data['data']
82
+ if db_access.table_exists?(table)
83
+ schema = db_access.schema(table)
84
+ if schema.any? { |col_def| col_def.first == particle }
85
+ identity_table = db_access[table.to_sym]
86
+ identity_table.insert(particle => data)
87
+ { data: { message: "column : #{particle}, in table : #{table}, updated with : #{data}" }, message_id: message_id }
88
+ else
89
+ { data: { message: "column not found: #{particle.class}" }, message_id: message_id }
90
+ end
43
91
  else
44
- { data: { message: "column not found: #{particle.class}" }, message_id: message_id }
45
- end
46
- else
47
- { data: { message: "table not found: #{table.class}" }, message_id: message_id }
92
+ { data: { message: "table not found: #{table.class}" }, message_id: message_id }
48
93
 
94
+ end
49
95
  end
50
- end
51
96
 
52
- def self.file(data, message_id)
97
+ def file(data, message_id)
53
98
 
54
- file_content = File.send(data['operation'], data['source'], data['value']).to_s
55
- file_content = file_content.gsub("'", "\"")
99
+ file_content = File.send(data['operation'], data['source'], data['value']).to_s
100
+ file_content = file_content.gsub("'", "\"")
56
101
 
57
- file_content = file_content.gsub('#', '\x23')
58
- { data: "=> operation: #{data['operation']}, source: #{data['source']}, content: #{file_content}", message_id: message_id }
59
- end
102
+ file_content = file_content.gsub('#', '\x23')
103
+ { data: "=> operation: #{data['operation']}, source: #{data['source']}, content: #{file_content}", message_id: message_id }
104
+ end
60
105
 
61
- def self.safe_send(method_name, data, message_id)
62
- method_sym = method_name.to_sym
63
- send(method_sym, data, message_id)
106
+ def safe_send(method_name, data, message_id)
107
+ method_sym = method_name.to_sym
108
+ send(method_sym, data, message_id)
109
+ end
64
110
  end
111
+
65
112
  end
@@ -67,7 +67,7 @@ const communication = {
67
67
 
68
68
  // now new can exec user code : loadApplicationJs in index.html
69
69
  loadApplicationJs();
70
- rubyVMCallback("A.user_login");
70
+ // rubyVMCallback("A.user_login");
71
71
  };
72
72
  this.websocket.onmessage = function (event) {
73
73
  // console.log(event.data)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6.2.3
4
+ version: 0.5.6.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Eric Godard
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-14 00:00:00.000000000 Z
11
+ date: 2024-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: artoo
@@ -465,6 +465,7 @@ files:
465
465
  - lib/eVe/documentation/server.md
466
466
  - lib/eVe/eVe.rb
467
467
  - lib/eVe/eVe_relative.rb
468
+ - lib/eVe/lib/init.rb
468
469
  - lib/eVe/todo.txt
469
470
  - lib/platform_specific/opal/atome_opal_extensions.rb
470
471
  - lib/platform_specific/opal/extensions/color.rb