ehbrs_ruby_utils 0.25.1 → 0.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ehbrs_ruby_utils/bga/parsers/table/players.rb +28 -3
- data/lib/ehbrs_ruby_utils/bga/table_whatsapp_formatter/format_player.rb +1 -1
- data/lib/ehbrs_ruby_utils/version.rb +1 -1
- data/spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_302873643.target.yaml +10 -6
- data/spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_308782287.source.html +1965 -0
- data/spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_308782287.target.yaml +45 -0
- data/spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_356513708.target.yaml +20 -12
- data/spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_357408039.target.yaml +25 -15
- data/spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_368448439.target.yaml +20 -12
- data/spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_373602409.target.yaml +10 -6
- data/spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_373747455.target.yaml +10 -6
- metadata +34 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '01492301e8c9f767213720ca3b78b900225fdb359f6f140ca7b29598af9ce125'
|
4
|
+
data.tar.gz: e6ac5d5ee6b8f2d5e667df6a0eb196283d21be8da3e42636d80fbedfa1be5aec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a47e3110e4640dc017c1265b9bfd0f36661fe3e38379cdcdca9fd7bee8cb40acc6cb1385501f7f57f44a71a7ac0831725c51d4a977b0b7e5c2547298a9e8aeb
|
7
|
+
data.tar.gz: 2354c44fe899307ffba53b2be8843cb542f2095a0dd03efccc566a01fdc0641a699a30d190556febe6e0a7177134c3e94323a2a6a7f90d1c2072e34a68c6f354
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'aranha/parsers/html/item'
|
4
4
|
require 'aranha/parsers/html/item_list'
|
5
|
+
require 'dentaku'
|
5
6
|
require 'eac_ruby_utils/core_ext'
|
6
7
|
|
7
8
|
module EhbrsRubyUtils
|
@@ -10,17 +11,41 @@ module EhbrsRubyUtils
|
|
10
11
|
class Table < ::Aranha::Parsers::Html::Item
|
11
12
|
class Players < ::Aranha::Parsers::Html::ItemList
|
12
13
|
ITEMS_XPATH = '//div[starts-with(@id, "score_entry_")]'
|
14
|
+
RANK_VALUES = { vencedor: 1, perdedor: 2 }.freeze
|
13
15
|
|
14
|
-
field :
|
16
|
+
field :rank, :string, './div[@class = "rank"]'
|
15
17
|
field :id, :integer, './div[@class = "name"]/a/@href'
|
16
18
|
field :name, :string, './div[@class = "name"]/a/text()'
|
17
19
|
field :score, :integer_optional, './div[@class = "score"]'
|
18
|
-
field :
|
19
|
-
field :
|
20
|
+
field :elo_increment, :string, './/*[starts-with(@id, "winpoints_value_")]/text()'
|
21
|
+
field :elo_reached, :integer, './/*[@class = "gamerank_value"]/text()'
|
22
|
+
field :penalty_clock, :boolean,
|
23
|
+
'.//*[@class = "clockpenalty" and @style = "display: inline;"]'
|
24
|
+
field :penalty_leave, :boolean,
|
25
|
+
'.//*[@class = "leavepenalty" and @style = "display: inline;"]'
|
20
26
|
|
21
27
|
def items_xpath
|
22
28
|
ITEMS_XPATH
|
23
29
|
end
|
30
|
+
|
31
|
+
def item_data(data)
|
32
|
+
%i[elo_increment rank].inject(data) do |a, e|
|
33
|
+
a.merge(e => send("process_#{e}", data.fetch(e)))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [Integer, nil]
|
38
|
+
def process_elo_increment(expression)
|
39
|
+
return nil if expression.blank?
|
40
|
+
|
41
|
+
::Dentaku::Calculator.new.evaluate(expression.gsub(/\A\+/, '')).to_i
|
42
|
+
end
|
43
|
+
|
44
|
+
# @param value [String]
|
45
|
+
# @return [Integer]
|
46
|
+
def process_rank(source)
|
47
|
+
RANK_VALUES[source.downcase.to_sym] || source.to_i
|
48
|
+
end
|
24
49
|
end
|
25
50
|
end
|
26
51
|
end
|
@@ -20,16 +20,20 @@
|
|
20
20
|
:value: Desligado
|
21
21
|
:description: ''
|
22
22
|
:players:
|
23
|
-
- :
|
23
|
+
- :rank: 1
|
24
24
|
:id: 84920871
|
25
25
|
:name: eduardobogoni
|
26
26
|
:score: 53
|
27
|
-
:
|
28
|
-
:
|
29
|
-
|
27
|
+
:elo_increment:
|
28
|
+
:elo_reached:
|
29
|
+
:penalty_clock: false
|
30
|
+
:penalty_leave: false
|
31
|
+
- :rank: 2
|
30
32
|
:id: 93167144
|
31
33
|
:name: iuriadmvr1
|
32
34
|
:score: 43
|
33
|
-
:
|
34
|
-
:
|
35
|
+
:elo_increment:
|
36
|
+
:elo_reached:
|
37
|
+
:penalty_clock: false
|
38
|
+
:penalty_leave: false
|
35
39
|
:game_conceded: false
|