sinatra-rocketio-linda 0.1.4 → 0.2.0
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 +4 -4
- data/History.txt +4 -0
- data/README.md +2 -1
- data/bin/linda-rocketio +39 -40
- data/lib/sinatra/rocketio/linda/version.rb +1 -1
- data/linda.js +1 -1
- data/linda.min.js +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0294f5d3a02665a4a387de3e3881901f5d7f6608
|
4
|
+
data.tar.gz: c09d1bb3e75e86f21f3076970865596362be56f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11388a5aa10b0a23ee081d3ddc12d25bfa5744d2bbb274aba6f2b98aa4368fe0f3e5a3953da9ff145943203b1346b1d9d819527dde0e6cf3b8a5e4cd94fbac59
|
7
|
+
data.tar.gz: 4b29d75a5a3c4b744f00671ca5e40ac7fad9a150a486177ffad010af44f03fdcbf3407e0a05a851df73aa590c47f510ecdf8bf1d1d4364223c32ebf4c260cde3
|
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -151,7 +151,8 @@ linda-rocketio command
|
|
151
151
|
----------------------
|
152
152
|
|
153
153
|
% lidna-rocketio --help
|
154
|
-
% linda-rocketio
|
154
|
+
% linda-rocketio write -tuple '["say","hello"]' -base http://example.com -space test
|
155
|
+
% linda-rocketio read -tuple '["say","hello"]' -base http://example.com -space test
|
155
156
|
|
156
157
|
|
157
158
|
JavaScript Lib for browser
|
data/bin/linda-rocketio
CHANGED
@@ -6,12 +6,9 @@ require 'args_parser'
|
|
6
6
|
$stdout.sync = true
|
7
7
|
|
8
8
|
args = ArgsParser.parse ARGV do
|
9
|
-
arg :
|
10
|
-
arg :
|
11
|
-
arg :
|
12
|
-
arg :watch, 'watch Tuples'
|
13
|
-
arg :base, 'linda base URL', :default => 'http://linda.shokai.org'
|
14
|
-
arg :space, 'linda space name', :default => 'test'
|
9
|
+
arg :tuple, 'tuple(s)'
|
10
|
+
arg :base, 'linda base URL'
|
11
|
+
arg :space, 'linda space name'
|
15
12
|
arg :timeout, 'wait (sec)', :default => 10
|
16
13
|
arg :verbose, 'verbose mode', :alias => :v
|
17
14
|
arg :help, 'show help', :alias => :h
|
@@ -20,10 +17,8 @@ args = ArgsParser.parse ARGV do
|
|
20
17
|
v =~ /^https?:\/\/.+/
|
21
18
|
end
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
JSON.parse v
|
26
|
-
end
|
20
|
+
filter :tuple do |v|
|
21
|
+
JSON.parse v
|
27
22
|
end
|
28
23
|
end
|
29
24
|
|
@@ -47,7 +42,8 @@ end
|
|
47
42
|
|
48
43
|
Console.enable = args.has_option? :verbose
|
49
44
|
|
50
|
-
if args.has_option? :help or !args.has_param?
|
45
|
+
if args.has_option? :help or !args.has_param?(:base, :space) or
|
46
|
+
!["read","write","take","watch"].include?(args.first)
|
51
47
|
bin = $0.split("/").last
|
52
48
|
STDERR.puts "RocketIO::Linda v#{Sinatra::RocketIO::Linda::VERSION}"
|
53
49
|
STDERR.puts " - https://github.com/shokai/sinatra-rocketio-linda"
|
@@ -55,11 +51,11 @@ if args.has_option? :help or !args.has_param? :base, :space
|
|
55
51
|
STDERR.puts args.help
|
56
52
|
STDERR.puts
|
57
53
|
STDERR.puts "e.g."
|
58
|
-
STDERR.puts %Q{write #{bin}
|
59
|
-
STDERR.puts %Q{ echo '["say","hello"]\\n["say","world"]' | #{bin}
|
60
|
-
STDERR.puts %Q{read #{bin}
|
61
|
-
STDERR.puts %Q{take #{bin}
|
62
|
-
STDERR.puts %Q{watch #{bin}
|
54
|
+
STDERR.puts %Q{write #{bin} write -tuple '["say","hello"]' -base http://example.com -space test}
|
55
|
+
STDERR.puts %Q{ echo '["say","hello"]\\n["say","world"]' | #{bin} write -base http://example.com -space test}
|
56
|
+
STDERR.puts %Q{read #{bin} read -tuple '["say"]' -base http://example.com -space test}
|
57
|
+
STDERR.puts %Q{take #{bin} take -tuple '["say"]' -base http://example.com -space test}
|
58
|
+
STDERR.puts %Q{watch #{bin} watch -tuple '["say"]' -base http://example.com -space test}
|
63
59
|
exit 1
|
64
60
|
end
|
65
61
|
|
@@ -69,37 +65,40 @@ ts = linda.tuplespace[ args[:space] ]
|
|
69
65
|
|
70
66
|
linda.io.on :connect do
|
71
67
|
Console.log "connect #{io.session} (#{io.type})"
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
68
|
+
case args.first
|
69
|
+
when "write"
|
70
|
+
if args.has_param? :tuple
|
71
|
+
Console.log "write #{args[:tuple].to_json}"
|
72
|
+
ts.write args[:tuple]
|
73
|
+
exit
|
74
|
+
else
|
75
|
+
while line = STDIN.gets do
|
76
|
+
begin
|
77
|
+
tuple = JSON.parse line.strip
|
78
|
+
Console.log "write #{tuple.to_json}"
|
79
|
+
puts tuple.to_json
|
80
|
+
ts.write tuple
|
81
|
+
rescue => e
|
82
|
+
Console.error e
|
83
|
+
end
|
85
84
|
end
|
85
|
+
exit
|
86
86
|
end
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
ts.read args[:read] do |tuple|
|
87
|
+
when "read"
|
88
|
+
Console.log "read #{args[:tuple].to_json}"
|
89
|
+
ts.read args[:tuple] do |tuple|
|
91
90
|
puts tuple.to_json
|
92
91
|
exit
|
93
92
|
end
|
94
|
-
|
95
|
-
Console.log "take #{args[:
|
96
|
-
ts.take args[:
|
93
|
+
when "take"
|
94
|
+
Console.log "take #{args[:tuple].to_json}"
|
95
|
+
ts.take args[:tuple] do |tuple|
|
97
96
|
puts tuple.to_json
|
98
97
|
exit
|
99
98
|
end
|
100
|
-
|
101
|
-
Console.log "watch #{args[:
|
102
|
-
ts.watch args[:
|
99
|
+
when "watch"
|
100
|
+
Console.log "watch #{args[:tuple].to_json}"
|
101
|
+
ts.watch args[:tuple] do |tuple|
|
103
102
|
puts tuple.to_json
|
104
103
|
end
|
105
104
|
else
|
@@ -115,7 +114,7 @@ Console.log "waiting #{args[:base]}"
|
|
115
114
|
io.connect
|
116
115
|
|
117
116
|
if [Fixnum, Float].include? args[:timeout].class and args[:timeout] > 0 and
|
118
|
-
!args.
|
117
|
+
args.first != "watch" and !(args.first == "write" and !args.has_param?(:tuple))
|
119
118
|
sleep args[:timeout]
|
120
119
|
else
|
121
120
|
linda.wait
|
data/linda.js
CHANGED
data/linda.min.js
CHANGED