minep-request 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +1 -0
- data/bin/{mine-request → minep-request} +1 -4
- data/lib/minep-request/requests.rb +28 -6
- data/lib/minep-request/version.rb +1 -1
- metadata +4 -5
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -19,6 +19,7 @@ The known commands are :
|
|
19
19
|
- exit : Disconnect and quit the program
|
20
20
|
- help : Show the list of the commands
|
21
21
|
- insert : Send an INSERT request
|
22
|
+
- load : Send a LOAD request
|
22
23
|
- move : Send a MOVE request
|
23
24
|
- quit : Disconnect and quit the program
|
24
25
|
- signup : Send a SIGNUP request
|
@@ -1,8 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# lib = "lib"
|
4
|
-
# $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
|
6
3
|
require 'optparse'
|
7
4
|
require 'socket'
|
8
5
|
require 'WEBSocket'
|
@@ -23,7 +20,7 @@ $commands = {
|
|
23
20
|
"move" => Proc.new { |s| Minep::Request.move s},
|
24
21
|
"backspace" => Proc.new { |s| Minep::Request.backspace s},
|
25
22
|
"delete" => Proc.new { |s| Minep::Request.delete s},
|
26
|
-
"
|
23
|
+
"load" => Proc.new { |s| Minep::Request.load s, $options[:type]},
|
27
24
|
"help" => Proc.new { |s| help s},
|
28
25
|
"exit" => Proc.new { |s| quit s},
|
29
26
|
"quit" => Proc.new { |s| quit s}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'minep-request/minep'
|
2
|
+
|
1
3
|
module Minep
|
2
4
|
module Request
|
3
5
|
CommandsInfo ||= {
|
@@ -8,7 +10,7 @@ module Minep
|
|
8
10
|
"move" => "Send a MOVE request",
|
9
11
|
"backspace" => "Send a BACKSPACE request",
|
10
12
|
"delete" => "Send a DELETE request",
|
11
|
-
"
|
13
|
+
"load" => "Send a LOAD request",
|
12
14
|
"help" => "Show the list of the commands",
|
13
15
|
"exit" => "Disconnect and quit the program",
|
14
16
|
"quit" => "Disconnect and quit the program"
|
@@ -18,7 +20,7 @@ module Minep
|
|
18
20
|
CommandsInfo
|
19
21
|
end
|
20
22
|
|
21
|
-
def self.
|
23
|
+
def self.load socket, type
|
22
24
|
args = {
|
23
25
|
:path => "",
|
24
26
|
:size => 0,
|
@@ -26,14 +28,34 @@ module Minep
|
|
26
28
|
:port => 0
|
27
29
|
}
|
28
30
|
printf "path : "
|
29
|
-
args[:path] = read
|
31
|
+
args[:path] = Minep.read
|
30
32
|
printf "line number : "
|
31
|
-
args[:line] = read.to_i
|
33
|
+
args[:line] = Minep.read.to_i
|
34
|
+
printf "port : "
|
35
|
+
args[:port] = Minep.read.to_i
|
32
36
|
if File.exist? args[:path]
|
33
37
|
f = File.new args[:path]
|
34
38
|
args[:size] = f.size
|
35
|
-
|
36
|
-
|
39
|
+
f.close
|
40
|
+
Thread.start args[:port], args[:path] do |port, path|
|
41
|
+
file = File.new args[:path]
|
42
|
+
content = file.read
|
43
|
+
file.close
|
44
|
+
server = nil
|
45
|
+
if type == :tcp
|
46
|
+
server = TCPServer.new "0.0.0.0", port
|
47
|
+
elsif type == :websocket
|
48
|
+
server = WEBSocket::Server.new "0.0.0.0", port
|
49
|
+
end
|
50
|
+
socket = server.accept
|
51
|
+
socket.write content
|
52
|
+
socket.shutdown :RDWR
|
53
|
+
socket.close
|
54
|
+
server.close
|
55
|
+
Thread.stop
|
56
|
+
end
|
57
|
+
sleep 2
|
58
|
+
socket.write "LOAD=#{JSON.dump args}"
|
37
59
|
else
|
38
60
|
$stderr.puts "File #{args[:path]} doesn't exists"
|
39
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minep-request
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: WEBSocket
|
@@ -40,7 +40,7 @@ description: ! 'Binary allowing the communication with a MINE server. It support
|
|
40
40
|
email:
|
41
41
|
- ciappam@gmail.com
|
42
42
|
executables:
|
43
|
-
-
|
43
|
+
- minep-request
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
@@ -49,7 +49,7 @@ files:
|
|
49
49
|
- LICENSE.txt
|
50
50
|
- README.md
|
51
51
|
- Rakefile
|
52
|
-
- bin/
|
52
|
+
- bin/minep-request
|
53
53
|
- lib/minep-request.rb
|
54
54
|
- lib/minep-request/minep.rb
|
55
55
|
- lib/minep-request/requests.rb
|
@@ -80,4 +80,3 @@ signing_key:
|
|
80
80
|
specification_version: 3
|
81
81
|
summary: Binary allowing the communication with a MINE server
|
82
82
|
test_files: []
|
83
|
-
has_rdoc:
|