csstats 1.0.0 → 1.0.1

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: 9da3fbfae32bbf6cae85ac94caf59a66fb9fb4f8
4
- data.tar.gz: 76547cef1effba619c15eded091132196cafe537
3
+ metadata.gz: ecb9899a0509a548c484782f274c9a2977b85e9f
4
+ data.tar.gz: 35da68649b1d7dc15d54caaceed2b394b8482552
5
5
  SHA512:
6
- metadata.gz: a9d31ba0a0059ad47e1d0bf66f7377b29edba4266151c2402cc886dc9690c3beac93aa002e2d3db8e5de0606b84729fd9bf543a5c0bb601da44eb9de78323f54
7
- data.tar.gz: e533af087daa8172936c493196263c9f0264dac75966af80e4e3a1ea1ceb33868769106c7fd12991c336ef4a2b34229133762a20cb1cbecf021cf540aeadd164
6
+ metadata.gz: c092e09b2b2174c8fe65c487d9ae2e5896be3339b54f130fa0da9b81302376abc50dd18cc51a1392866daefd7d13f824b61956c8d93a0832d814607ca9f3eb2b
7
+ data.tar.gz: ae13b4f5c2b321b47e8d91faa62f5826221d9e526b92f0e6ee064f8182a5a1860900f19a88e5c93deeda9a5f05462be63b3cdb3f810638a7ea2b9e4768619c42
data/CONTRIBUTING.md CHANGED
@@ -8,17 +8,19 @@ The following guidelines for contribution should be followed if you want to subm
8
8
 
9
9
  * You need a [GitHub account](https://github.com/signup/free)
10
10
  * Submit an [issue ticket](https://github.com/jpalumickas/csstats/issues) for your issue if the is no one yet.
11
- * Describe the issue and include steps to reproduce when it's a bug.
11
+ * Describe the issue and include steps to reproduce if it's a bug.
12
12
  * Ensure to mention the earliest version that you know is affected.
13
- * Fork the repository on GitHub
13
+ * If you are able and want to fix this, fork the repository on GitHub
14
14
 
15
15
  ## Make Changes
16
16
 
17
- * In your forked repository, create a topic branch for your upcoming patch.
17
+ * In your forked repository, create a topic branch for your upcoming patch. (e.g. `feature--autoplay` or `bugfix--ios-crash`)
18
18
  * Usually this is based on the master branch.
19
19
  * Create a branch based on master; `git branch
20
20
  fix/master/my_contribution master` then checkout the new branch with `git
21
21
  checkout fix/master/my_contribution`. Please avoid working directly on the `master` branch.
22
+ * Make sure you stick to the coding style that is used already.
23
+ * Make use of the `.editorconfig`-file if provided with the repository.
22
24
  * Make commits of logical units and describe them properly.
23
25
  * Check for unnecessary whitespace with `git diff --check` before committing.
24
26
 
@@ -29,10 +31,12 @@ The following guidelines for contribution should be followed if you want to subm
29
31
 
30
32
  * Push your changes to a topic branch in your fork of the repository.
31
33
  * Open a pull request to the original repository and choose the right original branch you want to patch.
32
- * If not done in commit messages (which you really should do) please reference and update your issue with the code changes.
34
+ _Advanced users may use [`hub`](https://github.com/defunkt/hub#git-pull-request) gem for that._
35
+ * If not done in commit messages (which you really should do) please reference and update your issue with the code changes. But _please do not close the issue yourself_.
36
+ _Notice: You can [turn your previously filed issues into a pull-request here](http://issue2pr.herokuapp.com/)._
33
37
  * Even if you have write access to the repository, do not directly push or merge pull-requests. Let another team member review your pull request and approve.
34
38
 
35
39
  # Additional Resources
36
40
 
37
41
  * [General GitHub documentation](http://help.github.com/)
38
- * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
42
+ * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
data/LICENSE.md CHANGED
@@ -1,9 +1,20 @@
1
- Copyright (c) 2013 Justas Palumickas
1
+ The MIT License (MIT)
2
2
 
3
- MIT License
3
+ Copyright (c) 2013 Justas Palumickas
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
6
11
 
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
8
14
 
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -7,6 +7,7 @@ in AMX Mod X ([http://www.amxmodx.org/][amxx])
7
7
  [![Build Status](https://secure.travis-ci.org/jpalumickas/csstats.png?branch=master)][travis]
8
8
  [![Dependency Status](https://gemnasium.com/jpalumickas/csstats.png?travis)][gemnasium]
9
9
  [![Coverage Status](https://coveralls.io/repos/jpalumickas/csstats/badge.png?branch=master)][coveralls]
10
+ [![Code Climate](https://codeclimate.com/github/jpalumickas/csstats.png)][codeclimate]
10
11
 
11
12
  ## Installation
12
13
 
@@ -39,6 +40,13 @@ stats.players_count
39
40
  # => 15
40
41
  ```
41
42
 
43
+ You can find player by specified name.
44
+
45
+ ```ruby
46
+ stats = CSstats.new(path: 'csstats.dat')
47
+ stats.search_by_name('nick')
48
+ ```
49
+
42
50
  ## Supported Ruby Versions
43
51
 
44
52
  This library aims to support and is [tested against][travis] the following Ruby
@@ -56,6 +64,7 @@ See [LICENSE][] for details.
56
64
  [travis]: http://travis-ci.org/jpalumickas/csstats
57
65
  [gemnasium]: https://gemnasium.com/jpalumickas/csstats
58
66
  [coveralls]: https://coveralls.io/r/jpalumickas/csstats
67
+ [codeclimate]: https://codeclimate.com/github/jpalumickas/csstats
59
68
 
60
69
  [amxx]: http://www.amxmodx.org/
61
70
  [license]: LICENSE.md
@@ -28,7 +28,7 @@ module CSstats
28
28
  while (!handle.eof? && (maxplayers == 0 || i < maxplayers))
29
29
  player = read_player(handle)
30
30
  if player
31
- player['rank'] = i+1
31
+ player['rank'] = i + 1
32
32
  players[i] = player
33
33
  end
34
34
  i = i + 1
@@ -41,41 +41,45 @@ module CSstats
41
41
  #
42
42
  # Returns The Hash (Mash) of player information.
43
43
  def read_player(handle)
44
- hash = Hashie::Mash.new
45
- l = read_short_data(handle);
44
+ length = read_short_data(handle);
46
45
 
47
- return nil if (l == 0)
46
+ return nil if (length == 0)
48
47
 
49
- hash['nick'] = read_string_data(handle, l)
50
- l = read_short_data(handle)
51
- hash['uniq'] = read_string_data(handle, l)
48
+ mash = Hashie::Mash.new
52
49
 
53
- hash['teamkill'] = read_int_data(handle)
54
- hash['damage'] = read_int_data(handle)
55
- hash['deaths'] = read_int_data(handle)
56
- hash['kills'] = read_int_data(handle)
57
- hash['shots'] = read_int_data(handle)
58
- hash['hits'] = read_int_data(handle)
59
- hash['headshots'] = read_int_data(handle)
50
+ mash.nick = read_string_data(handle, length)
51
+ length = read_short_data(handle)
52
+ mash.uniq = read_string_data(handle, length)
60
53
 
61
- hash['defusions'] = read_int_data(handle)
62
- hash['defused'] = read_int_data(handle)
63
- hash['plants'] = read_int_data(handle)
64
- hash['explosions'] = read_int_data(handle)
54
+ mash.teamkill = read_int_data(handle)
55
+ mash.damage = read_int_data(handle)
56
+ mash.deaths = read_int_data(handle)
57
+ mash.kills = read_int_data(handle)
58
+ mash.shots = read_int_data(handle)
59
+ mash.hits = read_int_data(handle)
60
+ mash.headshots = read_int_data(handle)
61
+
62
+ mash.defusions = read_int_data(handle)
63
+ mash.defused = read_int_data(handle)
64
+ mash.plants = read_int_data(handle)
65
+ mash.explosions = read_int_data(handle)
65
66
 
66
67
  read_int_data(handle) # 0x00000000
67
68
 
68
- hash['head'] = read_int_data(handle)
69
- hash['chest'] = read_int_data(handle)
70
- hash['stomach'] = read_int_data(handle)
71
- hash['leftarm'] = read_int_data(handle)
72
- hash['rightarm'] = read_int_data(handle)
73
- hash['leftleg'] = read_int_data(handle)
74
- hash['rightleg'] = read_int_data(handle)
69
+ mash.head = read_int_data(handle)
70
+ mash.chest = read_int_data(handle)
71
+ mash.stomach = read_int_data(handle)
72
+ mash.leftarm = read_int_data(handle)
73
+ mash.rightarm = read_int_data(handle)
74
+ mash.leftleg = read_int_data(handle)
75
+ mash.rightleg = read_int_data(handle)
76
+
77
+ mash.acc = mash.hits / mash.shots * 100
78
+ mash.eff = mash.kills / (mash.kills + mash.deaths) * 100
75
79
 
76
80
  read_int_data(handle) # 0x00000000
77
81
 
78
- return hash
82
+ return mash
79
83
  end
80
84
 
81
85
  # Get the 32bit integer from file.
@@ -86,8 +90,7 @@ module CSstats
86
90
  def read_int_data(handle)
87
91
  data = handle.read(4)
88
92
  raise CSstats::Error, "Cannot read int data." unless data
89
- data = data.unpack("V")
90
- return data.first
93
+ return data.unpack("V").first
91
94
  end
92
95
 
93
96
  # Get the 16bit integer from file.
@@ -98,8 +101,7 @@ module CSstats
98
101
  def read_short_data(handle)
99
102
  data = handle.read(2)
100
103
  raise CSstats::Error, "Cannot read short data." unless data
101
- data = data.unpack("v")
102
- return data.first
104
+ return data.unpack("v").first
103
105
  end
104
106
 
105
107
  # Get the string from file.
@@ -123,8 +125,6 @@ module CSstats
123
125
  def player(id)
124
126
  unless (@players[id-1].nil?)
125
127
  @players[id-1]
126
- else
127
- nil
128
128
  end
129
129
  end
130
130
 
@@ -146,4 +146,4 @@ module CSstats
146
146
  end
147
147
  end
148
148
  end
149
- end
149
+ end
@@ -1,3 +1,3 @@
1
1
  module CSstats
2
- VERSION = "1.0.0" unless defined?(CSstats::VERSION)
3
- end
2
+ VERSION = "1.0.1" unless defined?(CSstats::VERSION)
3
+ end
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.0
4
+ version: 1.0.1
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-04-22 00:00:00.000000000 Z
11
+ date: 2013-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  requirements: []
85
85
  rubyforge_project:
86
- rubygems_version: 2.0.3
86
+ rubygems_version: 2.0.6
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: Gem which handle csstats.dat file generated by CSX module in AMX Mod X (http://www.amxmodx.org/)