csstats 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/csstats.gemspec +8 -6
- data/lib/csstats.rb +5 -9
- data/lib/csstats/handler.rb +11 -9
- data/lib/csstats/version.rb +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d51fefc1bb5175635411ea675e5a671aa562e64
|
4
|
+
data.tar.gz: e9839b430fb119edea4038620cd40a1d8cfca586
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ead5bc0c0816de8489dfe76cc3056214694b914b476084374858273a1f334404beda7ded468dfca38c75140be17a5326876a4800aaa7e93d45829037a852ecf2
|
7
|
+
data.tar.gz: 5abc39e06124efe37b54356fc75f38d9797a61b76bebb1de8805fd04fa90e93c7dc6431e320e71ff4d6736e206ee3dfbef686b51bcd4aef2c12cc0374a75ca89
|
data/Gemfile
CHANGED
data/csstats.gemspec
CHANGED
@@ -4,20 +4,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'csstats/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
|
-
gem.name =
|
7
|
+
gem.name = 'csstats'
|
8
8
|
gem.version = CSstats::VERSION
|
9
|
-
gem.
|
10
|
-
gem.email =
|
11
|
-
gem.homepage =
|
9
|
+
gem.author = 'Justas Palumickas'
|
10
|
+
gem.email = 'jpalumickas@gmail.com'
|
11
|
+
gem.homepage = 'https://github.com/jpalumickas/csstats/'
|
12
12
|
gem.summary = gem.description
|
13
13
|
gem.description = %q{ Gem which handle csstats.dat file generated by CSX module in AMX Mod X (http://www.amxmodx.org/) }
|
14
14
|
gem.license = 'MIT'
|
15
15
|
|
16
|
+
gem.required_ruby_version = '>= 1.9.2'
|
17
|
+
|
16
18
|
gem.files = `git ls-files`.split($/)
|
17
19
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
20
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
-
gem.require_paths = [
|
21
|
+
gem.require_paths = ['lib']
|
20
22
|
|
21
|
-
gem.add_dependency 'hashie', '~>
|
23
|
+
gem.add_dependency 'hashie', '~> 3.0'
|
22
24
|
gem.add_development_dependency 'bundler', '~> 1.0'
|
23
25
|
end
|
data/lib/csstats.rb
CHANGED
@@ -2,14 +2,10 @@ require 'csstats/error'
|
|
2
2
|
require 'csstats/handler'
|
3
3
|
|
4
4
|
module CSstats
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def new(options = {})
|
11
|
-
CSstats::Handler.new(options)
|
12
|
-
end
|
13
|
-
|
5
|
+
# Alias for CSstats::Handler.new
|
6
|
+
#
|
7
|
+
# Returns CSstats::Handler
|
8
|
+
def self.new(options = {})
|
9
|
+
CSstats::Handler.new(options)
|
14
10
|
end
|
15
11
|
end
|
data/lib/csstats/handler.rb
CHANGED
@@ -17,11 +17,11 @@ module CSstats
|
|
17
17
|
|
18
18
|
maxplayers = options[:maxplayers] || 0
|
19
19
|
|
20
|
-
return if
|
20
|
+
return if path.nil?
|
21
21
|
|
22
|
-
handle = File.new(
|
22
|
+
handle = File.new(path, 'r')
|
23
23
|
|
24
|
-
|
24
|
+
file_version = read_short_data(handle)
|
25
25
|
|
26
26
|
i = 0
|
27
27
|
while !handle.eof? && (maxplayers == 0 || i < maxplayers)
|
@@ -40,8 +40,8 @@ module CSstats
|
|
40
40
|
#
|
41
41
|
# Returns the Mash of player information.
|
42
42
|
def player(id)
|
43
|
-
unless
|
44
|
-
|
43
|
+
unless players[id - 1].nil?
|
44
|
+
players[id - 1]
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -49,7 +49,7 @@ module CSstats
|
|
49
49
|
#
|
50
50
|
# Returns the Integer of player count.
|
51
51
|
def players_count
|
52
|
-
|
52
|
+
players.count
|
53
53
|
end
|
54
54
|
|
55
55
|
# Public: Get player by specified name.
|
@@ -58,7 +58,7 @@ module CSstats
|
|
58
58
|
#
|
59
59
|
# Returns the Mash of player information.
|
60
60
|
def search_by_name(name)
|
61
|
-
|
61
|
+
players.each do |player|
|
62
62
|
return player if name == player.nick
|
63
63
|
end
|
64
64
|
end
|
@@ -124,6 +124,7 @@ module CSstats
|
|
124
124
|
def read_int_data(handle)
|
125
125
|
data = handle.read(4)
|
126
126
|
raise CSstats::Error, 'Cannot read int data.' unless data
|
127
|
+
|
127
128
|
data.unpack('V').first
|
128
129
|
end
|
129
130
|
|
@@ -135,6 +136,7 @@ module CSstats
|
|
135
136
|
def read_short_data(handle)
|
136
137
|
data = handle.read(2)
|
137
138
|
raise CSstats::Error, 'Cannot read short data.' unless data
|
139
|
+
|
138
140
|
data.unpack('v').first
|
139
141
|
end
|
140
142
|
|
@@ -147,8 +149,8 @@ module CSstats
|
|
147
149
|
def read_string_data(handle, length)
|
148
150
|
data = handle.read(length)
|
149
151
|
raise CSstats::Error, 'Cannot read string data.' unless data
|
150
|
-
|
151
|
-
data
|
152
|
+
|
153
|
+
data.strip
|
152
154
|
end
|
153
155
|
end
|
154
156
|
end
|
data/lib/csstats/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csstats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justas Palumickas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,8 +40,7 @@ dependencies:
|
|
40
40
|
version: '1.0'
|
41
41
|
description: " Gem which handle csstats.dat file generated by CSX module in AMX Mod
|
42
42
|
X (http://www.amxmodx.org/) "
|
43
|
-
email:
|
44
|
-
- justas@elish.lt
|
43
|
+
email: jpalumickas@gmail.com
|
45
44
|
executables: []
|
46
45
|
extensions: []
|
47
46
|
extra_rdoc_files: []
|
@@ -75,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
74
|
requirements:
|
76
75
|
- - ">="
|
77
76
|
- !ruby/object:Gem::Version
|
78
|
-
version:
|
77
|
+
version: 1.9.2
|
79
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
79
|
requirements:
|
81
80
|
- - ">="
|
@@ -83,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
82
|
version: '0'
|
84
83
|
requirements: []
|
85
84
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.2.
|
85
|
+
rubygems_version: 2.2.2
|
87
86
|
signing_key:
|
88
87
|
specification_version: 4
|
89
88
|
summary: ''
|