ehbrs_ruby_utils 0.41.0 → 0.41.2
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/game_in_progress.rb +22 -12
- data/lib/ehbrs_ruby_utils/bga/session/player_tables_on_game_in_progress.rb +17 -1
- data/lib/ehbrs_ruby_utils/fs/selected/build.rb +2 -0
- data/lib/ehbrs_ruby_utils/fs/selected/build_file.rb +1 -1
- data/lib/ehbrs_ruby_utils/patches/object/template.rb +1 -3
- data/lib/ehbrs_ruby_utils/version.rb +1 -1
- metadata +22 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 890a2f8eebfce6f021bcbbd8ba26651bac76439fde0ae3a94a69a1dee88a41e6
|
4
|
+
data.tar.gz: ac80be08876fe8cb1c3cc26d0a4f18216b2fd1d9bb977e73c12f33377e0081bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0cb5b9f6782c2b21e7b63884e30f726f1b19b22f88da04e423a1c9a1a9777854fe92a7e07a2768255104ef234da00aba9ffbc69cca7a8fb4ccd30cc11a86001
|
7
|
+
data.tar.gz: 792058f84adc1dcede5e9cdd597225018933dfc8dd6467975af8e40bab03996de818a72cd5482b42b83177e40521cef2087ec5ca55972ec99251607afc33a949
|
@@ -7,30 +7,40 @@ module EhbrsRubyUtils
|
|
7
7
|
module Bga
|
8
8
|
module Parsers
|
9
9
|
class GameInProgress < ::Aranha::Parsers::Html::ItemList
|
10
|
-
|
11
|
-
|
10
|
+
DEFAULT_STATUS = 'asyncplay'
|
11
|
+
ID_PARSER = /table=(\d+)/.to_parser { |m| m[1].to_i }
|
12
|
+
ITEMS_XPATH = '//*[@id = "section-play"]//a[contains(@href, "table=")]'
|
12
13
|
STATUS_CLASS_PATTERN = /\Agametable_status_(.+)\z/.freeze
|
13
14
|
STATUS_CLASS_PARSER = STATUS_CLASS_PATTERN.to_parser { |m| m[1] }
|
15
|
+
TABLE_COUNT_XPATH =
|
16
|
+
'//*[@id = "section-play"]/h1/span[contains(@class, "font-normal")]/span/text()'
|
14
17
|
|
15
|
-
field :
|
16
|
-
|
18
|
+
field :href, :string, './@href'
|
19
|
+
|
20
|
+
def data
|
21
|
+
{
|
22
|
+
table_count: table_count,
|
23
|
+
tables: items_data
|
24
|
+
}
|
25
|
+
end
|
17
26
|
|
18
27
|
def item_data(idd)
|
19
|
-
|
20
|
-
idd[key] = send("process_#{key}", idd.fetch(key))
|
21
|
-
end
|
22
|
-
idd
|
28
|
+
{ id: parse_id(idd.fetch(:href)), status: 'asyncplay' }
|
23
29
|
end
|
24
30
|
|
25
31
|
def items_xpath
|
26
32
|
ITEMS_XPATH
|
27
33
|
end
|
28
34
|
|
29
|
-
|
35
|
+
# @param href [String]
|
36
|
+
# @return [Integer]
|
37
|
+
def parse_id(href)
|
38
|
+
ID_PARSER.parse!(href)
|
39
|
+
end
|
30
40
|
|
31
|
-
|
32
|
-
|
33
|
-
|
41
|
+
# @return [Integer]
|
42
|
+
def table_count
|
43
|
+
nokogiri.at_xpath(TABLE_COUNT_XPATH).if_present(-1) { |v| v.text.to_i }
|
34
44
|
end
|
35
45
|
end
|
36
46
|
end
|
@@ -13,6 +13,8 @@ module EhbrsRubyUtils
|
|
13
13
|
enable_simple_cache
|
14
14
|
common_constructor :session, :player_id
|
15
15
|
|
16
|
+
WAIT_FOR_RESULT_SECONDS = 60
|
17
|
+
|
16
18
|
def result
|
17
19
|
navigate_to_page
|
18
20
|
result_data
|
@@ -25,14 +27,28 @@ module EhbrsRubyUtils
|
|
25
27
|
|
26
28
|
private
|
27
29
|
|
30
|
+
def current_data
|
31
|
+
::EhbrsRubyUtils::Bga::Parsers::GameInProgress.from_content(session.current_source).data
|
32
|
+
end
|
33
|
+
|
28
34
|
# @return [Array<Hash>]
|
29
35
|
def result_data
|
30
|
-
|
36
|
+
cr = nil
|
37
|
+
session.wait(WAIT_FOR_RESULT_SECONDS).until do
|
38
|
+
scroll_down
|
39
|
+
cr = current_data
|
40
|
+
cr.fetch(:tables).count == cr.fetch(:table_count)
|
41
|
+
end
|
42
|
+
cr.fetch(:tables)
|
31
43
|
end
|
32
44
|
|
33
45
|
def navigate_to_page
|
34
46
|
session.navigate.to url
|
35
47
|
end
|
48
|
+
|
49
|
+
def scroll_down
|
50
|
+
session.execute_script('window.scrollBy(0, 90)')
|
51
|
+
end
|
36
52
|
end
|
37
53
|
end
|
38
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ehbrs_ruby_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.41.
|
4
|
+
version: 0.41.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo H. Bogoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aranha
|
@@ -50,34 +50,40 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
53
|
+
version: '0.10'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.10.1
|
54
57
|
type: :runtime
|
55
58
|
prerelease: false
|
56
59
|
version_requirements: !ruby/object:Gem::Requirement
|
57
60
|
requirements:
|
58
61
|
- - "~>"
|
59
62
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0.
|
63
|
+
version: '0.10'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.10.1
|
61
67
|
- !ruby/object:Gem::Dependency
|
62
68
|
name: avm
|
63
69
|
requirement: !ruby/object:Gem::Requirement
|
64
70
|
requirements:
|
65
71
|
- - "~>"
|
66
72
|
- !ruby/object:Gem::Version
|
67
|
-
version: '0.
|
73
|
+
version: '0.90'
|
68
74
|
- - ">="
|
69
75
|
- !ruby/object:Gem::Version
|
70
|
-
version: 0.
|
76
|
+
version: 0.90.1
|
71
77
|
type: :runtime
|
72
78
|
prerelease: false
|
73
79
|
version_requirements: !ruby/object:Gem::Requirement
|
74
80
|
requirements:
|
75
81
|
- - "~>"
|
76
82
|
- !ruby/object:Gem::Version
|
77
|
-
version: '0.
|
83
|
+
version: '0.90'
|
78
84
|
- - ">="
|
79
85
|
- !ruby/object:Gem::Version
|
80
|
-
version: 0.
|
86
|
+
version: 0.90.1
|
81
87
|
- !ruby/object:Gem::Dependency
|
82
88
|
name: dentaku
|
83
89
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,14 +138,14 @@ dependencies:
|
|
132
138
|
requirements:
|
133
139
|
- - "~>"
|
134
140
|
- !ruby/object:Gem::Version
|
135
|
-
version: '0.
|
141
|
+
version: '0.121'
|
136
142
|
type: :runtime
|
137
143
|
prerelease: false
|
138
144
|
version_requirements: !ruby/object:Gem::Requirement
|
139
145
|
requirements:
|
140
146
|
- - "~>"
|
141
147
|
- !ruby/object:Gem::Version
|
142
|
-
version: '0.
|
148
|
+
version: '0.121'
|
143
149
|
- !ruby/object:Gem::Dependency
|
144
150
|
name: eac_templates
|
145
151
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,6 +153,9 @@ dependencies:
|
|
147
153
|
- - "~>"
|
148
154
|
- !ruby/object:Gem::Version
|
149
155
|
version: '0.5'
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: 0.5.1
|
150
159
|
type: :runtime
|
151
160
|
prerelease: false
|
152
161
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -154,6 +163,9 @@ dependencies:
|
|
154
163
|
- - "~>"
|
155
164
|
- !ruby/object:Gem::Version
|
156
165
|
version: '0.5'
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: 0.5.1
|
157
169
|
- !ruby/object:Gem::Dependency
|
158
170
|
name: inifile
|
159
171
|
requirement: !ruby/object:Gem::Requirement
|