quake_parser 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/main.rb +12 -12
  3. data/lib/quake_parser.rb +2 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4e2bb10a2ec81e337ae119c6c67b26d5f2f729fa28dbe57b6ff194c91d21d20
4
- data.tar.gz: 8d60157d949882454a33e4ebd15957072fe2c94291b4f8bc510a764201f31fa8
3
+ metadata.gz: b0debba2b9d2fc5393e6c5389be892702f875d4660237b04983b40a094ccb32e
4
+ data.tar.gz: 35e618de009c2174e7484d23570c12476581b759343c1d5bca8f3beecb477089
5
5
  SHA512:
6
- metadata.gz: bff772913f2af1f5c620237a5cc7eda014bf3742486dcaefd5b15dd9e8df64c0201f9ab324db2746a26a2cb081f4a35d9be17abd3f54f27b8a3cca01cd01075c
7
- data.tar.gz: f764392cc28ef328c80ab8672965e4111653bb4992ff9c60e71de7c41e547fa1cc7268bbcbfd6425194232a5e1d9b648126e8d9aa10572f86c886d16ac918d12
6
+ metadata.gz: 2d1c97948995afe19fa7c3abbde6c105e3cb04fface10891151081cf636bc09de0245eddb0a8a86129c8d41be15c21ccecda1d8f120d2b100618c2e75c78ce30
7
+ data.tar.gz: 7468ad3d52329855024f88463aadd6f52852bccb17f64d5d155fd7a0a00702debf81952ce915de92b142b5f056d719b6044ed39d747e2ae26580d97e1499fe54
data/lib/main.rb CHANGED
@@ -8,29 +8,29 @@ module QuakeParser
8
8
  @parser = QuakeParser::Parser.new(File.read(file_path))
9
9
  end
10
10
 
11
- def execute
11
+ def parser_and_print
12
12
  @parser.parse_file
13
- print_games
14
- print_ranking
15
13
  end
16
-
17
- def print_games
18
- @parser.games.each { |game| puts game.convert_data_to_json if game }
14
+
15
+ def get_games
16
+ games_data = []
17
+ @parser.games.each { |game| games_data << game.convert_data_to_hash if game }
18
+ games_data
19
19
  end
20
-
21
- def print_ranking
20
+
21
+ def get_ranking
22
22
  scores = Hash.new(0)
23
-
23
+
24
24
  @parser.games.each do |game|
25
25
  next unless game
26
-
26
+
27
27
  game.kills.each do |key, value|
28
28
  scores[key] += value
29
29
  end
30
30
  end
31
-
31
+
32
32
  ranking = scores.sort_by { |_key, value| -value }.to_h
33
- puts "global_ranking: #{JSON.pretty_generate(ranking)}\n"
33
+ ranking
34
34
  end
35
35
  end
36
36
  end
data/lib/quake_parser.rb CHANGED
@@ -5,6 +5,7 @@ require_relative 'game'
5
5
  module QuakeParser
6
6
  def self.run(file_path)
7
7
  main = QuakeParser::Main.new(file_path)
8
- main.execute
8
+ main.parser_and_print
9
+ { games: main.get_games, ranking: main.get_ranking }
9
10
  end
10
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quake_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''