ts3query 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -30,6 +30,26 @@ This will return a hash with the serverlist. (Options -uid and -short)
30
30
  opt.short
31
31
  end
32
32
 
33
+ This will select the first server. (Parameters sid=1)
34
+
35
+ @query.use :sid => 1
36
+
37
+ You can also combine parameters and options.
38
+
39
+ @query.use :sid => 1 do |opt|
40
+ opt.virtual
41
+ end
42
+
43
+ === Close the connection
44
+
45
+ If you don't need the query connection any longer you should close it.
46
+
47
+ @query.disconnect
48
+
49
+ === Query commands
50
+
51
+ For a full command reference you can download the {Teamspeak 3 Query Manuel}[http://media.teamspeak.com/ts3_literature/TeamSpeak%203%20Server%20Query%20Manual.pdf].
52
+
33
53
  == Contributing to TS3Query
34
54
 
35
55
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
@@ -40,6 +60,15 @@ This will return a hash with the serverlist. (Options -uid and -short)
40
60
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
41
61
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
42
62
 
63
+ == Running the tests
64
+
65
+ If you try to run the tests, you need a local teamspeak server running with this data:
66
+
67
+ * Address: 127.0.0.1
68
+ * Port: 10011
69
+ * User: serveradmin
70
+ * Password: 0L8awVFD
71
+
43
72
  == Copyright
44
73
 
45
74
  Copyright (c) 2012 TnT Web Solutions GbR. See LICENSE.txt for
@@ -11,4 +11,14 @@ Feature: Run a query command
11
11
  Scenario: Run 'serverlist' command with options
12
12
  Given I am connected to the default server with the password 0L8awVFD
13
13
  When I run the command serverlist with the options -uid -short
14
- Then I should get a hash with virtualserver_id=1 virtualserver_port=9987 virtualserver_status=online id=0 msg=ok
14
+ Then I should get a hash with virtualserver_id=1 virtualserver_port=9987 virtualserver_status=online id=0 msg=ok
15
+
16
+ Scenario: Run 'use' command with parameters
17
+ Given I am connected to the default server with the password 0L8awVFD
18
+ When I run the command use with the parameters sid=1
19
+ Then I should get a hash with id=0 msg=ok
20
+
21
+ Scenario: Run 'use' command with options and parameters
22
+ Given I am connected to the default server with the password 0L8awVFD
23
+ When I run the command use with the options -virtual and the parameters sid=1
24
+ Then I should get a hash with id=0 msg=ok
@@ -4,6 +4,7 @@ end
4
4
 
5
5
  When /^I run the command version$/ do
6
6
  @result = @query.version()
7
+ @query.disconnect
7
8
  end
8
9
 
9
10
  When /^I run the command serverlist with the options (.+)$/ do |options|
@@ -14,6 +15,34 @@ When /^I run the command serverlist with the options (.+)$/ do |options|
14
15
  opt.send(current)
15
16
  end
16
17
  end
18
+ @query.disconnect
19
+ end
20
+
21
+ When /^I run the command use with the parameters (.+)$/ do |parameters|
22
+ parameters = parameters.split(" ")
23
+ params = {}
24
+ parameters.each do |current|
25
+ params[current.split("=")[0]] = current.split("=")[1]
26
+ end
27
+ @result = @query.use params
28
+ @query.disconnect
29
+ end
30
+
31
+ When /^I run the command use with the options (.+) and the parameters (.+)$/ do |options, parameters|
32
+ parameters = parameters.split(" ")
33
+ params = {}
34
+ parameters.each do |current|
35
+ params[current.split("=")[0]] = current.split("=")[1]
36
+ end
37
+
38
+ options = options.split(" ")
39
+ @result = @query.use params do |opt|
40
+ options.each do |current|
41
+ current[0] = ""
42
+ opt.send(current)
43
+ end
44
+ end
45
+ @query.disconnect
17
46
  end
18
47
 
19
48
  Then /^I should get a hash with (.+)$/ do |data|
@@ -12,6 +12,7 @@ class TS3Connection
12
12
  def method_missing(meth, *args, &block)
13
13
  result = {}
14
14
  options = ""
15
+ params = ""
15
16
 
16
17
  if block
17
18
  query_options = QueryOptions.new
@@ -21,8 +22,12 @@ class TS3Connection
21
22
  options += " -#{opt}"
22
23
  end
23
24
  end
25
+
26
+ args.each do |param|
27
+ params += " #{param.keys[0]}=#{param[param.keys[0]]}"
28
+ end
24
29
 
25
- @connection.cmd("String" => "#{meth}#{options}\r",
30
+ @connection.cmd("String" => "#{meth}#{params}#{options}\r",
26
31
  "Match" => /error id=0 msg=ok\n/) { |data|
27
32
  data.split(" ").each do |entity|
28
33
  result[entity.split("=")[0]] = entity.split("=")[1]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ts3query
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: