legs 0.6.3 → 0.6.4
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.
- data/legs.gemspec +2 -2
- data/lib/legs.rb +13 -8
- metadata +30 -50
data/legs.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "legs"
|
3
|
-
s.version = "0.6.
|
4
|
-
s.date = "
|
3
|
+
s.version = "0.6.4"
|
4
|
+
s.date = "2012-08-24"
|
5
5
|
s.summary = "Simple fun open networking for newbies and quick hacks"
|
6
6
|
s.email = "a@creativepony.com"
|
7
7
|
s.homepage = "http://github.com/Bluebie/legs"
|
data/lib/legs.rb
CHANGED
@@ -7,10 +7,9 @@ class Legs
|
|
7
7
|
attr_reader :socket, :parent, :meta
|
8
8
|
def inspect; "<Legs:#{object_id} Meta: #{@meta.inspect}>"; end
|
9
9
|
|
10
|
-
# Legs.new for a client
|
10
|
+
# Legs.new for a client connected to some other legs server
|
11
11
|
def initialize(host = 'localhost', port = 30274)
|
12
12
|
self.class.start(port) if self.class != Legs && !self.class.started?
|
13
|
-
ObjectSpace.define_finalizer(self) { self.close! }
|
14
13
|
@parent = false; @responses = Hash.new; @meta = {}; @disconnected = false
|
15
14
|
@responses_mutex = Mutex.new; @socket_mutex = Mutex.new
|
16
15
|
|
@@ -205,12 +204,13 @@ class << Legs
|
|
205
204
|
attr_reader :incoming, :outgoing, :server_object, :incoming_mutex, :outgoing_mutex, :messages_mutex
|
206
205
|
alias_method :log?, :log
|
207
206
|
alias_method :users, :incoming
|
208
|
-
def started?; @started; end
|
207
|
+
def started?; @state[:started]; end
|
209
208
|
|
210
209
|
def initializer
|
211
|
-
ObjectSpace.define_finalizer(self) { self.stop! }
|
212
210
|
@incoming = []; @outgoing = []; @messages = Queue.new; @terminator = "\n"; @log = false
|
213
|
-
@incoming_mutex = Mutex.new; @outgoing_mutex = Mutex.new; @
|
211
|
+
@incoming_mutex = Mutex.new; @outgoing_mutex = Mutex.new; @state = { :started => false}
|
212
|
+
|
213
|
+
ObjectSpace.define_finalizer(self) { self.class.finalize(@incoming, @state) }
|
214
214
|
end
|
215
215
|
|
216
216
|
|
@@ -218,7 +218,7 @@ class << Legs
|
|
218
218
|
# This is useful for adding methods to Legs so that systems you connect to can call methods back on you
|
219
219
|
def start(port=30274, &blk)
|
220
220
|
return @server_class.module_eval(&blk) if started? and blk.respond_to? :call
|
221
|
-
@started = true
|
221
|
+
@state[:started] = true
|
222
222
|
|
223
223
|
# makes a nice clean class to hold all the server methods.
|
224
224
|
if @server_class.nil?
|
@@ -326,8 +326,13 @@ class << Legs
|
|
326
326
|
|
327
327
|
# stops the server, disconnects the clients
|
328
328
|
def stop
|
329
|
-
@
|
330
|
-
|
329
|
+
self.class.finalize(@incoming, @state)
|
330
|
+
end
|
331
|
+
|
332
|
+
# implemented on class to work around enclosure stuff with object finalizer
|
333
|
+
def self.finalize(incoming, state)
|
334
|
+
state[:started] = false
|
335
|
+
incoming.each { |user| user.close! }
|
331
336
|
end
|
332
337
|
|
333
338
|
# returns an array of all connections
|
metadata
CHANGED
@@ -1,46 +1,35 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: legs
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 6
|
8
|
-
- 3
|
9
|
-
version: 0.6.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.4
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Jenna Fox
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-08-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: json_pure
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70177970878240 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 1
|
31
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>'
|
20
|
+
- !ruby/object:Gem::Version
|
32
21
|
version: 1.1.0
|
33
22
|
type: :runtime
|
34
|
-
|
35
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70177970878240
|
25
|
+
description: Legs is a really simple fun networking library that uses 'json-rpc' formated
|
26
|
+
messages over a tcp connection to really easily built peery or server-clienty sorts
|
27
|
+
of apps, for ruby newbies and hackers to build fun little things.
|
36
28
|
email: a@creativepony.com
|
37
29
|
executables: []
|
38
|
-
|
39
30
|
extensions: []
|
40
|
-
|
41
31
|
extra_rdoc_files: []
|
42
|
-
|
43
|
-
files:
|
32
|
+
files:
|
44
33
|
- README.rdoc
|
45
34
|
- legs.gemspec
|
46
35
|
- lib/legs.rb
|
@@ -48,37 +37,28 @@ files:
|
|
48
37
|
- examples/chat-server.rb
|
49
38
|
- examples/shoes-chat-client.rb
|
50
39
|
- test/test_legs.rb
|
51
|
-
has_rdoc: true
|
52
40
|
homepage: http://github.com/Bluebie/legs
|
53
41
|
licenses: []
|
54
|
-
|
55
42
|
post_install_message:
|
56
43
|
rdoc_options: []
|
57
|
-
|
58
|
-
require_paths:
|
44
|
+
require_paths:
|
59
45
|
- lib
|
60
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
47
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
66
|
-
|
67
|
-
version: "0"
|
68
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
53
|
none: false
|
70
|
-
requirements:
|
71
|
-
- -
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
|
74
|
-
- 0
|
75
|
-
version: "0"
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
76
58
|
requirements: []
|
77
|
-
|
78
59
|
rubyforge_project:
|
79
|
-
rubygems_version: 1.
|
60
|
+
rubygems_version: 1.8.11
|
80
61
|
signing_key:
|
81
62
|
specification_version: 3
|
82
63
|
summary: Simple fun open networking for newbies and quick hacks
|
83
64
|
test_files: []
|
84
|
-
|