cmdserver 0.9.1 → 0.9.2
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 +3 -3
- data/bin/testserver +7 -0
- data/lib/cmdserver/version.rb +1 -1
- data/lib/cmdserver.rb +7 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4cb226f555b73c2bc4328970b85aa87edf3ca06
|
4
|
+
data.tar.gz: 04c9f4ac3f98885eaba6bad626db96d7b9245635
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 731c5b8435fc115f5a5959afb0559bcea0eb8ede04f46a6e08dda1ca8e357931b4bdf06a6cffc016a77425c66c7cf502017343f4545e29f281b1cc107d7e4d81
|
7
|
+
data.tar.gz: 0d36dc083f58852d13498dbb800c4f5cff72eeac05da41e8332881911eb391454e02571851282c362263add899628b0555451a6f9bced3c6eb0f6caab6024036
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
By default, Cmdserver looks into `~/.cmdserver/modules` for any .rb files present. It then `require
|
25
|
+
By default, Cmdserver looks into `~/.cmdserver/modules` for any .rb files present. It then `require`-s them into the program.
|
26
26
|
In these .rb files, you override the module `Cmdserver::CmdProtocol` as demonstrated bellow
|
27
27
|
|
28
28
|
```ruby
|
@@ -44,7 +44,7 @@ For now, argument parsing is left up to the individual functions.
|
|
44
44
|
|
45
45
|
Also note that overriding the default behaviour can be done only once. The last loaded module that redefines `self.default_action` is what is going to happen, when the command is not recognized. By default, it echoes back whatever it recieves.
|
46
46
|
|
47
|
-
The `@protocol_hash` can be
|
47
|
+
The `@protocol_hash` can be destroid in any module. The hash gets copied into the core on a per-module basis. Note that this can introduce
|
48
48
|
conflicts when many modules define the same keys for commands.
|
49
49
|
|
50
50
|
|
@@ -59,7 +59,7 @@ That starts the main loop which will then start accepting connections.
|
|
59
59
|
|
60
60
|
## Development
|
61
61
|
|
62
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake
|
62
|
+
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.
|
63
63
|
|
64
64
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
65
65
|
|
data/bin/testserver
ADDED
data/lib/cmdserver/version.rb
CHANGED
data/lib/cmdserver.rb
CHANGED
@@ -36,7 +36,7 @@ module Cmdserver
|
|
36
36
|
|
37
37
|
def initialize(config_dir="~/.cmdserver/")
|
38
38
|
@workdir = Pathname.new(File.expand_path(config_dir))
|
39
|
-
@config_rc = @workdir + "
|
39
|
+
@config_rc = @workdir + "config" # Configuration file currently unused
|
40
40
|
@module_dir = @workdir + "modules"
|
41
41
|
if not @workdir.exist?
|
42
42
|
Dir.mkdir @workdir
|
@@ -65,14 +65,14 @@ module Cmdserver
|
|
65
65
|
|
66
66
|
attr_accessor :socket
|
67
67
|
|
68
|
-
def initialize(port,
|
69
|
-
if settings.nil?
|
70
|
-
@settings = Settings.new()
|
71
|
-
end
|
68
|
+
def initialize(port, hash={}, settings=nil, debug=false)
|
72
69
|
@socket = TCPServer.new(port)
|
73
70
|
@cmd_hash = hash # hash of commands
|
74
|
-
@debug = debug
|
75
71
|
load_cmd_proto()
|
72
|
+
@debug = debug
|
73
|
+
if settings.nil?
|
74
|
+
@settings = Settings.new()
|
75
|
+
end
|
76
76
|
end
|
77
77
|
|
78
78
|
def load_cmd_proto()
|
@@ -110,6 +110,7 @@ module Cmdserver
|
|
110
110
|
if not real_key.nil?
|
111
111
|
begin
|
112
112
|
request.sub! real_key, ""
|
113
|
+
request.lstrip!
|
113
114
|
request.chomp!
|
114
115
|
if @cmd_hash.key? real_key
|
115
116
|
puts "Request after processing: #{request}" if @debug
|
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.9.
|
4
|
+
version: 0.9.2
|
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-10-
|
11
|
+
date: 2015-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- Rakefile
|
69
69
|
- bin/console
|
70
70
|
- bin/setup
|
71
|
+
- bin/testserver
|
71
72
|
- cmdserver.gemspec
|
72
73
|
- lib/cmdserver.rb
|
73
74
|
- lib/cmdserver/version.rb
|