magic_mirror 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 99ae6ed2cd45562d4fe35027396c9fb97c71e35a
4
- data.tar.gz: 9a94943f0ec1d9c6e59534a1653cef1aa5584dfc
3
+ metadata.gz: 5a1414e7bfa5467e60f05646f0370beeeb326f95
4
+ data.tar.gz: beaef4c2e0344799dbf286cfd0c3de8df32c98bf
5
5
  SHA512:
6
- metadata.gz: b44cbc8caa075fd22f931bea1ca149b99c0bd2b8a95d5e7577998b71c714a5dde15ffa7fa7e3394a6259cd68949b5418e5a71e97c9a68fc2c5382e74de394298
7
- data.tar.gz: 5b8b356d1117ef8d273a2c54d9747e079cad042afa0eda612d82643aef108e14c547a879174285bc86d1ff5430d1c427342150a80333aae0053a0c90c3aa0f08
6
+ metadata.gz: c1037e1c5af6c5d9922fff78f7b65cb339ad6e4be78b1c2d508c989f6112ba24b8f2ae02300e2045a00174d52d5714cf3d02408da6e332b758a38a6dbfa30054
7
+ data.tar.gz: 49eb5c2feba9d7a60bfbca86800e47c0bf3a5a6737ba48a36e066638a451a9affe57012756439917ce70c2648385c188867d78289a49ab1e71a0eb968e4407ba
data/changelog CHANGED
@@ -5,8 +5,14 @@ future.
5
5
  - Test against port in use problem.
6
6
 
7
7
  - How do you tell the host gem to just 'listen for commands' and idle there?
8
- (so the reverse usage of trtl)
9
- possible do a .join() on the sinatra thread?
8
+ > Call @magic_mirror.gaze_into to start event machine,
9
+ create a defered faye client,
10
+ make a subscription with said client
11
+ then block with EM.run
12
+
13
+ When a message is published to the subscribed channel, ruby can
14
+ respond accordingly, with full access to the gem and ruby landscape...
15
+ but ppl shouldn't directly eval the strings coming in over httpPost...
10
16
 
11
17
  - limitation: Can only have one rendering display at a time *per computer*
12
18
  > Solution: Clean up the output and make ports random
@@ -20,14 +26,56 @@ future.
20
26
  - Think of other popular uses for rendering...
21
27
  - secure by making servers listen only on localhost
22
28
 
23
- - Hide the STDOUT from starting the servers and print the
24
- address of the listening http server in a pretty manor that links
29
+ - I noticed some missing parts to the tree...
30
+ > Oh... right when you load the page, you'll get
31
+ [command_cache] - [changes to command_cache since page load innitated]
32
+ so a small gap in commands will exist...
33
+ SOLUTION
34
+
35
+ * Architecturally: add an index number to each message sent over faye
36
+ * Client-wise: Calculate
37
+ [Index of first faye message] - [length of the command cache] = [gap]
38
+ * request the gap from the server on receipt of first message from faye /gap?command_cache=95&first_faye=100
39
+
25
40
 
26
- - Write wrapper for TkcOval, btw...
27
41
 
28
42
  Currently:
29
43
 
44
+ - The tree example takes forever to draw
45
+ > Cache commands before sending through websockets:
46
+ cache websockets commands and wait 0.1 seconds between each
47
+ message sent...
48
+ ... it's also just a hell of a lot of data...
49
+
50
+ > Compress the command_cache: if the commands can be condensed so they
51
+ take up fewer characters, performance will improve dramatically.
52
+ *
53
+ *
54
+
55
+ > Dynamically build the tree function in javascript and reduce the command
56
+ to 1 function definition plus an invocation...
57
+
58
+ > What if command_cache SVG data instead of function calls?
59
+
60
+ - The javascript chokes up... possibly because it's iterating over the command cache,
61
+ and also responding to the websocket requests at the same time?
62
+
63
+ - Use webworker??
64
+
65
+ - Small discrepencies in bigish trtl lines in the tree example
66
+
67
+
68
+ - Hmmm.... why don't I steam the command_cache over websockets?
69
+ > The reason this is good is that it allows the client to get the data
70
+ in incriments and then deal with the data, and then wait for more.
71
+ This way the data never exceedes more than several kilobytes in memory...
72
+
73
+ - EFFICIENTLY TRANSFER THE COMMAND_CACHE ARRAY:
74
+ * embedded in html
30
75
 
76
+ * embedded in html, but split into chunks!!! after each chunk is finished and
77
+ processed/ deleted, the next chunk is gotten to until all the chunks are
78
+ deleted!!!!!!! !!!!!!!!!!!!!!!!!!!!
31
79
 
32
80
  Finished:
33
81
 
@@ -10,7 +10,26 @@ module MagicMirror
10
10
  def reset
11
11
  self.clear
12
12
  MagicMirror.mirror.speak_into("MagicMirror.clearCommandCache();")
13
+ self
13
14
  end
14
15
 
16
+
17
+ def to_embedded_javascript
18
+ string = ""
19
+
20
+ string += "<script>"
21
+ string += "window.command_cache = [];"
22
+
23
+ self.each_slice(100) do |a|
24
+ string += "z(#{a.to_json});"
25
+ end
26
+
27
+ string += "</script>"
28
+ string
29
+ end
30
+
31
+
32
+
33
+
15
34
  end
16
35
  end
@@ -71,20 +71,22 @@ module MagicMirror
71
71
  Net::HTTP.post_form(uri, :message => message.to_json)
72
72
  rescue
73
73
  $stderr.puts "failed to send message to faye server and thus webclient"
74
+ return false
74
75
  end
75
-
76
+ true
76
77
  end
77
78
 
78
79
  def wait_until_faye_is_up
79
80
  require 'net/http'
80
81
  while(true) do
81
82
  begin
82
- uri = URI.parse("http://localhost:#{FAYE_PORT}/")
83
- response = Net::HTTP.get_response(uri)
83
+ message = {:channel => "/0001", :data => "booted"}
84
+ uri = URI.parse("http://localhost:#{FAYE_PORT}/faye")
85
+ response = Net::HTTP.post_form(uri, :message => message.to_json)
84
86
  rescue
85
-
86
87
  end
87
- break if response and response.code == "404" and response.body == "Sure you're not looking for /faye ?"
88
+
89
+ break if response and response.code == "200" and response.body == "[{\"channel\":\"/0001\",\"successful\":true}]"
88
90
  sleep 0.1
89
91
  end
90
92
  end
@@ -9,6 +9,7 @@ module SinatraSilver
9
9
  #set :public_folder, Proc.new { File.join(MagicMirror.sinatra_root, "lib", "views") }
10
10
  #set :logging, false
11
11
  set :logging, false
12
+ set :bind, '127.0.0.1'
12
13
 
13
14
  configure do
14
15
  disable :logging
@@ -16,7 +17,12 @@ module SinatraSilver
16
17
 
17
18
  get '/' do
18
19
  @command_cache = MagicMirror.command_cache.to_json
20
+ @command_cache_fast_evaluator = MagicMirror.command_cache.to_embedded_javascript
19
21
  erb :index # 'Hello world!'
20
22
  end
23
+
24
+ get '/webworker.js' do
25
+ erb :webworker
26
+ end
21
27
  end
22
28
  end
@@ -1,3 +1,3 @@
1
1
  module MagicMirror
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -0,0 +1 @@
1
+ DEFINE YOUR WORKER IN YOUR OWN GEM, YOU'RE READING FROM MAGIC MIRROR'S lib/views/webworker.erb file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magic_mirror
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - TheNotary
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-14 00:00:00.000000000 Z
11
+ date: 2015-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -157,6 +157,7 @@ files:
157
157
  - lib/magic_mirror/sinatra_silver.rb
158
158
  - lib/magic_mirror/version.rb
159
159
  - lib/views/index.erb
160
+ - lib/views/webworker.erb
160
161
  - magic_mirror.gemspec
161
162
  - rspec
162
163
  - talk.md