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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a44e90ef4da84b99b3b0f0ec915528e06feef36f88ac6e1a89d7b6cd2dfa4a85
4
- data.tar.gz: 236d80b4491da318c1f5bc6ff6336ca9db5ddbb47b36e0222f817f906796e518
3
+ metadata.gz: 890a2f8eebfce6f021bcbbd8ba26651bac76439fde0ae3a94a69a1dee88a41e6
4
+ data.tar.gz: ac80be08876fe8cb1c3cc26d0a4f18216b2fd1d9bb977e73c12f33377e0081bb
5
5
  SHA512:
6
- metadata.gz: 3d2ef32002c18d1a907989c1cd11f423bd010e4f03af74a857a4ee9c046bbd9ca5f22015f82f1711191918da22da320ace42e70f49de6f14b36cd1d624cb9d48
7
- data.tar.gz: 6f9eef1ee52d3f97517448a03a346d6b392fecd4e26d064b7afa2b1eeddb0e530afffa6d3f25118752004c48d1be1ee382c11426156ae39ffec507ada037cb6d
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
- 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
@@ -25,6 +25,8 @@ module EhbrsRubyUtils
25
25
  private
26
26
 
27
27
  def clear_target_dir
28
+ return unless target_dir.exist?
29
+
28
30
  target_dir.children.each do |c|
29
31
  c.unlink if c.symlink? && c.directory?
30
32
  end
@@ -11,7 +11,7 @@ module EhbrsRubyUtils
11
11
  end
12
12
 
13
13
  def perform
14
- target_path.make_symlink(path)
14
+ target_path.assert_parent.make_symlink(path)
15
15
  end
16
16
 
17
17
  def target_path
@@ -1,6 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_templates/patches/object/template'
4
-
5
- EacTemplates::Searcher.default.included_paths <<
6
- File.expand_path('../../../../template', __dir__)
4
+ require 'eac_templates/sources/from_all_gems'
@@ -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.2'
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.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-01-17 00:00:00.000000000 Z
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.8'
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.8'
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.84'
73
+ version: '0.90'
68
74
  - - ">="
69
75
  - !ruby/object:Gem::Version
70
- version: 0.84.2
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.84'
83
+ version: '0.90'
78
84
  - - ">="
79
85
  - !ruby/object:Gem::Version
80
- version: 0.84.2
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.120'
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.120'
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