zrcon 0.0.3 → 0.0.4

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: f7d9ff2a8c84a38b825b2e2df6f419313a340d4c
4
- data.tar.gz: a3d8961bd9d29b5bca06dfb8426426157d8a9025
3
+ metadata.gz: ae5f25c0942ee1911228bd9c5d0f33d763c11166
4
+ data.tar.gz: '0806a6f16d2ad76695ce349ed2cb55a42d55d658'
5
5
  SHA512:
6
- metadata.gz: 693a2223973faabd17fb20239f88e875492fb4b74712983f1c8f4874901eb75cdad90dcc258dc8273cc5ca7f026253b53efdd0e25c17549a6ed833dc694d443a
7
- data.tar.gz: 4286ea637ceba7d735c6b46eae3573bd1893bbab16d8e11f39fe7008513b4f203749593f1a6dbd443f3ef16667da469d1556e5dfde6ce4383fd299a79e4457b1
6
+ metadata.gz: ac1986b4c5cf4b392b0734ffdaa762b1a95c1e841acb89290890220f9a9dc5258c08eb18ce66c294937a2b742893f48eb516693d93eb547499a8139af541a399
7
+ data.tar.gz: 2499bfe1b9cd39347c62eaaffdde8bbce2b9a698b62283a854b575d8e685937541435dad6fa45827ca4c22e144ce86ed087011c29e9e29c2ab337211cc4f977c
data/bin/zrcon CHANGED
@@ -15,12 +15,16 @@ options = OpenStruct.new(
15
15
  password: ENV['RCON_PASSWORD']
16
16
  )
17
17
 
18
- OptionParser.new { |opts|
19
- opts.banner = "Usage: zrcon..."
20
- opts.on("-hHOSTNAME", "--host=HOSTNAME", "hostname of rcon server") { |value| options.host = value }
18
+ OptionParser.new do |opts|
19
+ opts.banner = "Usage: zrcon ..."
20
+ opts.on("-HHOSTNAME", "--host=HOSTNAME", "hostname of rcon server") { |value| options.host = value }
21
21
  opts.on("-pPORT", "--port=PORT", "tcp port") { |value| options.port = value.to_i }
22
22
  opts.on("-PPASS", "--password=PASS", "rcon password") { |value| options.password = value }
23
- }.parse!
23
+ opts.on("-h", "--help") do
24
+ puts opts.help()
25
+ exit
26
+ end
27
+ end.parse!
24
28
 
25
29
  begin
26
30
  rcon = Zrcon.new options.to_h
@@ -30,4 +34,3 @@ begin
30
34
  rescue Zrcon::ConnectError => e
31
35
  puts "Connect error: #{e}"
32
36
  end
33
-
@@ -32,20 +32,19 @@ class Zrcon
32
32
  def conn
33
33
  @conn ||= TCPSocket.new host, port
34
34
  rescue SocketError
35
- raise ConnectError.new "bad hostname perhaps? (#{host})"
35
+ raise ConnectError, "bad hostname perhaps? (#{host})"
36
36
  rescue Errno::ETIMEDOUT
37
- raise ConnectError.new "timed out connecting to #{host}:#{port}"
37
+ raise ConnectError, "timed out connecting to #{host}:#{port}"
38
38
  rescue Errno::ECONNREFUSED
39
- raise ConnectError.new "connection refused"
39
+ raise ConnectError, "connection refused"
40
40
  end
41
41
 
42
-
43
42
  def next_id
44
43
  @id ||= 0
45
44
  @id += 1
46
45
  end
47
46
 
48
- def send packet
47
+ def send(packet)
49
48
  conn.write packet.encode
50
49
  end
51
50
 
@@ -9,23 +9,27 @@ class Zrcon
9
9
  end
10
10
 
11
11
  def next_id
12
- @@id ||= -1
13
- @@id += 1
12
+ self.class.next_id
13
+ end
14
+
15
+ def self.next_id
16
+ @id ||= -1
17
+ @id += 1
14
18
  end
15
19
 
16
20
  def encode
17
- [10+data.length, id, type, data].pack("l<l<l<A#{data.length}xx")
21
+ [10 + data.length, id, type, data].pack("l<l<l<A#{data.length}xx")
18
22
  end
19
23
 
20
- def self.auth password
24
+ def self.auth(password)
21
25
  new type: 3, data: password
22
26
  end
23
27
 
24
- def self.command cmd
28
+ def self.command(cmd)
25
29
  new type: 2, data: cmd
26
30
  end
27
31
 
28
- def self.decode raw
32
+ def self.decode(raw)
29
33
  raw = raw.to_s
30
34
  fields = raw.unpack("l<l<Z*x")
31
35
 
@@ -33,4 +37,3 @@ class Zrcon
33
37
  end
34
38
  end
35
39
  end
36
-
@@ -1,3 +1,3 @@
1
1
  class Zrcon
2
- VERSION = '0.0.3'.freeze
2
+ VERSION = '0.0.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zrcon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Libby
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.3'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -53,19 +67,19 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '3.7'
55
69
  - !ruby/object:Gem::Dependency
56
- name: rake
70
+ name: rubocop
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '12.3'
75
+ version: '0.52'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '12.3'
82
+ version: '0.52'
69
83
  description: A lightweight rcon client to talk to minecraft remote console service
70
84
  email: alibby@andylibby.org
71
85
  executables: