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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31a118c0a7dd050df9ff68429e62d871f841eab1
4
- data.tar.gz: 1e6aefe006ff873c1bee490bd0dcfae4e2a53129
3
+ metadata.gz: 0294f5d3a02665a4a387de3e3881901f5d7f6608
4
+ data.tar.gz: c09d1bb3e75e86f21f3076970865596362be56f0
5
5
  SHA512:
6
- metadata.gz: 6afcf2504b94e184e810a57eb61f5f96ea8390ff8a454fd47f142d6aec9021c68a687deab263f42f510420fabe6f7e424163002b67f6a422b30d3ed8ec33240e
7
- data.tar.gz: 96e4efa069b6b9e6ebc717696ebfa04aeac411056804afd09c4618f90f57f1120ad9c7ce0d0699bd8e5f0cf5b54533246bc9ef87fa00620c287c8590f99b11e0
6
+ metadata.gz: 11388a5aa10b0a23ee081d3ddc12d25bfa5744d2bbb274aba6f2b98aa4368fe0f3e5a3953da9ff145943203b1346b1d9d819527dde0e6cf3b8a5e4cd94fbac59
7
+ data.tar.gz: 4b29d75a5a3c4b744f00671ca5e40ac7fad9a150a486177ffad010af44f03fdcbf3407e0a05a851df73aa590c47f510ecdf8bf1d1d4364223c32ebf4c260cde3
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.2.0 2013-06-10
2
+
3
+ * changed linda-rocketio command options
4
+
1
5
  === 0.1.4 2013-06-09
2
6
 
3
7
  * bugfix linda-rocketio command
data/README.md CHANGED
@@ -151,7 +151,8 @@ linda-rocketio command
151
151
  ----------------------
152
152
 
153
153
  % lidna-rocketio --help
154
- % linda-rocketio --write '["say","hello"]' --base http://example.com --space test
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 :write, 'write Tuple(s)'
10
- arg :read, 'read a Tuple'
11
- arg :take, 'take a Tuple'
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
- [:write, :read, :take, :watch].each do |arg|
24
- filter arg do |v|
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? :base, :space
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} --base http://example.com --space test --write '["say","hello"]'}
59
- STDERR.puts %Q{ echo '["say","hello"]\\n["say","world"]' | #{bin} --base http://example.com --space test --write}
60
- STDERR.puts %Q{read #{bin} --base http://example.com --space test --read '["say"]'}
61
- STDERR.puts %Q{take #{bin} --base http://example.com --space test --take '["say"]'}
62
- STDERR.puts %Q{watch #{bin} --base http://example.com --space test --watch '["say"]'}
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
- if args.has_param? :write
73
- Console.log "write #{args[:write].to_json}"
74
- ts.write args[:write]
75
- exit
76
- elsif args.has_option? :write
77
- while line = STDIN.gets do
78
- begin
79
- tuple = JSON.parse line.strip
80
- Console.log "write #{tuple.to_json}"
81
- puts tuple.to_json
82
- ts.write tuple
83
- rescue => e
84
- Console.error e
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
- exit
88
- elsif args.has_param? :read
89
- Console.log "read #{args[:read].to_json}"
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
- elsif args.has_param? :take
95
- Console.log "take #{args[:take].to_json}"
96
- ts.take args[:take] do |tuple|
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
- elsif args.has_param? :watch
101
- Console.log "watch #{args[:watch].to_json}"
102
- ts.watch args[:watch] do |tuple|
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.has_option?(:write) and !args.has_param?(:watch)
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
@@ -1,7 +1,7 @@
1
1
  module Sinatra
2
2
  module RocketIO
3
3
  module Linda
4
- VERSION = "0.1.4"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
7
7
  end
data/linda.js CHANGED
@@ -1,4 +1,4 @@
1
- // Linda.js v0.1.4 (rocketio v0.2.6)
1
+ // Linda.js v0.2.0 (rocketio v0.2.6)
2
2
  // https://github.com/shokai/sinatra-rocketio-linda
3
3
  // (c) 2013 Sho Hashimoto <hashimoto@shokai.org>
4
4
  // The MIT License
data/linda.min.js CHANGED
@@ -1,4 +1,4 @@
1
- // Linda.js v0.1.4 (rocketio v0.2.6)
1
+ // Linda.js v0.2.0 (rocketio v0.2.6)
2
2
  // https://github.com/shokai/sinatra-rocketio-linda
3
3
  // (c) 2013 Sho Hashimoto <hashimoto@shokai.org>
4
4
  // The MIT License
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-rocketio-linda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Hashimoto