gamespy_query 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ module GamespyQuery
5
5
  PARAMS = [:hostname, :gamever, :gametype, :gamemode, :numplayers, :maxplayers, :password, :equalModRequired, :mission, :mapname,
6
6
  :mod, :signatures, :verifysignatures, :gamestate, :dedicated, :platform, :sv_battleeye, :language, :difficulty]
7
7
 
8
- RX_ADDR_LINE = /([\d\.]+)[\s\t]*(\d+)/
8
+ RX_ADDR_LINE = /^[\s\t]*([\d\.]+)[\s\t:]*(\d+)[\s\t]*(.*)$/
9
9
 
10
10
  DELIMIT = case RUBY_PLATFORM
11
11
  when /-mingw32$/, /-mswin32$/
@@ -29,9 +29,8 @@ module GamespyQuery
29
29
  @geo, @game = geo, game
30
30
  end
31
31
 
32
- def process
33
- @list = Hash.new
34
- self.to_hash(self.read)
32
+ def process list = self.read
33
+ self.to_hash list
35
34
  end
36
35
 
37
36
  def get_params
@@ -68,6 +67,7 @@ module GamespyQuery
68
67
  RX_H = /\A([\.0-9]*):([0-9]*) *\\(.*)/
69
68
  STR_SPLIT = "\\"
70
69
  def to_hash(ar)
70
+ list = Hash.new
71
71
  ar.each_with_index do |entry, index|
72
72
  str = entry[RX_H]
73
73
  next unless str
@@ -80,13 +80,13 @@ module GamespyQuery
80
80
  i % 2 == 0 ? e : clean_string(e)
81
81
  end
82
82
  addr = "#{ip}:#{port}"
83
- if @list.has_key?(addr)
84
- e = @list[addr]
83
+ if list.has_key?(addr)
84
+ e = list[addr]
85
85
  else
86
86
  e = Hash.new
87
87
  e[:ip] = ip
88
88
  e[:port] = port
89
- @list[addr] = e
89
+ list[addr] = e
90
90
  end
91
91
  if e[:gamedata]
92
92
  e[:gamedata].merge!(Hash[*content])
@@ -94,7 +94,7 @@ module GamespyQuery
94
94
  e[:gamedata] = Hash[*content]
95
95
  end
96
96
  end
97
- @list
97
+ list
98
98
  end
99
99
  end
100
100
  end
@@ -1,3 +1,3 @@
1
1
  module GamespyQuery
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamespy_query
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: