h2g_ajaxchat 0.3.1 → 0.3.2

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: fed7c95dd7baa7e075472ce965f71916083e8f662a269292ef90bf195b89c1bc
4
- data.tar.gz: 104cbd2876daee33558effccd165653bba0bcfd4ca4e691afcb67b257ab488df
3
+ metadata.gz: 941e2d26eb4eb2933c760bfc321214f8278f2e6266f94a35b5bcfcf969c6e369
4
+ data.tar.gz: b9ec8471271d3dfee2d5316376e8889b71be9abb9fce803ed5698e150692d1df
5
5
  SHA512:
6
- metadata.gz: b38375b60ea5ae5fac4040e0136e59ae62af25b457ff207feb4f43f397d2296a56fa75a0b4dbcfe670df62f8e3dc537b9871be78c54ae5095ce351d262fbcfaf
7
- data.tar.gz: 3b8a18a0c8d2240de2947b497d90203f74418ff75f8f2eb3972924f488360969117debf8d49d51b2f1eaee659ad03866667da47a7bd55887868451064f0e334e
6
+ metadata.gz: 51e2850f810132d03cfa9f71b2ff69e787ea1aaae16df17ffb327cae97672c8dbc4d33410c4dae131c43ed1e025d7a6a05380b426a5c1382511888786e269a56
7
+ data.tar.gz: 2e0f56b8e26b60accb24d4aabf5e60acdef9f1a8b731a5b795d9861e0cb3ba6bc083ddccf613b853f95678d75a73d0d76d89f522a109e8a2c8f49915906ea844
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -10,6 +10,7 @@ require 'simple-config'
10
10
 
11
11
  # This file includes the following classes
12
12
  #
13
+ # * AjaxChatPlugin Base class for plugins
13
14
  # * DummyRequest (used for testing)
14
15
  # * ChatCore (chat engine)
15
16
  # * DummyRws (used for testing)
@@ -18,9 +19,31 @@ require 'simple-config'
18
19
  # * Login < WebPage
19
20
  # * Logout < WebPage
20
21
  # * LogoutPost < WebPage
21
- # * AjaxChat
22
+ # * AjaxChat (the main class)
22
23
 
23
24
 
25
+ class AjaxChatPlugin
26
+
27
+ def initialize(settings={})
28
+ end
29
+
30
+ # Customises the ajax chat html etc; ac = ajaxchat object
31
+ #
32
+ def apply(ac)
33
+ end
34
+
35
+ # messages from the plugin to be added to the chat timeline
36
+ #
37
+ def messages()
38
+ []
39
+ end
40
+
41
+ # messages from the chat timeline
42
+ #
43
+ def on_newmessage(*a)
44
+ end
45
+ end
46
+
24
47
  class DummyRequest
25
48
 
26
49
  def initialize()
@@ -136,20 +159,23 @@ end
136
159
 
137
160
  class WebPage
138
161
 
139
- attr_reader :name
140
162
  attr_accessor :css, :html, :js, :s
141
163
 
142
- def initialize(name, h={} )
143
- @h, @name = h, name
164
+ def initialize( h={} )
165
+ @h = h
144
166
  end
145
167
 
146
168
  def to_css()
147
169
  end
148
170
 
149
171
  def to_html()
172
+ b = binding
173
+
174
+ ERB.new(html()).result(b)
150
175
  end
151
176
 
152
177
  def to_js()
178
+ js()
153
179
  end
154
180
 
155
181
  def s()
@@ -157,7 +183,7 @@ class WebPage
157
183
  end
158
184
 
159
185
  def to_s()
160
- @s
186
+ s()
161
187
  end
162
188
 
163
189
  protected
@@ -189,7 +215,7 @@ end
189
215
  class Index < WebPage
190
216
 
191
217
  def initialize(h)
192
- @name, @h = :index, h
218
+ @h = h
193
219
  end
194
220
 
195
221
  def html()
@@ -220,9 +246,7 @@ div p span {colour: #dde}
220
246
 
221
247
  def to_html()
222
248
 
223
- b = binding
224
-
225
- ERB.new(@html).result(b)
249
+ super()
226
250
  end
227
251
 
228
252
  def js()
@@ -276,16 +300,13 @@ EOF
276
300
 
277
301
  end
278
302
 
279
- def to_js()
280
- @js
281
- end
282
303
 
283
304
  end
284
305
 
285
306
  class Login < WebPage
286
307
 
287
- def initialize(h)
288
- @name = :login
308
+ def initialize(h={})
309
+
289
310
  end
290
311
 
291
312
  def html()
@@ -303,16 +324,13 @@ class Login < WebPage
303
324
 
304
325
  end
305
326
 
306
- def to_html()
307
- @html
308
- end
309
327
 
310
328
  end
311
329
 
312
330
  class Logout < WebPage
313
331
 
314
- def initialize(h)
315
- @name = :logout
332
+ def initialize(h={})
333
+
316
334
  end
317
335
 
318
336
  def html()
@@ -329,16 +347,13 @@ class Logout < WebPage
329
347
 
330
348
  end
331
349
 
332
- def to_html()
333
- @html
334
- end
335
350
 
336
351
  end
337
352
 
338
353
  class LogoutPost < WebPage
339
354
 
340
- def initialize(h)
341
- @name = :logout_post
355
+ def initialize(h={})
356
+
342
357
  end
343
358
 
344
359
  def s()
@@ -346,10 +361,7 @@ class LogoutPost < WebPage
346
361
  @s ||= 'You have successfully logged out'
347
362
 
348
363
  end
349
-
350
- def to_s()
351
- @s
352
- end
364
+
353
365
 
354
366
  end
355
367
 
@@ -358,21 +370,25 @@ class AjaxChat
358
370
 
359
371
  attr_reader :rws, :views
360
372
 
361
- def initialize(chatobj, rws=DummyRws.new(self), config: nil, debug: false)
373
+ def initialize(chatobj=ChatCore.new, rws: DummyRws.new(self), config: nil,
374
+ debug: false)
362
375
 
363
376
  @chat, @rws, @debug = chatobj, rws, debug
364
377
 
365
- plugins = if config then
378
+ @plugins = if config then
366
379
 
367
380
  SimpleConfig.new(config).to_h.map do |name, settings|
381
+
368
382
  puts 'name: ' + name.inspect if @debug
369
383
  settings = {} if settings.is_a? String
370
384
 
385
+ next if settings[:disabled]
371
386
  pluginklass_name = 'AjaxChatPlugin' + name.to_s
372
387
 
373
- Kernel.const_get(pluginklass_name).new(settings)
388
+ #Kernel.const_get(pluginklass_name).new(settings)
389
+ eval("#{pluginklass_name}.new(#{settings})")
374
390
 
375
- end
391
+ end.compact
376
392
 
377
393
  else
378
394
 
@@ -396,7 +412,7 @@ class AjaxChat
396
412
  logout_post: @logout_post
397
413
  }
398
414
 
399
- plugins.each {|plugin| plugin.apply(self) if plugin.respond_to? :apply }
415
+ @plugins.each {|plugin| plugin.apply(self) if plugin.respond_to? :apply }
400
416
 
401
417
  end
402
418
 
@@ -417,12 +433,8 @@ class AjaxChat
417
433
  @chat.chatter(@rws.req, newmsg) do |t, uid, username, msg|
418
434
 
419
435
  @plugins.each do |plugin|
420
-
421
- plugin.messages.each do |x|
422
-
423
- x.on_newmesage(t, uid, username, msg) if x.respond_to? :on_newmessage
424
-
425
- end
436
+
437
+ plugin.on_newmesage(t, uid, username, msg) if x.respond_to? :on_newmessage
426
438
 
427
439
  end
428
440
 
@@ -480,7 +492,7 @@ class AjaxChat
480
492
 
481
493
  end
482
494
 
483
- # user for debugging
495
+ # used for debugging
484
496
  def messages()
485
497
  @chat.messages
486
498
  end
@@ -492,7 +504,7 @@ class AjaxChat
492
504
 
493
505
  end
494
506
 
495
- # user for debugging
507
+ # used for debugging
496
508
  def users()
497
509
  @chat.users
498
510
  end
@@ -501,6 +513,8 @@ class AjaxChat
501
513
 
502
514
  def view(obj)
503
515
 
516
+ puts 'inside view obj: ' + obj.inspect if @debug
517
+
504
518
  if obj.to_s.length > 0 then
505
519
  obj.to_s
506
520
  else
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.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,28 +35,28 @@ cert_chain:
35
35
  PrknRa5wCOkWn6MNeaZ10MuRCv0E4IRGb8q/2WczGDXI3lmwDWOzPzia3/A32vdt
36
36
  hlwWFeE0gWND9J9tivS5qxBI
37
37
  -----END CERTIFICATE-----
38
- date: 2020-07-05 00:00:00.000000000 Z
38
+ date: 2020-07-06 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: simple-config
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '0.6'
47
44
  - - ">="
48
45
  - !ruby/object:Gem::Version
49
- version: 0.6.4
46
+ version: 0.7.0
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.7'
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - "~>"
55
- - !ruby/object:Gem::Version
56
- version: '0.6'
57
54
  - - ">="
58
55
  - !ruby/object:Gem::Version
59
- version: 0.6.4
56
+ version: 0.7.0
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '0.7'
60
60
  description:
61
61
  email: james@jamesrobertson.eu
62
62
  executables: []
metadata.gz.sig CHANGED
Binary file