ehbrs_ruby_utils 0.41.0 → 0.41.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 586c5869279d721b48b5cf6d6ce585edc26601a00aff87f412fa0cad3142206e
|
4
|
+
data.tar.gz: bf287e776722f8b92f3f7fe7832fdc574251c4ebee744c1f3018ef2957e278d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba4bc8bce782d16640c2e984ffd02f1a4a8dd390921f136321697efc1d3dd03339baeac2722ff5f1d9f858e44f3d616b3bb1b83dca6358d5993f621c3fd6593a
|
7
|
+
data.tar.gz: f9711900cb11defad1165a869e77bdc5ff160b7a070f79870bd927c624871271476505900b1d45dd88bf7598191809879b84fc9c3f40d5f6a37d5302caf47c83
|
@@ -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.1
|
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-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aranha
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
53
|
+
version: '0.9'
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0.
|
60
|
+
version: '0.9'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: avm
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,14 +132,14 @@ dependencies:
|
|
132
132
|
requirements:
|
133
133
|
- - "~>"
|
134
134
|
- !ruby/object:Gem::Version
|
135
|
-
version: '0.
|
135
|
+
version: '0.121'
|
136
136
|
type: :runtime
|
137
137
|
prerelease: false
|
138
138
|
version_requirements: !ruby/object:Gem::Requirement
|
139
139
|
requirements:
|
140
140
|
- - "~>"
|
141
141
|
- !ruby/object:Gem::Version
|
142
|
-
version: '0.
|
142
|
+
version: '0.121'
|
143
143
|
- !ruby/object:Gem::Dependency
|
144
144
|
name: eac_templates
|
145
145
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,6 +147,9 @@ dependencies:
|
|
147
147
|
- - "~>"
|
148
148
|
- !ruby/object:Gem::Version
|
149
149
|
version: '0.5'
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.5.1
|
150
153
|
type: :runtime
|
151
154
|
prerelease: false
|
152
155
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -154,6 +157,9 @@ dependencies:
|
|
154
157
|
- - "~>"
|
155
158
|
- !ruby/object:Gem::Version
|
156
159
|
version: '0.5'
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 0.5.1
|
157
163
|
- !ruby/object:Gem::Dependency
|
158
164
|
name: inifile
|
159
165
|
requirement: !ruby/object:Gem::Requirement
|