ehbrs_ruby_utils 0.26.0 → 0.27.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: '01492301e8c9f767213720ca3b78b900225fdb359f6f140ca7b29598af9ce125'
4
- data.tar.gz: e6ac5d5ee6b8f2d5e667df6a0eb196283d21be8da3e42636d80fbedfa1be5aec
3
+ metadata.gz: c871abaf7dc4060d3d4165e5e0ac29e083ff688c87972b008578ad7c6ee3b51c
4
+ data.tar.gz: 56a62fcdb9ac75d7e5fed15c145dd14b36b207628499108781337b870001147a
5
5
  SHA512:
6
- metadata.gz: 3a47e3110e4640dc017c1265b9bfd0f36661fe3e38379cdcdca9fd7bee8cb40acc6cb1385501f7f57f44a71a7ac0831725c51d4a977b0b7e5c2547298a9e8aeb
7
- data.tar.gz: 2354c44fe899307ffba53b2be8843cb542f2095a0dd03efccc566a01fdc0641a699a30d190556febe6e0a7177134c3e94323a2a6a7f90d1c2072e34a68c6f354
6
+ metadata.gz: 238cdc34f19c2b8c45ef4280ddac58f0f10ac6354df28c6d3fadf6d52999f4cfd7c4464c36e8b2c3353dcb11dae5bbb56f29d4fc9c110cea960d2d259952cc9c
7
+ data.tar.gz: 0d6a2de37a8b40a4005b6dd6cd9363f4a7f730bf4e474307e15939ce5d902ab7ccfe1bce6e7f4f04d9021f7201783e7d58ad10c51adc17a85c33b9aca282ddca
@@ -10,13 +10,6 @@ module EhbrsRubyUtils
10
10
  USERNAME_INPUT_ID = 'username_input'
11
11
  PASSWORD_INPUT_ID = 'password_input'
12
12
  SUBMIT_ID = 'login_button'
13
- LOGGED_MESSAGE_PATTERNS = [
14
- /Page not found/ # Page not found: join.js
15
- ].freeze
16
- UNLOGGED_MESSAGE_PATTERSN = [
17
- /Recover my password/ # Oops, we don't recognize your username or password. Don't panic.
18
- # (Recover my password)
19
- ].freeze
20
13
 
21
14
  # @return [Boolean]
22
15
  def login
@@ -24,7 +17,7 @@ module EhbrsRubyUtils
24
17
  input_username
25
18
  input_password
26
19
  submit_login
27
- logged_by_message?(waited_message_info)
20
+ logged?
28
21
  end
29
22
 
30
23
  def login_url
@@ -48,14 +41,6 @@ module EhbrsRubyUtils
48
41
  def submit_login
49
42
  wait_for_click(id: SUBMIT_ID)
50
43
  end
51
-
52
- # @return [Boolean]
53
- def logged_by_message?(message_info)
54
- return true if LOGGED_MESSAGE_PATTERNS.any? { |p| p.match?(message_info) }
55
- return false if UNLOGGED_MESSAGE_PATTERNS.any? { |p| p.match?(message_info) }
56
-
57
- raise("Unmapped login message: \"#{message_info}\"")
58
- end
59
44
  end
60
45
  end
61
46
  end
@@ -37,7 +37,7 @@ module EhbrsRubyUtils
37
37
 
38
38
  # @return [Boolean]
39
39
  def skip_trophy_overlay?
40
- find_element(xpath: TROPHY_SKIP_BUTTON_XPATH).present?
40
+ find_or_not_element(xpath: TROPHY_SKIP_BUTTON_XPATH).present?
41
41
  end
42
42
  end
43
43
  end
@@ -14,6 +14,8 @@ module EhbrsRubyUtils
14
14
  enable_simple_cache
15
15
  common_constructor :session, :table_id
16
16
 
17
+ RESULTS_XPATH = '//*[@id = "game_result"]'
18
+
17
19
  def result
18
20
  ::EhbrsRubyUtils::Bga::Table.new(
19
21
  fetch_data
@@ -29,6 +31,7 @@ module EhbrsRubyUtils
29
31
 
30
32
  def fetch_data
31
33
  session.navigate.to url
34
+ session.wait_for_element(xpath: RESULTS_XPATH)
32
35
  { id: table_id }.merge(
33
36
  ::EhbrsRubyUtils::Bga::Parsers::Table.from_content(session.current_source).data
34
37
  )
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EhbrsRubyUtils
6
+ module Bga
7
+ class Session < ::SimpleDelegator
8
+ module User
9
+ # @return [Boolean]
10
+ def logged?
11
+ navigate.to(build_url('/player'))
12
+ logged_username == username
13
+ end
14
+
15
+ # @return [String]
16
+ def logged_username
17
+ find_or_not_element(xpath: '//*[@id = "connected_username"]').attribute('innerHTML').strip
18
+ end
19
+
20
+ def on_logged(&block)
21
+ unless logged?
22
+ raise "Login failed for BoardGameUser user \"#{username}\"" unless login
23
+ end
24
+
25
+ block.call
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -10,7 +10,8 @@ module EhbrsRubyUtils
10
10
  include ::EhbrsRubyUtils::Bga::Urls
11
11
  MESSAGE_ID = 'head_infomsg_1'
12
12
 
13
- common_constructor :username, :password, super_args: -> { [::Aranha::Selenium::Session.new] }
13
+ common_constructor :username, :password,
14
+ super_args: -> { [::Aranha::Selenium::Session.new(driver: :chrome)] }
14
15
 
15
16
  # @return [EhbrsRubyUtils::Bga::Session::Player]
16
17
  def player(id)
@@ -22,11 +23,6 @@ module EhbrsRubyUtils
22
23
  find_or_not_element(id: MESSAGE_ID).if_present { |v| v.text.strip }
23
24
  end
24
25
 
25
- # @return [String]
26
- def waited_message_info
27
- wait_for_click(id: MESSAGE_ID).text
28
- end
29
-
30
26
  require_sub __FILE__, include_modules: true, require_mode: :kernel
31
27
  end
32
28
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'ehbrs_ruby_utils/bga/parsers/table'
3
4
  require 'ehbrs_ruby_utils/bga/parsers/table/options'
4
5
  require 'ehbrs_ruby_utils/bga/urls'
5
6
  require 'eac_ruby_utils/core_ext'
@@ -21,11 +21,6 @@ module EhbrsRubyUtils
21
21
  }.freeze
22
22
  SECTION_SEPARATOR = "\n\n"
23
23
 
24
- def perform
25
- infov 'Fetching table', table_id
26
- infov 'Message', "<<<EOS\n#{to_message}\nEOS\n"
27
- end
28
-
29
24
  def to_s
30
25
  [root_items_to_s, players_to_s, options_to_s].map(&:strip).join(SECTION_SEPARATOR)
31
26
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EhbrsRubyUtils
4
- VERSION = '0.26.0'
4
+ VERSION = '0.27.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.26.0
4
+ version: 0.27.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: 2023-06-02 00:00:00.000000000 Z
11
+ date: 2023-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha
@@ -50,34 +50,28 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0.6'
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 0.6.1
53
+ version: '0.7'
57
54
  type: :runtime
58
55
  prerelease: false
59
56
  version_requirements: !ruby/object:Gem::Requirement
60
57
  requirements:
61
58
  - - "~>"
62
59
  - !ruby/object:Gem::Version
63
- version: '0.6'
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 0.6.1
60
+ version: '0.7'
67
61
  - !ruby/object:Gem::Dependency
68
62
  name: avm
69
63
  requirement: !ruby/object:Gem::Requirement
70
64
  requirements:
71
65
  - - "~>"
72
66
  - !ruby/object:Gem::Version
73
- version: '0.76'
67
+ version: '0.78'
74
68
  type: :runtime
75
69
  prerelease: false
76
70
  version_requirements: !ruby/object:Gem::Requirement
77
71
  requirements:
78
72
  - - "~>"
79
73
  - !ruby/object:Gem::Version
80
- version: '0.76'
74
+ version: '0.78'
81
75
  - !ruby/object:Gem::Dependency
82
76
  name: dentaku
83
77
  requirement: !ruby/object:Gem::Requirement
@@ -248,6 +242,7 @@ files:
248
242
  - lib/ehbrs_ruby_utils/bga/session/player_tables_on_game_stats.rb
249
243
  - lib/ehbrs_ruby_utils/bga/session/skip_trophies.rb
250
244
  - lib/ehbrs_ruby_utils/bga/session/table.rb
245
+ - lib/ehbrs_ruby_utils/bga/session/user.rb
251
246
  - lib/ehbrs_ruby_utils/bga/table.rb
252
247
  - lib/ehbrs_ruby_utils/bga/table/option.rb
253
248
  - lib/ehbrs_ruby_utils/bga/table/player.rb