atome 0.1.00006 → 0.1.00009

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52c49373089fad75541d709e0a1e4f6308814d233ae065c3878e2c9b70519f41
4
- data.tar.gz: 19a30b6146ffcf2e7fdb5e947f2d040a113e6df4462d78009f4b344d153f24a1
3
+ metadata.gz: f4b48cdeb89c228abfd54f7ff8a986bf57b856ee448248f8bc72d350f2102f92
4
+ data.tar.gz: 684ee3dbfb0c2f8a630203b70c76fee2c4bbc38e668236eb39ce4031fce07ad0
5
5
  SHA512:
6
- metadata.gz: d69ff12e61d2f9645b63a1fdcb7bee47c855d5f675b33a0f8fb5dfb82eb265162c9bf2bcbc362d5199a3af5a369a2e0443777f1f8137376d526b614b94142643
7
- data.tar.gz: 453a3338ea67304157a79c8d07e976ac8345f540b6cca9469d68dfdb1868d49b01a33ee1fabd55c245e54d6d746e14c242d423e45ee405f9d5808ff4978d50f1
6
+ metadata.gz: abce3a0481ef173040bff4c5753ddc0da3429b62b9d25c6b60b3dd87751b582d3c917fb84ed56b97b684fe8066ff99882f7be57a1530529f32eee02666fa2781
7
+ data.tar.gz: e1addd8946eed935d0becf3b612969387f6107271819913fc62a8fe0f633ed13f485974195f77f74f28c03e95c412af39171336efcde841683e3ee84337eef29
data/exe/atome CHANGED
@@ -3,7 +3,21 @@
3
3
 
4
4
  require 'fileutils'
5
5
 
6
- def run option = :browser, location = nil
6
+ def delete_all(dir)
7
+ Dir.foreach(dir) do |e|
8
+ # Don't bother with . and ..
9
+ next if %w[. ..].include? e
10
+ fullname = dir + File::Separator + e
11
+ if FileTest.directory?(fullname)
12
+ delete_all(fullname)
13
+ else
14
+ File.delete(fullname)
15
+ end
16
+ end
17
+ Dir.delete(dir)
18
+ end
19
+
20
+ def run(option = :browser, location = nil)
7
21
  case option
8
22
  when :server
9
23
  require 'atome'
@@ -19,17 +33,15 @@ def run option = :browser, location = nil
19
33
  `cd ./build;open index.html`
20
34
  end
21
35
  when :osx
22
- puts `pwd`
23
36
  require 'webview_ruby'
24
37
  webview = WebviewRuby::Webview.new
25
- webview.set_title("atome")
38
+ webview.set_title('atome')
26
39
  webview.set_size(480, 360)
27
40
  if location
28
41
  webview.navigate("file:/#{`pwd`}/#{location}/build/index.html")
29
42
  else
30
43
  webview.navigate("file:#{`pwd`.chomp}/build/index.html")
31
44
  end
32
-
33
45
  webview.run
34
46
  else
35
47
  # nothing for now
@@ -40,6 +52,8 @@ end
40
52
  case ARGV[0]
41
53
  when 'create'
42
54
  project_name = ARGV[1]
55
+ force = ARGV[2]
56
+ delete_all(project_name) if force == 'force'
43
57
  Dir.mkdir project_name.to_s
44
58
  current_path = `pwd`.chomp
45
59
  gem_assets_location = File.join(File.dirname(__FILE__), '../vendor/assets/')
@@ -53,6 +67,7 @@ when 'create'
53
67
  end
54
68
  # now run the rake task to build the needed libraries (atome, renderers, etc...)
55
69
  `cd #{app_builder_helpers};rake system_builder #{current_path}/#{project_name}`
70
+ run(:server, project_name)
56
71
  when 'run'
57
72
  case ARGV[1]
58
73
  when 'android'
data/lib/atome/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Atome
4
- VERSION = '0.1.00006'
4
+ VERSION = '0.1.00009'
5
5
  end
@@ -1,135 +1,166 @@
1
- def toto(e)
2
- e.prevent
3
- e.on.inner_text = "Super Clicked!"
1
+ # def toto(e)
2
+ # e.prevent
3
+ # e.on.inner_text = "Super Clicked!"
4
+ # end
5
+ #
6
+ # $document.on(:mousedown, "#good") do |e|
7
+ # toto(e)
8
+ # end
9
+ # $document.on(:touchstart, "#good") do |e|
10
+ # toto(e)
11
+ # end
12
+ #
13
+ # verif = <<-STR
14
+ # $document.ready do
15
+ # DOM {
16
+ # div.info {
17
+ # span.red "Opal eval cooked up!"
18
+ # }
19
+ # }.append_to($document.body)
20
+ # end
21
+ # STR
22
+ #
23
+ # eval(verif)
24
+ #
25
+ #
26
+ # $document.body.style.apply {
27
+ # background color: 'black'
28
+ # color 'orange'
29
+ # font family: 'Verdana'
30
+ # }
31
+ # $document.ready do
32
+ # DOM {
33
+ # div.info {
34
+ # i=0
35
+ # while i< 20
36
+ # i+=1
37
+ # span(id: "good").red "Opal cooked up, click me #{i}"
38
+ # div(id: "hook").red "lllll#{i} --"
39
+ # end
40
+ # }
41
+ # }.append_to($document["user_view"])
42
+ #
43
+ # # alert($document.body.id)
44
+ # # $document.getElementById("hook").style.color("red")
45
+ # # bb=$document.find('header')
46
+ # bb=`document.getElementById('hook')`
47
+ # # a= $document.get_element_by_id(:hook)
48
+ # a= $document[:hook]
49
+ #
50
+ # elem = $document.at_css(".red").style(color: :yellow)
51
+ #
52
+ # $document.on :click do |e|
53
+ # elem.style(color: :yellowgreen)
54
+ # # elem.style.apply {
55
+ # # background color: 'blue'
56
+ # # color 'green'
57
+ # # font family: 'Verdana'
58
+ # # }
59
+ # # a.style.apply {
60
+ # # background color: 'red'
61
+ # # color 'black'
62
+ # # font family: 'Verdana'
63
+ # # }
64
+ # end
65
+ #
66
+ # # bb =$document.id='hook'
67
+ # # bb= $document["hook"]
68
+ # # bb.on.inner_text"jsqhdgfjqhsdgfjqhsgdjhqsg Clicked!"
69
+ # # bb.style.apply {
70
+ # # background color: 'black'
71
+ # # color 'orange'
72
+ # # font family: 'Verdana'
73
+ # # }
74
+ #
75
+ # end
76
+ #
77
+ # $document.body.style.apply {
78
+ # background color: 'black'
79
+ # color 'orange'
80
+ # font family: 'Verdana'
81
+ # }
82
+ #
83
+ #
84
+ # def box(params={})
85
+ # DOM do
86
+ # el=div(id: "hook")
87
+ # el( ",jb,jb")
88
+ # end.append_to($document["user_view"])
89
+ #
90
+ # end
91
+ #
92
+ # box
93
+ #
94
+ # e=$document.at_css("#hook")
95
+ # e.style { background color: 'lime' }
96
+ # $document.at_css("#hook").style(color: :red)
97
+ # # Example 2
98
+ # DOM do
99
+ # div(id: "hook").red "lllll"
100
+ # div(id: "poil").red "kool"
101
+ # end.append_to($document["user_view"])
102
+ # elem = $document.css("#poil").style(color: :orange)
103
+ #
104
+ # # #Example 3
105
+ # def box(params = {})
106
+ # params = { color: :pink, width: 100, height: 100 }.merge(params)
107
+ # DOM do
108
+ # div(id: "hook",
109
+ # class: :toto,
110
+ # style: "background-color: #{params[:color]};
111
+ # width: #{params[:width]}px;
112
+ # height: #{params[:height]}px;
113
+ # box-shadow: #{params[:shadow]};
114
+ # ")
115
+ # .the_class
116
+ # end.append_to($document["user_view"])
117
+ # end
118
+ #
119
+ # window_height= $window.view.height/12
120
+ # window_width= $window.view.width/12
121
+ # box({ color: :green, shadow: "0px 0px 10px black;" })
122
+ # $document.body['foo'] = 'bar'
123
+ #
124
+ #
125
+ # $window.on :resize do |e|
126
+ # puts $window.view.height
127
+ # puts $window.view.width
128
+ # puts "------"
129
+ # # alert $document.body.width
130
+ # end
131
+ #
132
+ # puts $document.search('div').size
133
+ # # $document.search('div')['foo'] = 'bar'
134
+ #
135
+ #
136
+
137
+
138
+
139
+ # require 'browser/socket'
140
+
141
+ ws =Browser::Socket.new 'ws://127.0.0.1:9292'
142
+ ws.on :open do
4
143
  end
5
144
 
6
- $document.on(:mousedown, "#good") do |e|
7
- toto(e)
145
+ ws.on :message do |e|
146
+ alert e.data
8
147
  end
9
- $document.on(:touchstart, "#good") do |e|
10
- toto(e)
11
- end
12
-
13
- verif = <<-STR
14
- $document.ready do
15
- DOM {
16
- div.info {
17
- span.red "Opal eval cooked up!"
18
- }
19
- }.append_to($document.body)
20
- end
21
- STR
22
-
23
- eval(verif)
24
-
25
148
 
26
- $document.body.style.apply {
27
- background color: 'black'
28
- color 'orange'
29
- font family: 'Verdana'
30
- }
31
- $document.ready do
32
- DOM {
33
- div.info {
34
- i=0
35
- while i< 20
36
- i+=1
37
- span(id: "good").red "Opal cooked up, click me #{i}"
38
- div(id: "hook").red "lllll#{i} --"
39
- end
40
- }
41
- }.append_to($document["user_view"])
42
149
 
43
- # alert($document.body.id)
44
- # $document.getElementById("hook").style.color("red")
45
- # bb=$document.find('header')
46
- bb=`document.getElementById('hook')`
47
- # a= $document.get_element_by_id(:hook)
48
- a= $document[:hook]
49
-
50
- elem = $document.at_css(".red").style(color: :yellow)
51
-
52
- $document.on :click do |e|
53
- elem.style(color: :yellowgreen)
54
- # elem.style.apply {
55
- # background color: 'blue'
56
- # color 'green'
57
- # font family: 'Verdana'
58
- # }
59
- # a.style.apply {
60
- # background color: 'red'
61
- # color 'black'
62
- # font family: 'Verdana'
63
- # }
150
+ def send_message(socket,msg)
151
+ if socket.alive?
152
+ socket.send(msg )
153
+ else
154
+ after 0.1 do
155
+ send_message(socket,msg)
64
156
  end
65
-
66
- # bb =$document.id='hook'
67
- # bb= $document["hook"]
68
- # bb.on.inner_text"jsqhdgfjqhsdgfjqhsgdjhqsg Clicked!"
69
- # bb.style.apply {
70
- # background color: 'black'
71
- # color 'orange'
72
- # font family: 'Verdana'
73
- # }
74
-
75
157
  end
76
158
 
77
- $document.body.style.apply {
78
- background color: 'black'
79
- color 'orange'
80
- font family: 'Verdana'
81
- }
82
-
83
-
84
- def box(params={})
85
- DOM do
86
- el=div(id: "hook")
87
- el( ",jb,jb")
88
- end.append_to($document["user_view"])
89
-
90
159
  end
91
160
 
92
- box
93
-
94
- e=$document.at_css("#hook")
95
- e.style { background color: 'lime' }
96
- $document.at_css("#hook").style(color: :red)
97
- # Example 2
98
- DOM do
99
- div(id: "hook").red "lllll"
100
- div(id: "poil").red "kool"
101
- end.append_to($document["user_view"])
102
- elem = $document.css("#poil").style(color: :orange)
103
-
104
- # #Example 3
105
- def box(params = {})
106
- params = { color: :pink, width: 100, height: 100 }.merge(params)
107
- DOM do
108
- div(id: "hook",
109
- class: :toto,
110
- style: "background-color: #{params[:color]};
111
- width: #{params[:width]}px;
112
- height: #{params[:height]}px;
113
- box-shadow: #{params[:shadow]};
114
- ")
115
- .the_class
116
- end.append_to($document["user_view"])
117
- end
118
-
119
- window_height= $window.view.height/12
120
- window_width= $window.view.width/12
121
- box({ color: :green, shadow: "0px 0px 10px black;" })
122
- $document.body['foo'] = 'bar'
123
-
124
-
125
- $window.on :resize do |e|
126
- puts $window.view.height
127
- puts $window.view.width
128
- puts "------"
129
- # alert $document.body.width
130
- end
161
+ my_msg={ foo: "bar" }
162
+ my_msg=JSON.generate(my_msg)
163
+ send_message(ws,my_msg)
131
164
 
132
- puts $document.search('div').size
133
- # $document.search('div')['foo'] = 'bar'
134
165
 
135
166
 
@@ -1,13 +1,6 @@
1
1
  # frozen_string_literal: true
2
+ # atome server
2
3
 
3
- # instructions to install :
4
- # gem install bundler roda sqlite3 sequel rack-unreloader faye-websocket websocket-extensions websocket-driver puma -N
5
- # important if crash the gem install rack-unreloader -v 1.7.0 gem install roda -v 2.26.0
6
- # bundle update
7
- # bundle install
8
- # to run: rackup --server puma --port 4567 or without puma : rackup -p 4567
9
-
10
- # puts RUBY_VERSION
11
4
  if RUBY_PLATFORM == "x64-mingw32"
12
5
  require "em/pure_ruby"
13
6
  end
@@ -19,9 +12,6 @@ require "json"
19
12
  require "securerandom"
20
13
  require "mail"
21
14
  require "digest"
22
- require "filewatcher"
23
- require "artoo"
24
-
25
15
 
26
16
  class String
27
17
  def is_json?
@@ -34,12 +24,6 @@ class String
34
24
  end
35
25
 
36
26
  class App < Roda
37
-
38
- @@channels = {}
39
- @@user
40
- @@test_socket = []
41
-
42
- #plugin :mail_processor
43
27
  eden = Sequel.connect("sqlite://eden.sqlite3")
44
28
  unless File.exist?("eden.sqlite3")
45
29
  eden.create_table :objects do
@@ -50,247 +34,28 @@ class App < Roda
50
34
  String :content
51
35
  end
52
36
  end
53
-
54
37
  index_content = File.read("../build/index.html")
55
38
 
56
- # index_content = index_content.gsub('<script type="text/javascript" src="../cordova.js"></script>', "")
57
- # below an attempt to load atome in pure ruby not opal
58
39
  require 'atome'
59
40
  opts[:root] = '../build'
60
41
  plugin :static, %w[/css /js /medias], root: '../build'
61
- # plugin "faye/websocket"
62
42
  route do |r|
63
43
  if Faye::WebSocket.websocket?(env)
64
- ws = Faye::WebSocket.new(env)
65
- # @@test_socket[0] = ws
66
- @@test_socket[0] = ws
67
- ws.on :message do |event|
44
+ websocket = Faye::WebSocket.new(env)
45
+ websocket.on :message do |event|
68
46
  client_data = event.data
69
47
  if client_data.is_json?
70
- data = JSON.parse(client_data)
71
- # puts data
72
- case data["type"]
73
- when "login"
74
- user_id = data["username"]
75
- # @user_id[user_id]=ws
76
- # @user[data["username"]] = ws
77
- # ws.send()
78
- # message_back = "text ({content: '#{data["username"]} with id : #{data["id"]} is connected!', y:330})"
79
- # message_back={id: data["id"], log: true}
80
- #
81
- session_id = SecureRandom.uuid
82
- message_back = JSON.generate({ type: :response, request_id: data["request_id"], session_id: session_id, log: true })
83
- ws.send(message_back)
84
-
85
- when "start_channel"
86
- channel_id = SecureRandom.uuid
87
- # self.channels(channel_id)
88
- @@channels[channel_id] = []
89
- # @session[data["username"]] =session_id
90
- message_back = JSON.generate({ type: :response, request_id: data["request_id"], channel_id: channel_id })
91
- ws.send(message_back)
92
- when "list_channels"
93
- message_back = JSON.generate({ type: :response, request_id: data["request_id"], channels: @@channels.keys })
94
- ws.send(message_back)
95
- when "connect_channel"
96
- channel_id = data["channel_id"]
97
- @@channels[channel_id] << ws
98
- message_back = JSON.generate({ type: :response, request_id: data["request_id"], connected: true })
99
- ws.send(message_back)
100
- when "push_to_channel"
101
- channel_id = data["channel_id"]
102
- message_received = data["message"]
103
- #fixme the type depend on the kind if received message
104
- message_to_push = JSON.generate({ type: :code, content: message_received })
105
- @@channels[channel_id].each do |ws_found|
106
- # we exclude the sender from the recipient
107
- unless ws_found == ws
108
- ws_found.send(message_to_push)
109
- end
110
- end
111
- message_back = JSON.generate({ type: :response, request_id: data["request_id"], pushed: true })
112
- ws.send(message_back)
113
- when "read"
114
- file_content = File.read(data["file"])
115
- hashed_content = { content: file_content }
116
- hashed_options = { options: data["options"].to_s }
117
- message_to_push = JSON.generate({ type: :read, atome: data["atome"], target: data["target"], content: hashed_content, options: hashed_options })
118
- ws.send(message_to_push)
119
- when "set"
120
- msg = { type: :monitor, atome: data["atome"], target: data["target"], output: data["output"], content: data["content"],options: data["options"] }
121
- set_output msg
122
- when "monitor"
123
- # file = data["file"]
124
- # monitor "public/medias/e_projects/chambon/code.rb"
125
- # puts file.class
126
- # if !file.instance_of?(Array)
127
- # file=[file]
128
- # end
129
-
130
-
131
- # @@threads << Thread.new do
132
- # puts "hello from thread"
133
- # Filewatcher.new(file).watch do |changes|
134
- # file_content = file
135
- # hashed_content = { content: data["file"] }
136
- # hashed_options = { options: data["options"].to_s }
137
- if data["file"]
138
- msg = { type: :monitor, atome: data["atome"], target: data["target"], content: data["file"], options: data["options"] }
139
- monitor msg
140
- else
141
- msg = { type: :monitor, atome: data["atome"], target: data["target"], input: data["input"], options: data["options"] }
142
- capture_input msg
143
- end
144
- # puts "------"
145
- # puts file.class
146
- # puts "------"
147
- # message_to_push = JSON.generate({ type: :monitor, atome: data["atome"], target: data["target"], content: hashed_content, options: hashed_options })
148
- # # puts ws.inspect
149
- # # puts "---"
150
- # puts "hashed_content : #{hashed_content}}"
151
- # puts "hashed_options : #{hashed_options}}"
152
- # puts "message_to_push : #{message_to_push}}"
153
- # ws.send(message_to_push)
154
- # # @@channels[channel_id].each do |ws_found|
155
- # # # we exclude the sender from the recipient
156
- # # unless ws_found == ws
157
- # # ws_found.send(message_to_push)
158
- # # end
159
- # # end
160
- # end
161
- # puts "koolll!!!!"
162
- # end
163
- # @@threads.each(&:join)
164
-
165
- # t= Thread.new do
166
- # puts "hello from thread"
167
- # Filewatcher.new(file).watch do |changes|
168
- # # file_content = File.read(changes)
169
- # hashed_content = { content: file_content }
170
- # hashed_options = { options: data["options"].to_s }
171
- # message_to_push = JSON.generate({ type: :monitor, atome: data["atome"], target: data["target"], content: hashed_content, options: hashed_options })
172
- # # puts ws.inspect
173
- # # puts "---"
174
- # puts "hashed_content : #{hashed_content}}"
175
- # puts "hashed_options : #{hashed_options}}"
176
- # puts "message_to_push : #{message_to_push}}"
177
- # ws.send(message_to_push)
178
- # # @@channels[channel_id].each do |ws_found|
179
- # # # we exclude the sender from the recipient
180
- # # unless ws_found == ws
181
- # # ws_found.send(message_to_push)
182
- # # end
183
- # # end
184
- # end
185
- #
186
- # end
187
- #
188
- # t.join
189
-
190
- # # ugly patch below needs to use filewatcher above instead
191
- # t=Thread.new do
192
- # sleep 12
193
- # puts file = data["file"]
194
- # end
195
- # t.join
196
- # if @file_require == (Digest::SHA256.hexdigest File.read data["file"])
197
- # @file_require = Digest::SHA256.hexdigest File.read data["file"]
198
- # else
199
- # @file_require = Digest::SHA256.hexdigest File.read data["file"]
200
- # # file_content = File.read()
201
- # file = data["file"]
202
- # hashed_file = { content: file }
203
- # hashed_options = { options: data["options"].to_s }
204
- # message_to_push = JSON.generate({ type: :monitor, atome: data["atome"], target: data["target"], file: hashed_file, options: hashed_options })
205
- # ws.send(message_to_push)
206
- # end
207
- when "list"
208
- files_found = Dir[data["path"] + "/*"]
209
- hashed_content = { content: files_found }
210
- hashed_options = { options: data["options"].to_s }
211
- message_to_push = JSON.generate({ type: :read, target: data["target"], content: hashed_content, options: hashed_options })
212
- ws.send(message_to_push)
213
- when "write"
214
- File.write(data["file"], data["content"])
215
- hashed_content = { content: data["content"].to_s }
216
- hashed_options = { options: data["options"].to_s }
217
- message_to_push = JSON.generate({ type: :read, target: data["target"], content: hashed_content, options: hashed_options })
218
- ws.send(message_to_push)
219
- when "copy"
220
- FileUtils.cp data["source"], data["dest"]
221
- when "delete"
222
- File.delete(data["file"])
223
- hashed_content = { content: data["file"].to_s }
224
- hashed_options = { options: data["options"].to_s }
225
- message_to_push = JSON.generate({ type: :read, target: data["target"], content: hashed_content, options: hashed_options })
226
- ws.send(message_to_push)
227
- when "mail"
228
- if data["from"]
229
- sender = data["from"]
230
- else
231
- sender = "contact@atome.one"
232
- end
233
- receiver = data["to"]
234
- mail_subject = data["subject"]
235
- content = data["content"]
236
- attachment = data["attachment"]
237
- attachments = []
238
- if attachment
239
- if attachment.instance_of?(Array)
240
- attachment.each do |file|
241
- filename = File.basename(file)
242
- attachments << { file: file, filename: filename }
243
- end
244
- else
245
- filename = File.basename(attachment)
246
- attachments << { file: attachment, filename: filename }
247
- end
248
- end
249
- # puts "----- + -----"
250
- # puts "sender: #{sender}"
251
- # puts "receiver: #{receiver}"
252
- # puts "mail_subject: #{mail_subject}"
253
- # puts "content: #{content}"
254
- # puts "attachments: #{attachments}"
255
- # puts "----- - -----"
256
- mail = Mail.new do
257
- from sender
258
- to receiver
259
- subject mail_subject
260
- body content
261
- attachments.each do |file_to_add|
262
- file = file_to_add[:file]
263
- filename = file_to_add[:filename]
264
- add_file :filename => filename, :content => File.read(file)
265
- end
266
- end
267
-
268
- mail.delivery_method :sendmail
269
-
270
- mail.deliver
271
- when "atome"
272
- message_to_push = JSON.generate({ type: :atome, target: data["target"], atome: data["atome"], content: data["content"] })
273
- ws.send(message_to_push)
274
- when "code"
275
- message_to_push = JSON.generate({ type: :code, content: data["content"] })
276
- ws.send(message_to_push)
277
- when "command"
278
- file_content = `#{data["content"]}`
279
- # hashed_content = { content: file_content }.merge(data["options"])
280
- message_to_push = JSON.generate({ type: :command, target: data["target"], atome: data["atome"], content: file_content })
281
- ws.send(message_to_push)
282
- else
283
- # ws.send("unknown message received")
284
- end
48
+ # to get hash from data: data_to_hash = JSON.parse(client_data)
49
+ websocket.send(client_data)
285
50
  end
286
51
  end
287
- #ws.on :open do |event|
288
- # #ws = nil
289
- #end
290
- ws.on :close do |event|
291
- #ws = nil
52
+ websocket.on :open do
53
+ # websocket.send(event.data)
54
+ end
55
+ websocket.on :close do
56
+ # websocket.send(event.data)
292
57
  end
293
- ws.rack_response
58
+ websocket.rack_response
294
59
  end
295
60
  r.root do
296
61
  r.redirect "/index"
@@ -298,78 +63,9 @@ class App < Roda
298
63
  r.on "index" do
299
64
  r.is do
300
65
  r.get do
301
- #sleep 7
302
- #box()
303
66
  index_content
304
67
  end
305
68
  end
306
69
  end
307
70
  end
308
-
309
- def self.monitor_callback(val, params)
310
- ws = @@test_socket[0]
311
- file_content = File.read(val)
312
- params[:content] = val
313
- msg = { "type": "eval", "atome": "text", "target": "tryout", "content": { "content": file_content }, "options": "clear" }
314
- params[:content] = { "content": { "content": file_content } }
315
- message_to_push = JSON.generate(msg)
316
- ws.send(message_to_push)
317
- end
318
-
319
- def self.device_output_callback( params)
320
- ws = @@test_socket[0]
321
- file_content = params[:content]
322
- msg = { "type": "read", "atome": "text", "target": "tryout", "content": { "content": file_content }, "options": "clear" }
323
- params[:content] = { "content": { "content": file_content } }
324
- message_to_push = JSON.generate(msg)
325
- ws.send(message_to_push)
326
- end
327
71
  end
328
-
329
-
330
-
331
-
332
- # Update all connections in a single thread
333
- def monitor(params)
334
- Thread.new do
335
- Filewatcher.new(params[:content]).watch do |changes|
336
- App.monitor_callback(changes, params)
337
- end
338
- end
339
- end
340
-
341
- @bbb_ready = false
342
- @bbb_thread = false
343
-
344
- def capture_input params
345
- unless @bbb_ready
346
- @bbb_ready = true
347
- puts "bbb is ready"
348
- # require "./beagleboard"
349
-
350
- end
351
- if @bbb_thread
352
- @bbb_thread.exit
353
- end
354
-
355
- @bbb_thread = Thread.new do
356
-
357
- i = 0
358
- while i < 2000
359
- puts i
360
- sleep 1
361
- i += 1
362
- end
363
- end
364
- end
365
-
366
-
367
- def set_output params
368
- App.device_output_callback( params)
369
- end
370
-
371
-
372
- # capture_input(1, { my_condition: :callback })
373
- #
374
- # capture_input(1, { my_condition: :callback })
375
- # capture_input(1, { my_condition: :callback })
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.00006
4
+ version: 0.1.00009
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: 2022-04-13 00:00:00.000000000 Z
11
+ date: 2022-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: artoo
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.8'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.8'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: faye-websocket
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -276,23 +262,9 @@ dependencies:
276
262
  - - "~>"
277
263
  - !ruby/object:Gem::Version
278
264
  version: '0.1'
279
- - !ruby/object:Gem::Dependency
280
- name: webview_ruby
281
- requirement: !ruby/object:Gem::Requirement
282
- requirements:
283
- - - "~>"
284
- - !ruby/object:Gem::Version
285
- version: '0.1'
286
- type: :runtime
287
- prerelease: false
288
- version_requirements: !ruby/object:Gem::Requirement
289
- requirements:
290
- - - "~>"
291
- - !ruby/object:Gem::Version
292
- version: '0.1'
293
265
  description: the creative framework.
294
266
  email:
295
- - jeezs@jeezs.net
267
+ - jeezs@atopme.one
296
268
  executables:
297
269
  - atome
298
270
  extensions: []