ehbrs_ruby_utils 0.26.0 → 0.27.0

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: a5dec5f4f8ddd8f557593ebf6996da07a0068037d60b944d7dd026df93ad41bd
4
+ data.tar.gz: d13e4169174f00b947f1c057112d7390ded0322266f24a36df38bc623441c0e2
5
5
  SHA512:
6
- metadata.gz: 3a47e3110e4640dc017c1265b9bfd0f36661fe3e38379cdcdca9fd7bee8cb40acc6cb1385501f7f57f44a71a7ac0831725c51d4a977b0b7e5c2547298a9e8aeb
7
- data.tar.gz: 2354c44fe899307ffba53b2be8843cb542f2095a0dd03efccc566a01fdc0641a699a30d190556febe6e0a7177134c3e94323a2a6a7f90d1c2072e34a68c6f354
6
+ metadata.gz: 9b6f2c93327cfaeedef1a4e73636cd39818d0c65ced4e8573089c91bc4b96dc8e27b471676a8546adef346140db32eaf8d84f3e1a81012a1cfc711e22f348059
7
+ data.tar.gz: 5e8b0aa58cdbd8e75cf53296ff0b8936093f333131293fbcf37ff890b3ae6398a5f14b79b6a04308f9906f0f50bc8e52a9548d4e676dd9859fd64ea7e0ac26d0
@@ -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,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EhbrsRubyUtils
4
- VERSION = '0.26.0'
4
+ VERSION = '0.27.0'
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.0
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-09 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.77'
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.77'
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
@@ -398,50 +393,50 @@ signing_key:
398
393
  specification_version: 4
399
394
  summary: Utilities for EHB/RS's Ruby projects.
400
395
  test_files:
401
- - spec/rubocop_check_spec.rb
396
+ - spec/spec_helper.rb
397
+ - spec/lib/ehbrs_ruby_utils/circular_list_spreader_spec.rb
398
+ - spec/lib/ehbrs_ruby_utils/videos/stream_spec_files/menina_ovo_attachment.target.yaml
399
+ - spec/lib/ehbrs_ruby_utils/videos/stream_spec_files/menina_ovo_subtitle.target.yaml
400
+ - spec/lib/ehbrs_ruby_utils/videos/stream_spec_files/menina_ovo_attachment.source.yaml
401
+ - spec/lib/ehbrs_ruby_utils/videos/stream_spec_files/menina_ovo_video.source.yaml
402
+ - spec/lib/ehbrs_ruby_utils/videos/stream_spec_files/menina_ovo_subtitle.source.yaml
403
+ - spec/lib/ehbrs_ruby_utils/videos/stream_spec_files/menina_ovo_video.target.yaml
404
+ - spec/lib/ehbrs_ruby_utils/videos/stream_spec_files/menina_ovo_audio.target.yaml
405
+ - spec/lib/ehbrs_ruby_utils/videos/stream_spec_files/menina_ovo_audio.source.yaml
406
+ - spec/lib/ehbrs_ruby_utils/videos/resolution_spec.rb
407
+ - spec/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/episode_spec.rb
408
+ - spec/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/title_spec.rb
409
+ - spec/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/episode_spec_files/counterpart_s01e01.target.yaml
410
+ - spec/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/episode_spec_files/wire-season-1-page-1.target.yaml
411
+ - spec/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/episode_spec_files/counterpart_s01e01.source.html
412
+ - spec/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/episode_spec_files/wire-season-1-page-1.source.html
413
+ - spec/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/title_spec_files/countepart.source.html
414
+ - spec/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/title_spec_files/countepart.target.yaml
415
+ - spec/lib/ehbrs_ruby_utils/videos/stream_spec.rb
402
416
  - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_308782287.target.yaml
403
- - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_356513708.target.yaml
404
- - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_302873643.target.yaml
405
417
  - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_368448439.target.yaml
406
- - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_368448439.source.html
407
- - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_357408039.source.html
408
418
  - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_356513708.source.html
419
+ - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_357408039.source.html
420
+ - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_356513708.target.yaml
421
+ - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_373747455.target.yaml
422
+ - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_302873643.target.yaml
409
423
  - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_373747455.source.html
410
- - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_373602409.source.html
411
- - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_373602409.target.yaml
412
424
  - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_302873643.source.html
413
- - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_357408039.target.yaml
425
+ - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_373602409.target.yaml
414
426
  - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_308782287.source.html
415
- - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_373747455.target.yaml
416
- - spec/lib/ehbrs_ruby_utils/bga/parsers/game_stats_spec_files/2.target.yaml
417
- - spec/lib/ehbrs_ruby_utils/bga/parsers/game_stats_spec_files/2.source.html
427
+ - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_368448439.source.html
428
+ - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_373602409.source.html
429
+ - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec_files/table_357408039.target.yaml
418
430
  - spec/lib/ehbrs_ruby_utils/bga/parsers/game_stats_spec_files/1.source.html
431
+ - spec/lib/ehbrs_ruby_utils/bga/parsers/game_stats_spec_files/2.target.yaml
419
432
  - spec/lib/ehbrs_ruby_utils/bga/parsers/game_stats_spec_files/1.target.yaml
433
+ - spec/lib/ehbrs_ruby_utils/bga/parsers/game_stats_spec_files/2.source.html
420
434
  - spec/lib/ehbrs_ruby_utils/bga/parsers/game_stats_spec.rb
421
435
  - spec/lib/ehbrs_ruby_utils/bga/parsers/table_spec.rb
422
- - spec/lib/ehbrs_ruby_utils/circular_list_spreader_spec.rb
423
- - spec/lib/ehbrs_ruby_utils/circular_list_spreader_spec_files/minimum.target.yaml
424
- - spec/lib/ehbrs_ruby_utils/circular_list_spreader_spec_files/ehbrs_music1.source.yaml
425
436
  - spec/lib/ehbrs_ruby_utils/circular_list_spreader_spec_files/minimum.source.yaml
437
+ - spec/lib/ehbrs_ruby_utils/circular_list_spreader_spec_files/minimum.target.yaml
426
438
  - spec/lib/ehbrs_ruby_utils/circular_list_spreader_spec_files/ehbrs_music1.target.yaml
427
- - spec/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/title_spec_files/countepart.target.yaml
428
- - spec/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/title_spec_files/countepart.source.html
429
- - spec/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/title_spec.rb
430
- - spec/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/episode_spec.rb
431
- - spec/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/episode_spec_files/counterpart_s01e01.source.html
432
- - spec/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/episode_spec_files/wire-season-1-page-1.target.yaml
433
- - spec/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/episode_spec_files/wire-season-1-page-1.source.html
434
- - spec/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/episode_spec_files/counterpart_s01e01.target.yaml
435
- - spec/lib/ehbrs_ruby_utils/videos/stream_spec.rb
436
- - spec/lib/ehbrs_ruby_utils/videos/stream_spec_files/menina_ovo_audio.target.yaml
437
- - spec/lib/ehbrs_ruby_utils/videos/stream_spec_files/menina_ovo_video.target.yaml
438
- - spec/lib/ehbrs_ruby_utils/videos/stream_spec_files/menina_ovo_attachment.target.yaml
439
- - spec/lib/ehbrs_ruby_utils/videos/stream_spec_files/menina_ovo_subtitle.target.yaml
440
- - spec/lib/ehbrs_ruby_utils/videos/stream_spec_files/menina_ovo_audio.source.yaml
441
- - spec/lib/ehbrs_ruby_utils/videos/stream_spec_files/menina_ovo_attachment.source.yaml
442
- - spec/lib/ehbrs_ruby_utils/videos/stream_spec_files/menina_ovo_subtitle.source.yaml
443
- - spec/lib/ehbrs_ruby_utils/videos/stream_spec_files/menina_ovo_video.source.yaml
444
- - spec/lib/ehbrs_ruby_utils/videos/resolution_spec.rb
445
- - spec/spec_helper.rb
439
+ - spec/lib/ehbrs_ruby_utils/circular_list_spreader_spec_files/ehbrs_music1.source.yaml
440
+ - spec/rubocop_check_spec.rb
446
441
  - ".rubocop.yml"
447
442
  - ".rspec"