cmdserver 0.9.2 → 0.10.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/README.md +14 -1
- data/lib/cmdserver/version.rb +1 -1
- data/lib/cmdserver.rb +17 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fae792cda07478c097e01d974c9753ad2a79e1db
|
4
|
+
data.tar.gz: d881017e9579698f4d014df4f553f85146aa8df6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67f8c992d4be5fddcf46fea9649b967fc389f99f5635332d764ecf4223920309deff0335ac53a952c511753be12bbb706f4cfa119eb575a2b1b54fee21e8a7bf
|
7
|
+
data.tar.gz: fa8335ab0c42b8f3fe8c9c5ac83c76824dcafe1a7f5044859ded9305913d5ab1e0a8cd01c3a9f5fe07763f5c74d7a9af83c5b439a41733533c46f5dc05a88a5f
|
data/README.md
CHANGED
@@ -57,6 +57,19 @@ server.start()
|
|
57
57
|
|
58
58
|
That starts the main loop which will then start accepting connections.
|
59
59
|
|
60
|
+
You then connect to the specified port (1234 in our case) and write `CustomCommand`. The server will
|
61
|
+
then execute your function.
|
62
|
+
|
63
|
+
The functions can also be specified in the constructor itself as a hash:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
require "cmdserver"
|
67
|
+
server = Cmdserver::TCPCommandServer.new(1234, {
|
68
|
+
"CustomCommand" => -> client, args { client.puts "Running custom command" }
|
69
|
+
})
|
70
|
+
server.start()
|
71
|
+
```
|
72
|
+
|
60
73
|
## Development
|
61
74
|
|
62
75
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -65,7 +78,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
65
78
|
|
66
79
|
## Contributing
|
67
80
|
|
68
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/majorendian/
|
81
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/majorendian/Modular-Tcp-Command-Server
|
69
82
|
|
70
83
|
|
71
84
|
## License
|
data/lib/cmdserver/version.rb
CHANGED
data/lib/cmdserver.rb
CHANGED
@@ -8,10 +8,12 @@ module Cmdserver
|
|
8
8
|
# Protocol stuff goes here.
|
9
9
|
# Should be loaded from ~/.cmdserver/modules/*.rb
|
10
10
|
@protocol_hash = {}
|
11
|
+
@protocol = @protocol_hash
|
11
12
|
def self.extend_protocol()
|
12
|
-
@
|
13
|
+
@protocol = {
|
13
14
|
"dummy" => -> cs, args { cs.puts "Dummy reply"}
|
14
15
|
}
|
16
|
+
@protocol_hash = @protocol
|
15
17
|
end
|
16
18
|
|
17
19
|
def self.default_action(cs, args)
|
@@ -19,9 +21,10 @@ module Cmdserver
|
|
19
21
|
end
|
20
22
|
|
21
23
|
module_function
|
22
|
-
def
|
24
|
+
def get_protocol_hash()
|
23
25
|
self.extend_protocol()
|
24
|
-
|
26
|
+
@protocol = @protocol_hash
|
27
|
+
return @protocol
|
25
28
|
end
|
26
29
|
|
27
30
|
# Default behaviour when querry was not found
|
@@ -61,6 +64,16 @@ module Cmdserver
|
|
61
64
|
end
|
62
65
|
end
|
63
66
|
|
67
|
+
class Command # Class provided for the possibilty of future extensibility
|
68
|
+
def initialize
|
69
|
+
end
|
70
|
+
|
71
|
+
def call(client_socket, arg_string)
|
72
|
+
client_socket.puts "Dummy command call"
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
64
77
|
class TCPCommandServer
|
65
78
|
|
66
79
|
attr_accessor :socket
|
@@ -76,7 +89,7 @@ module Cmdserver
|
|
76
89
|
end
|
77
90
|
|
78
91
|
def load_cmd_proto()
|
79
|
-
phash = CmdProtocol.
|
92
|
+
phash = CmdProtocol.get_protocol_hash()
|
80
93
|
phash.each_key do |key|
|
81
94
|
@cmd_hash[key] = phash[key]
|
82
95
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmdserver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernest Deák
|
8
8
|
autorequire:
|
9
9
|
bindir: release
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|