acts_as_realtime 0.0.4 → 0.0.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 +8 -8
- data/lib/acts_as_realtime.rb +39 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OGE2Y2Y4ZTNkMzc1Njk4N2FlNWNhMTI3MWNjNDhhMzljZTYyMWJmYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Yjg2YWU0N2M1ZWUyYzBmMTY5MTdmMmNmOGZiNDlhMzVmNjU2OTk4ZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2E4MGYwNDQ4MjU1YmJkNDFkNzhmNTA2MjA3YzVkNTAxNjAyMGI0YmFjN2Q5
|
10
|
+
ZWJiM2U2YTJmZTY4MDIyODIzZDNjYWEwZjQwOWQ0NzkwNTZhNThhZGQ3YjFk
|
11
|
+
Y2ViMTMwNzI2MzRiNzQ5MDA3YTJmMWNlZWMwNzk5OWUxMzgyOGQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2M0NGRkNTVhYmJhZWI0YzcwMTk3MTgxY2EyNDE1YjBhMmU5NzMzMDRjMDAy
|
14
|
+
YmI3NTg2Y2I1YjFiYzU1MjQwYzc5YmRjMGM3NjY0Y2M3YmIxMWYxNzhkYTAz
|
15
|
+
ZmZlODc2NGYwZDc4NjZjOGJjZTRjYTY5ZDc2ZGI0MDQ4MzJjMTQ=
|
data/lib/acts_as_realtime.rb
CHANGED
@@ -3,7 +3,7 @@ require 'em-websocket'
|
|
3
3
|
|
4
4
|
module ActsAsRealTime
|
5
5
|
|
6
|
-
class << self; attr_accessor :ws, :channel; end
|
6
|
+
class << self; attr_accessor :ws, :channel, :mod_app, :html, :port, :selector, :host, :insert_method; end
|
7
7
|
|
8
8
|
def self.startup_web_socket_server
|
9
9
|
Thread.new {
|
@@ -19,6 +19,7 @@ module ActsAsRealTime
|
|
19
19
|
|
20
20
|
ws.onmessage { |msg|
|
21
21
|
#@channel.push "<#{sid}>: #{msg}"
|
22
|
+
puts msg
|
22
23
|
}
|
23
24
|
|
24
25
|
ws.onclose {
|
@@ -47,20 +48,51 @@ module ActsAsRealTime
|
|
47
48
|
end
|
48
49
|
|
49
50
|
module ClassMethods
|
50
|
-
def acts_as_realtime &blk
|
51
|
-
puts "ESTA GEMARA HARA QUE LAS APLICACIONES DE RAILS REVOLUCIONEN INCREIBLEMENTE"
|
52
51
|
|
53
|
-
|
52
|
+
def acts_as_realtime(config_params = {selector: nil, insertion_method: 'prepend'}, &blk)
|
54
53
|
|
54
|
+
=begin
|
55
|
+
Se había manejado cómo posible solución el manejar un token(*-*)
|
56
|
+
para interporlar los valores de los registros que se estan creando, cómo
|
57
|
+
por ejemplo el nombre de un usuario.
|
58
|
+
|
59
|
+
La idea consistia que el nombre del campo que se quiere interpolar debe de ir entre el token
|
60
|
+
identificador(*-*) en el html que sea pasado a la gema, para se parseado(interpolado) por la gema.
|
61
|
+
Ej:
|
62
|
+
|
63
|
+
html = "<tr><td><div class=" + '"prueba1"' + " > *-*#{'nombre'}*-* </div></td><td>R</td><td>o</td><td>R</td></tr>"
|
64
|
+
|
65
|
+
Esta solución puede causar problemas futuros, es por eso que se busco otra solución, que es el código
|
66
|
+
actual, esto se deja comentado por si se necesitara usar despues
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
start_index = html.index("*-*")
|
71
|
+
sub_html = html[start_index+3..-1]
|
72
|
+
finish_index = sub_html.index('*-*') + 2
|
73
|
+
attr = sub_html[0..finish_index-3]
|
74
|
+
|
75
|
+
|
76
|
+
=end
|
77
|
+
|
78
|
+
#Se define el método update_index en lo modelos que se ejecute el método acts_as_real_time
|
55
79
|
ActiveRecord::Base.class_eval {
|
56
|
-
|
57
|
-
|
80
|
+
define_method(:update_index) do
|
81
|
+
|
82
|
+
#eval("html[start_index..finish_index] = #{attr}") Esta instrucción se usaba para la solución que se planteó arriba
|
83
|
+
|
84
|
+
res_yield = yield ActsAsRealTime.ws, ActsAsRealTime.channel, self if block_given?
|
85
|
+
ActsAsRealTime.mod_app, ActsAsRealTime.html = res_yield[0], res_yield[1]
|
86
|
+
ActsAsRealTime.mod_app::Application.config.chanel = ActsAsRealTime::channel
|
87
|
+
ActsAsRealTime.mod_app::Application.config.chanel.push "$('#{config_params[:selector]}').#{config_params[:insertion_method]}('#{ActsAsRealTime.html}');"
|
58
88
|
end
|
59
89
|
after_create :update_index
|
60
90
|
}
|
61
91
|
end
|
62
92
|
end
|
63
93
|
|
94
|
+
=begin
|
95
|
+
Estos métodos no se usa actualmente, se deja comentado cómo ejemplo para modificaciones o mejoras futuras
|
64
96
|
def self.define_adders_methods app
|
65
97
|
eval "#{app}::Aplication.class_eval {" +
|
66
98
|
"define_method(:save_communication_variables, :ws, :channel){" +
|
@@ -69,6 +101,7 @@ module ActsAsRealTime
|
|
69
101
|
"}" +
|
70
102
|
"}"
|
71
103
|
end
|
104
|
+
=end
|
72
105
|
end
|
73
106
|
|
74
107
|
ActiveRecord::Base.send :include, ActsAsRealTime
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_realtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rolando Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Gem for add realtime functionality for ruby on rails apps, it use em-websocket
|
14
14
|
gem sor use websockets and channels
|
@@ -18,7 +18,7 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- lib/acts_as_realtime.rb
|
21
|
-
homepage:
|
21
|
+
homepage: https://github.com/rolandoivan23/acts_as_realtime
|
22
22
|
licenses:
|
23
23
|
- MIT
|
24
24
|
metadata: {}
|