cmdserver 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c4084d52fe2ef4f97a79630ee88c52ca99c2b1b
4
- data.tar.gz: d389b6d35fc6c9670f395c4001a41167276a3081
3
+ metadata.gz: b4cb226f555b73c2bc4328970b85aa87edf3ca06
4
+ data.tar.gz: 04c9f4ac3f98885eaba6bad626db96d7b9245635
5
5
  SHA512:
6
- metadata.gz: 1cdf8084c4412313c54a5d2c13b49b06ec1ce3b824d9cb30edbeded8e79f07755e7e5e2a7352829235b9334e0355c6f530814098cc9cc287e0b34d4bf216d35c
7
- data.tar.gz: 117b41f1ca968f3d8bd76725ea2f0589d3862045a23f238bdc6634c8cdbca7cdef5561654c2f8eb7c7efa8c4fcf577798cacda2b983ab1d3a620df75aa4b3e73
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`s them into the program.
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 destroied in any module. The hash gets copied into the core on a per-module basis. Note that this can introduce
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 rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cmdserver"
5
+
6
+ server = Cmdserver::TCPCommandServer.new(2121)
7
+ server.start()
@@ -1,3 +1,3 @@
1
1
  module Cmdserver
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.2"
3
3
  end
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 + "configrc"
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, settings=nil, hash={}, debug=false)
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.1
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-27 00:00:00.000000000 Z
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