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: a44e90ef4da84b99b3b0f0ec915528e06feef36f88ac6e1a89d7b6cd2dfa4a85
4
- data.tar.gz: 236d80b4491da318c1f5bc6ff6336ca9db5ddbb47b36e0222f817f906796e518
3
+ metadata.gz: 586c5869279d721b48b5cf6d6ce585edc26601a00aff87f412fa0cad3142206e
4
+ data.tar.gz: bf287e776722f8b92f3f7fe7832fdc574251c4ebee744c1f3018ef2957e278d7
5
5
  SHA512:
6
- metadata.gz: 3d2ef32002c18d1a907989c1cd11f423bd010e4f03af74a857a4ee9c046bbd9ca5f22015f82f1711191918da22da320ace42e70f49de6f14b36cd1d624cb9d48
7
- data.tar.gz: 6f9eef1ee52d3f97517448a03a346d6b392fecd4e26d064b7afa2b1eeddb0e530afffa6d3f25118752004c48d1be1ee382c11426156ae39ffec507ada037cb6d
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
- ITEMS_XPATH = '//*[@id = "gametables_inprogress_all"]' \
11
- '//*[starts-with(@id, "gametableblock_")]'
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 :id, :integer, './@id'
16
- field :status, :string, './@class'
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
- %i[status].each do |key|
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
- private
35
+ # @param href [String]
36
+ # @return [Integer]
37
+ def parse_id(href)
38
+ ID_PARSER.parse!(href)
39
+ end
30
40
 
31
- def process_status(status)
32
- status.split.lazy.map { |s| STATUS_CLASS_PARSER.parse(s.strip) }.find(&:present?) ||
33
- raise("No status class found in \"#{status}\"")
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
- ::EhbrsRubyUtils::Bga::Parsers::GameInProgress.from_content(session.current_source).data
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EhbrsRubyUtils
4
- VERSION = '0.41.0'
4
+ VERSION = '0.41.1'
5
5
  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.0
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-01-17 00:00:00.000000000 Z
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.8'
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.8'
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.120'
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.120'
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