orator 0.4.5 → 0.5.1
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,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjgxMWQyODVkNmU4OTZlYTlkNzVhMzM2MWMwYjM1NjZjNmMxN2M0Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjgxMWE5NWEyYjlhZGM1YWIyYjI5MGZlMDAzZGQ0MzE5NzE1MGVmMA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTg5MTYzM2JmOTg2YmFiN2IzMjQ4OGQ0ZDVhOWE1MzU3MjQ5ODk5MzUwN2Uz
|
10
|
+
MzFlNThmNDJlYzNiMDBlYjYwN2VhZjI4OGY0M2QzNzRmNTQ4MzZmYzY2ODI3
|
11
|
+
NDljMDM0Zjc2MGQ1NzU3ZWNmNjRkMWU4ZmI3NWRhZmI5ZDNiOTk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTgyOGViMDY2ZDcxN2RkOThkZjI5MDMxZmMyZjdkNWQ0ODVkNjE4N2RhYTIx
|
14
|
+
ZjllMjA1YzgzOGI1OWJkMjVkZWE3OThkNzEyNzliNmIwODgwYzRhZWY4Mzgx
|
15
|
+
NGE4YWFkMzlhMzUwYzJjZmNmNGU5NzkxYWQ1ZmI3ZmM1OGMwZTM=
|
data/lib/orator.rb
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'oj'
|
4
4
|
require 'set'
|
5
|
-
require 'ostruct'
|
6
5
|
require 'em-websocket'
|
7
6
|
|
8
7
|
require 'orator/base'
|
9
8
|
require 'orator/server'
|
10
9
|
require 'orator/client'
|
11
10
|
require 'orator/version'
|
11
|
+
require 'orator/open_struct'
|
12
12
|
require 'orator/event_handler'
|
13
13
|
require 'orator/middle_ground'
|
14
14
|
|
data/lib/orator/middle_ground.rb
CHANGED
@@ -11,7 +11,7 @@ module Orator
|
|
11
11
|
# Initialize the class.
|
12
12
|
def initialize(client)
|
13
13
|
@client = client
|
14
|
-
@struct = OpenStruct.new
|
14
|
+
@struct = ::Orator::OpenStruct.new
|
15
15
|
end
|
16
16
|
|
17
17
|
# This sends a message to the client.
|
@@ -26,6 +26,8 @@ module Orator
|
|
26
26
|
#
|
27
27
|
# @param event [String, Symbol] the event for the message.
|
28
28
|
# @param data [Hash] the data for the message.
|
29
|
+
#
|
30
|
+
# @return [Hash]
|
29
31
|
def message(event, data)
|
30
32
|
new_data = { "event" => event.to_s }
|
31
33
|
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Orator
|
2
|
+
|
3
|
+
# This provides openstruct-like access to a hash behind the scenes. This
|
4
|
+
# class does not dynamically define methods on itself.
|
5
|
+
#
|
6
|
+
# @!attribute [r] table
|
7
|
+
# The table that the class uses behind the scenes.
|
8
|
+
#
|
9
|
+
# @return [Hash]
|
10
|
+
class OpenStruct
|
11
|
+
|
12
|
+
# Initialize.
|
13
|
+
#
|
14
|
+
# @param hash [Hash] the hash to intialize with.
|
15
|
+
def initialize(hash = {})
|
16
|
+
@table = hash.dup
|
17
|
+
end
|
18
|
+
|
19
|
+
# This provides access to the table without raising an error.
|
20
|
+
#
|
21
|
+
# @param key [Object] the key of the element we're looking for.
|
22
|
+
# @return [Object, nil]
|
23
|
+
def [](key)
|
24
|
+
@table[key.to_s]
|
25
|
+
end
|
26
|
+
|
27
|
+
# This provides access to the table without raising an error.
|
28
|
+
#
|
29
|
+
# @param key [Object] the key of the element we're going to set.
|
30
|
+
# @param value [Object] the element we're going to set the key to.
|
31
|
+
def []=(key, value)
|
32
|
+
@table[key.to_s] = value
|
33
|
+
end
|
34
|
+
|
35
|
+
# This returns the table that we're using.
|
36
|
+
#
|
37
|
+
# @private
|
38
|
+
def table
|
39
|
+
@table.dup
|
40
|
+
end
|
41
|
+
|
42
|
+
# This handles the magic of this class. If the method doesn't end in `=`,
|
43
|
+
# it checks to see if the element exists in the table; if not, it calls
|
44
|
+
# `super`. Otherwise, it sets the value and carries on. It ignores blocks
|
45
|
+
# given to it. If too many arguments are passed, it calls `super`.
|
46
|
+
#
|
47
|
+
# @param method [Symbol] the method to look up.
|
48
|
+
# @param args [Array<Object>]
|
49
|
+
# @return [Object]
|
50
|
+
def method_missing(method, *args)
|
51
|
+
method = method.to_s
|
52
|
+
raise ArgumentError if args.length > 1
|
53
|
+
|
54
|
+
if method =~ /\=\z/
|
55
|
+
self[method[0..-2]] = args[0]
|
56
|
+
else
|
57
|
+
raise ArgumentError if args.length > 0
|
58
|
+
super unless @table.key?(method)
|
59
|
+
self[method]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# This checks to see if we can respond to the method. This is used in
|
64
|
+
# {#respond_to?} to let other objects know we do respond to that method, as
|
65
|
+
# well as ruby internally for the {#method} method.
|
66
|
+
def respond_to_missing?(method, include_private = false)
|
67
|
+
method = method.to_s
|
68
|
+
|
69
|
+
if method =~ /\=\z/
|
70
|
+
true
|
71
|
+
else
|
72
|
+
@table.key?(method)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
data/lib/orator/version.rb
CHANGED
@@ -6,12 +6,12 @@ window.WEB_SOCKET_SWF_LOCATION = "/assets/WebSocketMain.swf"
|
|
6
6
|
|
7
7
|
Orator.setup = (address, routes = ()->)->
|
8
8
|
libs = Orator.Libraries
|
9
|
-
out = { libs: libs }
|
9
|
+
out = { libs: libs, server: null }
|
10
10
|
|
11
|
-
event_handler = new libs.EventHandler(
|
11
|
+
event_handler = new libs.EventHandler(out)
|
12
12
|
console.log(event_handler)
|
13
|
-
|
14
|
-
out.server =
|
13
|
+
socket = new WebSocket(address)
|
14
|
+
out.server = new libs.MiddleGround(socket)
|
15
15
|
routes.apply(event_handler, event_handler)
|
16
16
|
|
17
17
|
socket.onopen = (args...)->
|
@@ -19,7 +19,7 @@ class Orator.Libraries.ChatLogger
|
|
19
19
|
# the default options and set as the class's options.
|
20
20
|
###
|
21
21
|
constructor: (options)->
|
22
|
-
@options = $.extend(true, {}, Orator.Libraries.
|
22
|
+
@options = $.extend(true, {}, Orator.Libraries.ChatLogger.DEFAULT_OPTIONS, options)
|
23
23
|
@format_maps = @options.format_maps || {}
|
24
24
|
|
25
25
|
format_maps: {}
|
@@ -79,10 +79,12 @@ class Orator.Libraries.ChatLogger
|
|
79
79
|
# @see _format for more information on formatting.
|
80
80
|
###
|
81
81
|
to: (element)->
|
82
|
-
@options.formatted_body = _format(@_get_body(), @options.data)
|
82
|
+
@options.formatted_body = @_format(@_get_body(), @options.data)
|
83
83
|
@options.from = @options.sender || @options.data.name || "(unknown)"
|
84
84
|
@options.classes = @_define_classes()
|
85
|
-
_format(@cl_opts.format, @options)
|
85
|
+
out = @_format(@cl_opts.format, @options)
|
86
|
+
|
87
|
+
element.append(out)
|
86
88
|
|
87
89
|
###
|
88
90
|
# Defines the classes to be used by the element.
|
@@ -160,7 +162,7 @@ class Orator.Libraries.ChatLogger
|
|
160
162
|
# from ESCAPE_CHARS.
|
161
163
|
###
|
162
164
|
_escape: (data)->
|
163
|
-
(data || "").replace @ESCAPE_REGEX, (s)
|
165
|
+
(data || "").replace @ESCAPE_REGEX, (s)=>
|
164
166
|
@ESCAPE_CHARS[s]
|
165
167
|
|
166
168
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Rodi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-websocket
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- lib/orator/server.rb
|
81
81
|
- lib/orator/cli.rb
|
82
82
|
- lib/orator/client.rb
|
83
|
+
- lib/orator/open_struct.rb
|
83
84
|
- lib/orator/engine.rb
|
84
85
|
- lib/orator/base.rb
|
85
86
|
- lib/orator/event_handler.rb
|