h2g_ajaxchat 0.3.2 → 0.3.3

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: 941e2d26eb4eb2933c760bfc321214f8278f2e6266f94a35b5bcfcf969c6e369
4
- data.tar.gz: b9ec8471271d3dfee2d5316376e8889b71be9abb9fce803ed5698e150692d1df
3
+ metadata.gz: 7db5c15f7f4833080876a74afc5aa0a5076e8a08e5401c2d40a5a2b3c5082d89
4
+ data.tar.gz: 57f9b086460821188a16c3f028abc3528683afcb4efb23be2e460e1b7c84a442
5
5
  SHA512:
6
- metadata.gz: 51e2850f810132d03cfa9f71b2ff69e787ea1aaae16df17ffb327cae97672c8dbc4d33410c4dae131c43ed1e025d7a6a05380b426a5c1382511888786e269a56
7
- data.tar.gz: 2e0f56b8e26b60accb24d4aabf5e60acdef9f1a8b731a5b795d9861e0cb3ba6bc083ddccf613b853f95678d75a73d0d76d89f522a109e8a2c8f49915906ea844
6
+ metadata.gz: 1d8252c053581cc82b74299d5fb022ef064a08e1533824725b8af01fd44980bf487731b4653b30f0ed48b817a4ed4452601858af482784251f3115fc70307014
7
+ data.tar.gz: 340a2b64327b71919d839c9a860343ad55a93fa51f774090d991eec0ef4835c026beb8485f31e12cb6b00e4cf6cce58c3fdc50de0fbb8a2191aca196c8ce9d3d
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -24,12 +24,15 @@ require 'simple-config'
24
24
 
25
25
  class AjaxChatPlugin
26
26
 
27
- def initialize(settings={})
27
+ # ac = ajaxchat object
28
+ #
29
+ def initialize(ac, settings={}, debug: false)
30
+ @ac, @settings, @debug = ac, settings, debug
28
31
  end
29
32
 
30
- # Customises the ajax chat html etc; ac = ajaxchat object
33
+ # Customises the ajax chat html etc;
31
34
  #
32
- def apply(ac)
35
+ def apply()
33
36
  end
34
37
 
35
38
  # messages from the plugin to be added to the chat timeline
@@ -40,7 +43,7 @@ class AjaxChatPlugin
40
43
 
41
44
  # messages from the chat timeline
42
45
  #
43
- def on_newmessage(*a)
46
+ def on_newmessage(time, userid, username, msg)
44
47
  end
45
48
  end
46
49
 
@@ -130,7 +133,6 @@ class ChatCore
130
133
 
131
134
  end
132
135
 
133
- protected
134
136
 
135
137
  def append_message(t=Time.now, id=@session[:session_id].to_s,
136
138
  u=@session[:username], msg)
@@ -144,16 +146,17 @@ end
144
146
 
145
147
  class DummyRws
146
148
 
147
- attr_accessor :req
149
+ attr_accessor :req, :ac
150
+ attr_reader :rsc
148
151
 
149
- def initialize(obj)
152
+ def initialize(ac=nil, rsc: nil)
150
153
 
151
- @obj = obj
154
+ @ac, @rsc = ac, rsc
152
155
 
153
156
  end
154
157
 
155
158
  def redirect(s)
156
- @obj.method(s.to_sym).call
159
+ @ac.method(s.to_sym).call
157
160
  end
158
161
  end
159
162
 
@@ -385,8 +388,8 @@ class AjaxChat
385
388
  next if settings[:disabled]
386
389
  pluginklass_name = 'AjaxChatPlugin' + name.to_s
387
390
 
388
- #Kernel.const_get(pluginklass_name).new(settings)
389
- eval("#{pluginklass_name}.new(#{settings})")
391
+ #Kernel.const_get(pluginklass_name).new(self, settings, debug: false)
392
+ eval("#{pluginklass_name}.new(self, #{settings}, debug: false)")
390
393
 
391
394
  end.compact
392
395
 
@@ -412,7 +415,7 @@ class AjaxChat
412
415
  logout_post: @logout_post
413
416
  }
414
417
 
415
- @plugins.each {|plugin| plugin.apply(self) if plugin.respond_to? :apply }
418
+ @plugins.each {|plugin| plugin.apply if plugin.respond_to? :apply }
416
419
 
417
420
  end
418
421
 
@@ -421,7 +424,7 @@ class AjaxChat
421
424
  id, users = @rws.req.session[:session_id].to_s, @chat.users
422
425
 
423
426
  chat = @chat
424
-
427
+
425
428
  # check for new messages to be added via the plugins
426
429
  @plugins.each do |plugin|
427
430
 
@@ -429,12 +432,14 @@ class AjaxChat
429
432
  plugin.messages.each {|x| chat.append_message *x }
430
433
 
431
434
  end
435
+
436
+ plugins = @plugins
432
437
 
433
438
  @chat.chatter(@rws.req, newmsg) do |t, uid, username, msg|
434
439
 
435
- @plugins.each do |plugin|
440
+ plugins.each do |x|
436
441
 
437
- plugin.on_newmesage(t, uid, username, msg) if x.respond_to? :on_newmessage
442
+ x.on_newmessage(t, uid, username, msg) if x.respond_to? :on_newmessage
438
443
 
439
444
  end
440
445
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: h2g_ajaxchat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file