jschat 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +23 -0
- data/README.textile +71 -0
- data/bin/jschat-client +3 -0
- data/bin/jschat-server +18 -0
- data/bin/jschat-web +7 -0
- data/lib/jschat/client.rb +745 -0
- data/lib/jschat/errors.rb +41 -0
- data/lib/jschat/flood_protection.rb +39 -0
- data/lib/jschat/http/config/sprockets.yml +7 -0
- data/lib/jschat/http/config.ru +12 -0
- data/lib/jschat/http/jschat.rb +264 -0
- data/lib/jschat/http/public/favicon.ico +0 -0
- data/lib/jschat/http/public/images/emoticons/angry.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/arr.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/blink.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/blush.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/brucelee.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/btw.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/chuckle.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/clap.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/cool.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/drool.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/drunk.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/dry.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/eek.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/flex.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/happy.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/holmes.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/huh.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/laugh.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/lol.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/mad.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/mellow.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/noclue.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/oh.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/ohmy.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/ph34r.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/pimp.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/punch.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/realmad.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/rock.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/rofl.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/rolleyes.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/sad.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/scratch.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/shifty.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/shock.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/shrug.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/sleep.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/sleeping.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/smile.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/suicide.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/sweat.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/thumbs.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/tongue.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/unsure.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/w00t.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/wacko.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/whistling.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/wink.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/worship.gif +0 -0
- data/lib/jschat/http/public/images/emoticons/yucky.gif +0 -0
- data/lib/jschat/http/public/images/jschat.gif +0 -0
- data/lib/jschat/http/public/images/shadow.png +0 -0
- data/lib/jschat/http/public/javascripts/app/controllers/chat_controller.js +191 -0
- data/lib/jschat/http/public/javascripts/app/controllers/signon_controller.js +56 -0
- data/lib/jschat/http/public/javascripts/app/helpers/emote_helper.js +23 -0
- data/lib/jschat/http/public/javascripts/app/helpers/form_helpers.js +37 -0
- data/lib/jschat/http/public/javascripts/app/helpers/link_helper.js +47 -0
- data/lib/jschat/http/public/javascripts/app/helpers/page_helper.js +27 -0
- data/lib/jschat/http/public/javascripts/app/helpers/text_helper.js +92 -0
- data/lib/jschat/http/public/javascripts/app/lib/split.js +78 -0
- data/lib/jschat/http/public/javascripts/app/models/cookie.js +27 -0
- data/lib/jschat/http/public/javascripts/app/protocol/change.js +15 -0
- data/lib/jschat/http/public/javascripts/app/protocol/chat_request.js +13 -0
- data/lib/jschat/http/public/javascripts/app/protocol/display.js +147 -0
- data/lib/jschat/http/public/javascripts/app/ui/commands.js +55 -0
- data/lib/jschat/http/public/javascripts/app/ui/tab_completion.js +122 -0
- data/lib/jschat/http/public/javascripts/init.js +19 -0
- data/lib/jschat/http/public/stylesheets/iphone.css +3 -0
- data/lib/jschat/http/public/stylesheets/screen.css +68 -0
- data/lib/jschat/http/script/sprockets.rb +14 -0
- data/lib/jschat/http/tmp/restart.txt +0 -0
- data/lib/jschat/http/views/index.erb +23 -0
- data/lib/jschat/http/views/iphone.erb +29 -0
- data/lib/jschat/http/views/layout.erb +29 -0
- data/lib/jschat/http/views/message_form.erb +15 -0
- data/lib/jschat/server.rb +503 -0
- data/test/server_test.rb +175 -0
- data/test/stateless_test.rb +33 -0
- data/test/test_helper.rb +61 -0
- metadata +223 -0
data/test/test_helper.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'eventmachine'
|
4
|
+
require 'json'
|
5
|
+
require File.join(File.dirname(__FILE__), '../', 'jschat.rb')
|
6
|
+
|
7
|
+
ServerConfig = {
|
8
|
+
:max_message_length => 500
|
9
|
+
}
|
10
|
+
|
11
|
+
class JsChat::Room
|
12
|
+
def self.reset
|
13
|
+
@@rooms = nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module JsChatHelpers
|
18
|
+
def identify_as(name, channel = nil)
|
19
|
+
if @cookie
|
20
|
+
result = @jschat.receive_line({ 'identify' => name, :cookie => @cookie }.to_json)
|
21
|
+
result = @jschat.receive_line({ 'join' => channel, :cookie => @cookie }.to_json) if channel
|
22
|
+
else
|
23
|
+
result = @jschat.receive_line({ 'identify' => name }.to_json)
|
24
|
+
result = @jschat.receive_line({ 'join' => channel }.to_json) if channel
|
25
|
+
end
|
26
|
+
result
|
27
|
+
end
|
28
|
+
|
29
|
+
def send_to_jschat(h, parse = true)
|
30
|
+
response = @jschat.receive_line(h.to_json)
|
31
|
+
parse ? JSON.parse(response) : response
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class JsChatMock
|
36
|
+
include JsChat
|
37
|
+
|
38
|
+
def get_remote_ip
|
39
|
+
''
|
40
|
+
end
|
41
|
+
|
42
|
+
def send_data(data)
|
43
|
+
data
|
44
|
+
end
|
45
|
+
|
46
|
+
def reset
|
47
|
+
@@users = nil
|
48
|
+
@user = nil
|
49
|
+
Room.reset
|
50
|
+
end
|
51
|
+
|
52
|
+
# Helper for testing
|
53
|
+
def add_user(name, room_name)
|
54
|
+
room = Room.find_or_create room_name
|
55
|
+
user = User.new self
|
56
|
+
user.name = name
|
57
|
+
user.rooms << room
|
58
|
+
@@users << user
|
59
|
+
room.users << user
|
60
|
+
end
|
61
|
+
end
|
metadata
ADDED
@@ -0,0 +1,223 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jschat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Alex R. Young
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-03-21 00:00:00 +00:00
|
18
|
+
default_executable: bin/jschat-server
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: sinatra
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 9
|
30
|
+
- 4
|
31
|
+
version: 0.9.4
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: json
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 1
|
43
|
+
- 1
|
44
|
+
- 9
|
45
|
+
version: 1.1.9
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: sprockets
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 1
|
57
|
+
- 0
|
58
|
+
- 2
|
59
|
+
version: 1.0.2
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: eventmachine
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
- 12
|
72
|
+
- 8
|
73
|
+
version: 0.12.8
|
74
|
+
type: :runtime
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: ncurses
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
- 9
|
86
|
+
- 1
|
87
|
+
version: 0.9.1
|
88
|
+
type: :runtime
|
89
|
+
version_requirements: *id005
|
90
|
+
description: JsChat is a JSON-based web and console chat app.
|
91
|
+
email: alex@alexyoung.org
|
92
|
+
executables:
|
93
|
+
- jschat-server
|
94
|
+
- jschat-client
|
95
|
+
- jschat-web
|
96
|
+
extensions: []
|
97
|
+
|
98
|
+
extra_rdoc_files: []
|
99
|
+
|
100
|
+
files:
|
101
|
+
- bin/jschat-client
|
102
|
+
- bin/jschat-server
|
103
|
+
- bin/jschat-web
|
104
|
+
- lib/jschat/client.rb
|
105
|
+
- lib/jschat/errors.rb
|
106
|
+
- lib/jschat/flood_protection.rb
|
107
|
+
- lib/jschat/http/config/sprockets.yml
|
108
|
+
- lib/jschat/http/config.ru
|
109
|
+
- lib/jschat/http/jschat.rb
|
110
|
+
- lib/jschat/http/public/favicon.ico
|
111
|
+
- lib/jschat/http/public/images/emoticons/angry.gif
|
112
|
+
- lib/jschat/http/public/images/emoticons/arr.gif
|
113
|
+
- lib/jschat/http/public/images/emoticons/blink.gif
|
114
|
+
- lib/jschat/http/public/images/emoticons/blush.gif
|
115
|
+
- lib/jschat/http/public/images/emoticons/brucelee.gif
|
116
|
+
- lib/jschat/http/public/images/emoticons/btw.gif
|
117
|
+
- lib/jschat/http/public/images/emoticons/chuckle.gif
|
118
|
+
- lib/jschat/http/public/images/emoticons/clap.gif
|
119
|
+
- lib/jschat/http/public/images/emoticons/cool.gif
|
120
|
+
- lib/jschat/http/public/images/emoticons/drool.gif
|
121
|
+
- lib/jschat/http/public/images/emoticons/drunk.gif
|
122
|
+
- lib/jschat/http/public/images/emoticons/dry.gif
|
123
|
+
- lib/jschat/http/public/images/emoticons/eek.gif
|
124
|
+
- lib/jschat/http/public/images/emoticons/flex.gif
|
125
|
+
- lib/jschat/http/public/images/emoticons/happy.gif
|
126
|
+
- lib/jschat/http/public/images/emoticons/holmes.gif
|
127
|
+
- lib/jschat/http/public/images/emoticons/huh.gif
|
128
|
+
- lib/jschat/http/public/images/emoticons/laugh.gif
|
129
|
+
- lib/jschat/http/public/images/emoticons/lol.gif
|
130
|
+
- lib/jschat/http/public/images/emoticons/mad.gif
|
131
|
+
- lib/jschat/http/public/images/emoticons/mellow.gif
|
132
|
+
- lib/jschat/http/public/images/emoticons/noclue.gif
|
133
|
+
- lib/jschat/http/public/images/emoticons/oh.gif
|
134
|
+
- lib/jschat/http/public/images/emoticons/ohmy.gif
|
135
|
+
- lib/jschat/http/public/images/emoticons/ph34r.gif
|
136
|
+
- lib/jschat/http/public/images/emoticons/pimp.gif
|
137
|
+
- lib/jschat/http/public/images/emoticons/punch.gif
|
138
|
+
- lib/jschat/http/public/images/emoticons/realmad.gif
|
139
|
+
- lib/jschat/http/public/images/emoticons/rock.gif
|
140
|
+
- lib/jschat/http/public/images/emoticons/rofl.gif
|
141
|
+
- lib/jschat/http/public/images/emoticons/rolleyes.gif
|
142
|
+
- lib/jschat/http/public/images/emoticons/sad.gif
|
143
|
+
- lib/jschat/http/public/images/emoticons/scratch.gif
|
144
|
+
- lib/jschat/http/public/images/emoticons/shifty.gif
|
145
|
+
- lib/jschat/http/public/images/emoticons/shock.gif
|
146
|
+
- lib/jschat/http/public/images/emoticons/shrug.gif
|
147
|
+
- lib/jschat/http/public/images/emoticons/sleep.gif
|
148
|
+
- lib/jschat/http/public/images/emoticons/sleeping.gif
|
149
|
+
- lib/jschat/http/public/images/emoticons/smile.gif
|
150
|
+
- lib/jschat/http/public/images/emoticons/suicide.gif
|
151
|
+
- lib/jschat/http/public/images/emoticons/sweat.gif
|
152
|
+
- lib/jschat/http/public/images/emoticons/thumbs.gif
|
153
|
+
- lib/jschat/http/public/images/emoticons/tongue.gif
|
154
|
+
- lib/jschat/http/public/images/emoticons/unsure.gif
|
155
|
+
- lib/jschat/http/public/images/emoticons/w00t.gif
|
156
|
+
- lib/jschat/http/public/images/emoticons/wacko.gif
|
157
|
+
- lib/jschat/http/public/images/emoticons/whistling.gif
|
158
|
+
- lib/jschat/http/public/images/emoticons/wink.gif
|
159
|
+
- lib/jschat/http/public/images/emoticons/worship.gif
|
160
|
+
- lib/jschat/http/public/images/emoticons/yucky.gif
|
161
|
+
- lib/jschat/http/public/images/jschat.gif
|
162
|
+
- lib/jschat/http/public/images/shadow.png
|
163
|
+
- lib/jschat/http/public/javascripts/app/controllers/chat_controller.js
|
164
|
+
- lib/jschat/http/public/javascripts/app/controllers/signon_controller.js
|
165
|
+
- lib/jschat/http/public/javascripts/app/helpers/emote_helper.js
|
166
|
+
- lib/jschat/http/public/javascripts/app/helpers/form_helpers.js
|
167
|
+
- lib/jschat/http/public/javascripts/app/helpers/link_helper.js
|
168
|
+
- lib/jschat/http/public/javascripts/app/helpers/page_helper.js
|
169
|
+
- lib/jschat/http/public/javascripts/app/helpers/text_helper.js
|
170
|
+
- lib/jschat/http/public/javascripts/app/lib/split.js
|
171
|
+
- lib/jschat/http/public/javascripts/app/models/cookie.js
|
172
|
+
- lib/jschat/http/public/javascripts/app/protocol/change.js
|
173
|
+
- lib/jschat/http/public/javascripts/app/protocol/chat_request.js
|
174
|
+
- lib/jschat/http/public/javascripts/app/protocol/display.js
|
175
|
+
- lib/jschat/http/public/javascripts/app/ui/commands.js
|
176
|
+
- lib/jschat/http/public/javascripts/app/ui/tab_completion.js
|
177
|
+
- lib/jschat/http/public/javascripts/init.js
|
178
|
+
- lib/jschat/http/public/stylesheets/iphone.css
|
179
|
+
- lib/jschat/http/public/stylesheets/screen.css
|
180
|
+
- lib/jschat/http/script/sprockets.rb
|
181
|
+
- lib/jschat/http/tmp/restart.txt
|
182
|
+
- lib/jschat/http/views/index.erb
|
183
|
+
- lib/jschat/http/views/iphone.erb
|
184
|
+
- lib/jschat/http/views/layout.erb
|
185
|
+
- lib/jschat/http/views/message_form.erb
|
186
|
+
- lib/jschat/server.rb
|
187
|
+
- test/server_test.rb
|
188
|
+
- test/stateless_test.rb
|
189
|
+
- test/test_helper.rb
|
190
|
+
- README.textile
|
191
|
+
- MIT-LICENSE
|
192
|
+
has_rdoc: false
|
193
|
+
homepage: http://github.com/alexyoung/jschat
|
194
|
+
licenses: []
|
195
|
+
|
196
|
+
post_install_message:
|
197
|
+
rdoc_options: []
|
198
|
+
|
199
|
+
require_paths:
|
200
|
+
- lib
|
201
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
202
|
+
requirements:
|
203
|
+
- - ">="
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
segments:
|
206
|
+
- 0
|
207
|
+
version: "0"
|
208
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
|
+
requirements:
|
210
|
+
- - ">="
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
segments:
|
213
|
+
- 0
|
214
|
+
version: "0"
|
215
|
+
requirements: []
|
216
|
+
|
217
|
+
rubyforge_project:
|
218
|
+
rubygems_version: 1.3.6
|
219
|
+
signing_key:
|
220
|
+
specification_version: 3
|
221
|
+
summary: JsChat features a chat server, client and web app.
|
222
|
+
test_files: []
|
223
|
+
|