csstats 1.0.2 → 1.0.3

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: d6872b7c03f06e7dd770c35a07cd90aaed879ecd
4
- data.tar.gz: 3834dbf6a0af008ce011d01f182e72c8249fe1a5
3
+ metadata.gz: 2313cf63067bbd162abce2c0a4c5fe00c87a6379
4
+ data.tar.gz: 60a0b3c72b821d3c194588282dbbbf256079e59e
5
5
  SHA512:
6
- metadata.gz: d2ef9f0ac0f3cfbd024eb17f3ae4bad43ca8cf81a715a39c8114744aea8f244a671a5896c231f83895fb42fe3b3c1829f4a8daa5215303f6b3192504c357d87b
7
- data.tar.gz: 593d29515df36cef84ea29e4e3141b659982b24b6b90a513fb92cccf5254b5a620415a0156a5d1ec31ad17420cfaa15f9d19527581c644b74ba1e4e149046093
6
+ metadata.gz: 516528ff7124ea2285562e66a627cbd883ba6f83cdc49471ba2193dbd07f8cf3c58315ac81c9c3faecc397c457bfaa08e8a31d1d818e3ddd47c37cefb488d2e9
7
+ data.tar.gz: 390927f04cbdcf054e255af541f83010f15b2156998a5be80d203af25778512d6a284915bc16a5ec14b66bdd05d81a0ff4db508a602c4dd78e9ff1d6ca84f145
@@ -1,7 +1,19 @@
1
+ bundler_args: --without development
2
+
1
3
  language: ruby
4
+
2
5
  rvm:
3
- - jruby-19mode
4
- - rbx-19mode
5
6
  - 1.9.2
6
7
  - 1.9.3
7
8
  - 2.0.0
9
+ - 2.1.0
10
+ - ruby-head
11
+ - jruby-19mode
12
+ - jruby-head
13
+ - rbx
14
+
15
+ matrix:
16
+ allow_failures:
17
+ - rvm: ruby-head
18
+ - rvm: jruby-head
19
+ - rvm: rbx
data/Gemfile CHANGED
@@ -3,9 +3,9 @@ source 'https://rubygems.org'
3
3
  gem 'rake'
4
4
 
5
5
  group :test do
6
- gem 'coveralls', require: false
7
- gem 'rspec', '>= 2.13'
8
- gem 'simplecov', require: false
6
+ gem 'coveralls', '~> 0.7.0', require: false
7
+ gem 'rspec', '~> 2.14.1'
8
+ gem 'simplecov', '~> 0.7.1', require: false
9
9
  end
10
10
 
11
11
  gemspec
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # CSstats
2
2
 
3
- Gem which handle csstats.dat file generated by CSX module
3
+ Gem which handle `csstats.dat` file generated by CSX module
4
4
  in AMX Mod X ([http://www.amxmodx.org/][amxx])
5
5
 
6
6
  [![Gem Version](https://badge.fury.io/rb/csstats.png)][rubygems]
@@ -40,7 +40,7 @@ stats.players_count
40
40
  # => 15
41
41
  ```
42
42
 
43
- You can find player by specified name.
43
+ You can get player information by specified name.
44
44
 
45
45
  ```ruby
46
46
  stats = CSstats.new(path: 'csstats.dat')
@@ -57,6 +57,7 @@ implementations:
57
57
  * Ruby 1.9.2
58
58
  * Ruby 1.9.3
59
59
  * Ruby 2.0.0
60
+ * Ruby 2.1.0
60
61
 
61
62
  ## Copyright
62
63
  Copyright (c) 2013 Justas Palumickas.
@@ -5,20 +5,19 @@ require 'csstats/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "csstats"
8
+ gem.version = CSstats::VERSION
8
9
  gem.authors = ["Justas Palumickas"]
9
10
  gem.email = ["justas@elish.lt"]
10
- gem.description = %q{ Gem which handle csstats.dat file generated by CSX module in AMX Mod X (http://www.amxmodx.org/) }
11
- gem.summary = gem.description
12
11
  gem.homepage = "https://github.com/jpalumickas/csstats/"
13
- gem.licenses = ['MIT']
12
+ gem.summary = gem.description
13
+ gem.description = %q{ Gem which handle csstats.dat file generated by CSX module in AMX Mod X (http://www.amxmodx.org/) }
14
+ gem.license = 'MIT'
14
15
 
15
16
  gem.files = `git ls-files`.split($/)
16
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
19
  gem.require_paths = ["lib"]
19
20
 
20
- gem.add_development_dependency 'bundler', '~> 1.0'
21
21
  gem.add_dependency 'hashie', '~> 2.0'
22
-
23
- gem.version = CSstats::VERSION
22
+ gem.add_development_dependency 'bundler', '~> 1.0'
24
23
  end
@@ -34,6 +34,57 @@ module CSstats
34
34
  end
35
35
  end
36
36
 
37
+ # Public: Get the player information of specified id.
38
+ #
39
+ # id - The Integer of player id.
40
+ #
41
+ # Returns the Mash of player information.
42
+ def player(id)
43
+ unless @players[id - 1].nil?
44
+ @players[id - 1]
45
+ end
46
+ end
47
+
48
+ # Public: Get total players count.
49
+ #
50
+ # Returns the Integer of player count.
51
+ def players_count
52
+ @players.count
53
+ end
54
+
55
+ # Public: Get player by specified name.
56
+ #
57
+ # name - The String of player name.
58
+ #
59
+ # Returns the Mash of player information.
60
+ def search_by_name(name)
61
+ @players.each do |player|
62
+ return player if name == player.nick
63
+ end
64
+ end
65
+
66
+ private
67
+
68
+ # Internal: Count player efficiency.
69
+ #
70
+ # kills - The Integer of player kills in game.
71
+ # deaths - The Integer of player deaths in game.
72
+ #
73
+ # Returns The Float of player efficiency.
74
+ def count_efficiency(kills, deaths)
75
+ (kills.to_f / (kills.to_f + deaths.to_f) * 100).round(2)
76
+ end
77
+
78
+ # Internal: Count player accuracy.
79
+ #
80
+ # hits - The Integer of player hits in game.
81
+ # shots - The Integer of player shots in game.
82
+ #
83
+ # Returns The Float of player accuracy.
84
+ def count_accuracy(hits, shots)
85
+ (hits.to_f / shots.to_f * 100).round(2)
86
+ end
87
+
37
88
  # Internal: Read player information from file.
38
89
  #
39
90
  # handle - The File which was opened for reading data.
@@ -50,33 +101,17 @@ module CSstats
50
101
  length = read_short_data(handle)
51
102
  mash.uniq = read_string_data(handle, length)
52
103
 
53
- mash.teamkill = read_int_data(handle)
54
- mash.damage = read_int_data(handle)
55
- mash.deaths = read_int_data(handle)
56
- mash.kills = read_int_data(handle)
57
- mash.shots = read_int_data(handle)
58
- mash.hits = read_int_data(handle)
59
- mash.headshots = read_int_data(handle)
60
-
61
- mash.defusions = read_int_data(handle)
62
- mash.defused = read_int_data(handle)
63
- mash.plants = read_int_data(handle)
64
- mash.explosions = read_int_data(handle)
104
+ read_data = %w(teamkill damage deaths kills shots hits headshots
105
+ defusions defused plants explosions - head chest stomach
106
+ leftarm rightarm leftleg rightleg -)
65
107
 
66
- read_int_data(handle) # 0x00000000
108
+ read_data.each { |data| mash[data] = read_int_data(handle) }
67
109
 
68
- mash.head = read_int_data(handle)
69
- mash.chest = read_int_data(handle)
70
- mash.stomach = read_int_data(handle)
71
- mash.leftarm = read_int_data(handle)
72
- mash.rightarm = read_int_data(handle)
73
- mash.leftleg = read_int_data(handle)
74
- mash.rightleg = read_int_data(handle)
110
+ # Remove all 0x00000000
111
+ mash.tap { |x| x.delete('-') }
75
112
 
76
- mash.acc = mash.hits.to_f / mash.shots.to_f * 100
77
- mash.eff = mash.kills.to_f / (mash.kills.to_f + mash.deaths.to_f) * 100
78
-
79
- read_int_data(handle) # 0x00000000
113
+ mash.acc = count_accuracy(mash.hits, mash.shots)
114
+ mash.eff = count_efficiency(mash.kills, mash.deaths)
80
115
 
81
116
  mash
82
117
  end
@@ -115,34 +150,5 @@ module CSstats
115
150
  data = data.strip
116
151
  data
117
152
  end
118
-
119
- # Internal: Get the player information of specified id.
120
- #
121
- # id - The Integer of player id.
122
- #
123
- # Returns the Mash of player information.
124
- def player(id)
125
- unless @players[id - 1].nil?
126
- @players[id - 1]
127
- end
128
- end
129
-
130
- # Get total players count.
131
- #
132
- # Returns the Integer of player count.
133
- def players_count
134
- @players.count
135
- end
136
-
137
- # Get player by specified name.
138
- #
139
- # name - The String of player name.
140
- #
141
- # Returns the Mash of player information.
142
- def search_by_name(name)
143
- @players.each do |player|
144
- return player if name == player.nick
145
- end
146
- end
147
153
  end
148
154
  end
@@ -1,3 +1,3 @@
1
1
  module CSstats
2
- VERSION = '1.0.2' unless defined?(CSstats::VERSION)
2
+ VERSION = '1.0.3' unless defined?(CSstats::VERSION)
3
3
  end
@@ -14,9 +14,99 @@ describe CSstats::Handler do
14
14
  expect(@handler.player(2).nick).to eq 'CHMARSON'
15
15
  end
16
16
 
17
- it 'should return searched player' do
18
- player = @handler.search_by_name('CHMARSON')
19
- expect(player.nick).to eq 'CHMARSON'
20
- end
17
+ describe 'player with specified name' do
18
+
19
+ before do
20
+ @player = @handler.search_by_name('CHMARSON')
21
+ end
22
+
23
+ it 'should return searched player' do
24
+ expect(@player.nick).to eq 'CHMARSON'
25
+ end
26
+
27
+ it 'should return correct player rank' do
28
+ expect(@player.rank).to eq 2
29
+ end
30
+
31
+ it 'should return correct player teamkill' do
32
+ expect(@player.teamkill).to eq 7
33
+ end
34
+
35
+ it 'should return correct player damage' do
36
+ expect(@player.damage).to eq 101543
37
+ end
38
+
39
+ it 'should return correct player deaths' do
40
+ expect(@player.deaths).to eq 511
41
+ end
42
+
43
+ it 'should return correct player kills' do
44
+ expect(@player.kills).to eq 759
45
+ end
46
+
47
+ it 'should return correct player shots' do
48
+ expect(@player.shots).to eq 9421
49
+ end
50
+
51
+ it 'should return correct player hits' do
52
+ expect(@player.hits).to eq 2885
53
+ end
54
+
55
+ it 'should return correct player headshots' do
56
+ expect(@player.headshots).to eq 225
57
+ end
58
+
59
+ it 'should return correct player defusions' do
60
+ expect(@player.defusions).to eq 15
61
+ end
62
+
63
+ it 'should return correct player defused' do
64
+ expect(@player.defused).to eq 9
65
+ end
21
66
 
67
+ it 'should return correct player plants' do
68
+ expect(@player.plants).to eq 33
69
+ end
70
+
71
+ it 'should return correct player explosions' do
72
+ expect(@player.explosions).to eq 7
73
+ end
74
+
75
+ it 'should return correct player head' do
76
+ expect(@player.head).to eq 275
77
+ end
78
+
79
+ it 'should return correct player chest' do
80
+ expect(@player.chest).to eq 407
81
+ end
82
+
83
+ it 'should return correct player stomach' do
84
+ expect(@player.stomach).to eq 376
85
+ end
86
+
87
+ it 'should return correct player leftarm' do
88
+ expect(@player.leftarm).to eq 1126
89
+ end
90
+
91
+ it 'should return correct player rightarm' do
92
+ expect(@player.rightarm).to eq 283
93
+ end
94
+
95
+ it 'should return correct player leftleg' do
96
+ expect(@player.leftleg).to eq 202
97
+ end
98
+
99
+ it 'should return correct player rightleg' do
100
+ expect(@player.rightleg).to eq 214
101
+ end
102
+
103
+ it 'should return correct player accuracy' do
104
+ expect(@player.acc).to eq 30.62
105
+ end
106
+
107
+ it 'should return correct player efficiency' do
108
+ expect(@player.eff).to eq 59.76
109
+ end
110
+
111
+ end
22
112
  end
metadata CHANGED
@@ -1,54 +1,54 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csstats
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justas Palumickas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-11 00:00:00.000000000 Z
11
+ date: 2014-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: hashie
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
20
- type: :development
19
+ version: '2.0'
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: '1.0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: hashie
28
+ name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.0'
34
- type: :runtime
33
+ version: '1.0'
34
+ type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.0'
41
- description: ' Gem which handle csstats.dat file generated by CSX module in AMX Mod
42
- X (http://www.amxmodx.org/) '
40
+ version: '1.0'
41
+ description: " Gem which handle csstats.dat file generated by CSX module in AMX Mod
42
+ X (http://www.amxmodx.org/) "
43
43
  email:
44
44
  - justas@elish.lt
45
45
  executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - .gitignore
50
- - .rspec
51
- - .travis.yml
49
+ - ".gitignore"
50
+ - ".rspec"
51
+ - ".travis.yml"
52
52
  - CONTRIBUTING.md
53
53
  - Gemfile
54
54
  - LICENSE.md
@@ -73,20 +73,20 @@ require_paths:
73
73
  - lib
74
74
  required_ruby_version: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - '>='
76
+ - - ">="
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - '>='
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  requirements: []
85
85
  rubyforge_project:
86
- rubygems_version: 2.0.6
86
+ rubygems_version: 2.2.0
87
87
  signing_key:
88
88
  specification_version: 4
89
- summary: Gem which handle csstats.dat file generated by CSX module in AMX Mod X (http://www.amxmodx.org/)
89
+ summary: ''
90
90
  test_files:
91
91
  - spec/csstats/handler_spec.rb
92
92
  - spec/csstats_spec.rb