sdtd_server 0.0.0 → 0.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sdtd_server.rb +61 -7
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 188590001c7221d75e41e7c23c15826f869c5a0a
4
- data.tar.gz: 79433500fb9ed39b08726bc873f4d8f3352dd806
3
+ metadata.gz: ef1dd972029c53b8b591958f60265ccce586944e
4
+ data.tar.gz: 8479ca01c3f3ee4a0cba6c3dfcad09bcd28885e4
5
5
  SHA512:
6
- metadata.gz: 1f53b3a5399897d568195d89268a37b17f3b9bada5c926dcce048f45248f19b7efa2acaa61df6df5ecae8d371b33511155e062052ba7e0334dd7d3d747af8956
7
- data.tar.gz: e2283ebb8d3e26cfe83c8c6d869f60843d6b0fafcf4430d2614bfbabc5aea7efb87e860d1aa50c500dfc6a3f7eb738167ebc2f7565312753f7547d242b2fbecc
6
+ metadata.gz: cd4727f4e94bdd2a6d2e5b461bbf90e7d4a0ac24ace9111925ce125c5dff6641d051afc9786115409975b95a0967cd3a1643e439d722f348481b5c11aac28be1
7
+ data.tar.gz: 7dc30208cbd33197b68147e4ad290b625270b4174142fabdf122539c91e63c5d55aef1d7cc3bfef8784a5d421b87b844f9bd41afcbd833171c481aaff75984ab
data/lib/sdtd_server.rb CHANGED
@@ -1,18 +1,72 @@
1
+ require 'net/telnet'
2
+
1
3
  class SDTD_Server
2
4
  #
5
+ attr_reader :server, :port, :connected
3
6
  #
4
7
  #
5
8
  #
6
- def self.hi
7
- #
8
- #
9
- puts "Hello bro!"
10
- #
11
- #
9
+ #
10
+ #
11
+ #
12
+ #
13
+ #
14
+ #
15
+ #
16
+ #
17
+ #
18
+ #
19
+ #
20
+ #
21
+ #
22
+ #
23
+ #
24
+ #
25
+ #
26
+ #
27
+ #
28
+ #
29
+ #
30
+ #
31
+ #
32
+ def save_world
33
+ telnet_command 'saveworld', /World saved/
34
+ return nil
12
35
  end
13
36
  #
37
+ def close
38
+ close_telnet_connection
39
+ end
14
40
  #
41
+ private
42
+ def telnet_command(string, match)
43
+ return @connection.cmd('String' => string, 'Match' => match)
44
+ end
15
45
  #
46
+ private
47
+ def console_login
48
+ login_response = telnet_command @password, /Logon successful.|Password incorrect/
49
+ raise InvalidConsolePasswordError unless login_response.include? 'ogon successful.'
50
+ @connected = true
51
+ end
16
52
  #
53
+ private
54
+ def close_telnet_connection
55
+ @connection.cmd('exit')
56
+ @connection.close
57
+ end
17
58
  #
18
- end
59
+ def initialize(params = {})
60
+ #
61
+ @server = params.fetch(:server, 'localhost')
62
+ @port = params.fetch(:port, '8081')
63
+ @password = params.fetch(:password, 'CHANGEME')
64
+ @connection = Net::Telnet.new('Host' => @server, 'Port' => @port, 'Telnetmode' => false)
65
+ @connected = false
66
+ #
67
+ console_login
68
+ #
69
+ end
70
+ end
71
+
72
+ class InvalidConsolePasswordError < StandardError ; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdtd_server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Ingalls
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-01 00:00:00.000000000 Z
11
+ date: 2016-01-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A gem to interface with a 7 days to die dedicated server with the telnet
14
14
  control port open.
@@ -18,7 +18,7 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - lib/sdtd_server.rb
21
- homepage: http://rubygems.org/gems/sdtd_server
21
+ homepage: https://rubygems.org/gems/sdtd_server
22
22
  licenses:
23
23
  - MIT
24
24
  metadata: {}