gamespy_query 0.2.0pre17 → 0.2.0pre18
Sign up to get free protection for your applications and to get access to all the features.
data/lib/gamespy_query/master.rb
CHANGED
@@ -34,8 +34,8 @@ module GamespyQuery
|
|
34
34
|
# Initializes the instance
|
35
35
|
# @param [String] geo Geo string
|
36
36
|
# @param [String] game Game string
|
37
|
-
def initialize(geo = nil, game = "arma2oapc", geoip_path = nil)
|
38
|
-
@geo, @game, @geoip_path = geo, game, geoip_path
|
37
|
+
def initialize(geo = nil, game = "arma2oapc", geoip_path = nil, filter = nil)
|
38
|
+
@geo, @game, @geoip_path, @filter = geo, game, geoip_path, filter
|
39
39
|
end
|
40
40
|
|
41
41
|
# Convert the master browser data to hash
|
@@ -45,16 +45,16 @@ module GamespyQuery
|
|
45
45
|
|
46
46
|
# Gets list of PARAMS, delimited by {DELIMIT}
|
47
47
|
def get_params
|
48
|
-
PARAMS.map{|e| "#{DELIMIT}#{e}"}.join("")
|
48
|
+
PARAMS.clone.map{|e| "#{DELIMIT}#{e}"}.join("")
|
49
49
|
end
|
50
50
|
|
51
51
|
# Gets list of server addressses and optionally data
|
52
52
|
# @param [String] list Specify list or nil to fetch the list
|
53
53
|
# @param [Boolean] include_data Should server info data from the master browser be included
|
54
54
|
# @param [String] geo Geo String
|
55
|
-
def get_server_list list = nil, include_data = false, geo = nil
|
55
|
+
def get_server_list list = nil, include_data = false, geo = nil, filter = nil
|
56
56
|
addrs = []
|
57
|
-
list = %x[gslist -C -p "#{geoip_path}"#{" #{geo}-X #{get_params}" if include_data} -n #{@game}] if list.nil?
|
57
|
+
list = %x[gslist -C -p "#{geoip_path}"#{" #{geo}-X #{get_params}" if include_data} -n #{@game}#{" -f \"#{filter}\"" if filter}] if list.nil?
|
58
58
|
if include_data
|
59
59
|
addrs = handle_data(list, geo)
|
60
60
|
else
|
@@ -72,7 +72,7 @@ module GamespyQuery
|
|
72
72
|
Tools.logger.warn "Warning: GeoIP.dat database missing. Can't parse countries. #{geoip_path}"
|
73
73
|
geo = nil
|
74
74
|
end
|
75
|
-
get_server_list(nil, true, geo)
|
75
|
+
get_server_list(nil, true, geo, @filter)
|
76
76
|
end
|
77
77
|
|
78
78
|
# Handle reply data from gamespy master browser
|
@@ -86,6 +86,7 @@ module GamespyQuery
|
|
86
86
|
|
87
87
|
option :g, :game, 'Specify game', :argument => :required
|
88
88
|
option nil, :geo, 'Specify geo', :argument => :required
|
89
|
+
option :f, :filter, 'Specify filter', :argument => :required
|
89
90
|
|
90
91
|
subcommand Cri::Command.new_basic_help
|
91
92
|
|
@@ -128,7 +129,7 @@ module GamespyQuery
|
|
128
129
|
|
129
130
|
run do |opts, args, cmd|
|
130
131
|
opts = GamespyQuery::Options.setup_master_opts opts
|
131
|
-
process = GamespyQuery::SocketMaster.process_master(opts[:game], opts[:geo], nil, false, true, true)
|
132
|
+
process = GamespyQuery::SocketMaster.process_master(opts[:game], opts[:geo], nil, false, true, true, opts[:filter])
|
132
133
|
puts process.size
|
133
134
|
#puts process
|
134
135
|
end
|
@@ -111,7 +111,7 @@ module GamespyQuery
|
|
111
111
|
# @param [String] game Game to fetch info from
|
112
112
|
# @param [String] geo Geo location enabled?
|
113
113
|
# @param [Array] remote Hostname and path+filename strings if the list needs to be fetched from http server
|
114
|
-
def process_master(game = "arma2oapc", geo = nil, remote = nil, dedicated_only = false, sm_dedicated_only = true, info = false)
|
114
|
+
def process_master(game = "arma2oapc", geo = nil, remote = nil, dedicated_only = false, sm_dedicated_only = true, info = false, filter = nil)
|
115
115
|
master = GamespyQuery::Master.new(geo, game)
|
116
116
|
list = if remote
|
117
117
|
Net::HTTP.start(remote[0]) do |http|
|
@@ -119,7 +119,7 @@ module GamespyQuery
|
|
119
119
|
resp.body.split("\n")
|
120
120
|
end
|
121
121
|
else
|
122
|
-
master.get_server_list(nil, true, geo)
|
122
|
+
master.get_server_list(nil, true, geo, filter)
|
123
123
|
end
|
124
124
|
|
125
125
|
dat = master.process list
|
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.2.
|
4
|
+
version: 0.2.0pre18
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cri
|