ehbrs_ruby_utils 0.50.2 → 0.51.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 313577609ee6eb941fe4555a69dd45857adabbe01969cabf59c3fae4021aa07c
4
- data.tar.gz: d23750e408c10e7724fb7292504a601ff6d8118823f881ff6f41f9febaca4fee
3
+ metadata.gz: 5d25c7ea513dfe3f38866c73e9de18fb6793dda8f9937c295b5732ceda50661b
4
+ data.tar.gz: c3dda1034ece0d7beded26fb17a81169e37f0d48dc159bf1f90bfad2a4995a74
5
5
  SHA512:
6
- metadata.gz: 11dadee80b32212622c880e31c379cae640df69cb101b77d51fe5de0e89753ce879705615f2bc1c4e0eda9a4c7e0b3bd9e6ef68482817642d41a77c6bad06256
7
- data.tar.gz: 7e1628e39e81cfc507bf1151cd7ae89e9c5a28ecf4a7187971cc1a7f00eed40cc153ce22abb5dc25153d52ecb07eda21eef1150b5c72cd73de528efec48c5ca5
6
+ metadata.gz: d221454359c3f2869d0e7c0272276087cfe09140bb8b54a16437c9d0e229aec92dd27e31419739bbb15456ea20ea7110f1a6bca8b1c7267eaa1cff2ed2da56fc
7
+ data.tar.gz: ba4a0901a5b41e428b35acb664ffc0a5ca84019e521ce2860e46ee8ee1a4c47ef85f5e864818826b095b1f47661a3cfb79a370cd735ca7482d96f36e26b4781d
@@ -9,14 +9,16 @@ module EhbrsRubyUtils
9
9
 
10
10
  # @return [Enumerable<Hash>]
11
11
  def accommodations
12
- current_url = url
13
- index = 0
14
- r = []
15
- while current_url.present?
16
- accommodations, current_url, index = page_accommodations(current_url, index)
17
- r += accommodations
12
+ session.quit_on_end do
13
+ current_url = url
14
+ index = 0
15
+ r = []
16
+ while current_url.present?
17
+ accommodations, current_url, index = page_accommodations(current_url, index)
18
+ r += accommodations
19
+ end
20
+ r
18
21
  end
19
- r
20
22
  end
21
23
 
22
24
  # @return [Integer]
@@ -2,7 +2,7 @@
2
2
 
3
3
  module EhbrsRubyUtils
4
4
  module Bga
5
- class Session < ::SimpleDelegator
5
+ class Session < ::Aranha::Selenium::Session
6
6
  module CookiesConsent
7
7
  REJECT_ALL_BUTTON_SELECTOR = { id: 'didomi-notice-disagree-button' }.freeze
8
8
  REJECT_ALL_BUTTON_TIMEOUT = 5
@@ -2,7 +2,7 @@
2
2
 
3
3
  module EhbrsRubyUtils
4
4
  module Bga
5
- class Session < ::SimpleDelegator
5
+ class Session < ::Aranha::Selenium::Session
6
6
  module Login
7
7
  LOGIN_PATH = 'account'
8
8
  STEP1_SELECTOR = { css: '.bga-account-manager-form__step1' }.freeze
@@ -2,7 +2,7 @@
2
2
 
3
3
  module EhbrsRubyUtils
4
4
  module Bga
5
- class Session < ::SimpleDelegator
5
+ class Session < ::Aranha::Selenium::Session
6
6
  class Player
7
7
  common_constructor :session, :player_id
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module EhbrsRubyUtils
4
4
  module Bga
5
- class Session < ::SimpleDelegator
5
+ class Session < ::Aranha::Selenium::Session
6
6
  class PlayerTablesOnGameInProgress
7
7
  include ::EhbrsRubyUtils::Bga::Urls
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module EhbrsRubyUtils
4
4
  module Bga
5
- class Session < ::SimpleDelegator
5
+ class Session < ::Aranha::Selenium::Session
6
6
  class PlayerTablesOnGameStats
7
7
  include ::EhbrsRubyUtils::Bga::Urls
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module EhbrsRubyUtils
4
4
  module Bga
5
- class Session < ::SimpleDelegator
5
+ class Session < ::Aranha::Selenium::Session
6
6
  module SkipTrophies
7
7
  TROPHY_SKIP_BUTTON_XPATH = '//*[@id = "splashedNotifications_overlay"]' \
8
8
  '//*[starts-with(@id, "continue_btn_")]'
@@ -2,7 +2,7 @@
2
2
 
3
3
  module EhbrsRubyUtils
4
4
  module Bga
5
- class Session < ::SimpleDelegator
5
+ class Session < ::Aranha::Selenium::Session
6
6
  class Table
7
7
  include ::EhbrsRubyUtils::Bga::Urls
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module EhbrsRubyUtils
4
4
  module Bga
5
- class Session < ::SimpleDelegator
5
+ class Session < ::Aranha::Selenium::Session
6
6
  module User
7
7
  # @return [Boolean]
8
8
  def logged?
@@ -2,13 +2,15 @@
2
2
 
3
3
  module EhbrsRubyUtils
4
4
  module Bga
5
- class Session < ::SimpleDelegator
5
+ class Session < ::Aranha::Selenium::Session
6
6
  include ::EhbrsRubyUtils::Bga::Urls
7
7
 
8
8
  MESSAGE_ID = 'head_infomsg_1'
9
9
 
10
- common_constructor :username, :password,
11
- super_args: -> { [::Aranha::Selenium::Session.new(driver: :chrome)] }
10
+ # @!method initialize(username, password)
11
+ # @param username [String]
12
+ # @param password [String]
13
+ common_constructor :username, :password, super_args: -> { [{ driver: :chrome }] }
12
14
 
13
15
  # @return [EhbrsRubyUtils::Bga::Session::Player]
14
16
  def player(id)
@@ -30,6 +30,11 @@ module EhbrsRubyUtils
30
30
  session.element(xpath: CLOSE_BANNER_XPATH)
31
31
  end
32
32
 
33
+ # @return [Hash]
34
+ def data
35
+ @data ||= session.quit_on_end { super }
36
+ end
37
+
33
38
  # @return [Aranha::Selenium::Session::Element]
34
39
  def more_results_button
35
40
  session.element(xpath: MORE_RESULTS_XPATH)
@@ -26,13 +26,12 @@ module EhbrsRubyUtils
26
26
  )
27
27
  end
28
28
 
29
+ # @yieldparam bga_session [EhbrsRubyUtils::Bga::Session]
30
+ # @return [Object]
31
+ # @raise [RuntimeError]
29
32
  def on_bga_logged_session(&block)
30
- bga_session = new_bga_session
31
- begin
33
+ new_bga_session.quit_on_end do |bga_session|
32
34
  bga_session.on_logged { block.call(bga_session) }
33
- ensure
34
- bga_session.close
35
- bga_session = nil
36
35
  end
37
36
  end
38
37
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EhbrsRubyUtils
4
- VERSION = '0.50.2'
4
+ VERSION = '0.51.1'
5
5
  end
@@ -1,44 +1,55 @@
1
- FROM ubuntu:18.04
2
-
3
- ENV DEBIAN_FRONTEND=noninteractive
4
- ENV USER_UID=1000
5
- ENV USER_GID=1000
6
- ENV USERNAME=user
7
-
8
- # sudo gosu \
9
-
10
- RUN ln -sf /bin/true /usr/bin/chfn && apt-get update && apt-get install -y \
11
- libnss3-tools \
12
- zenity \
13
- libgtk2.0-0 \
1
+ FROM debian:trixie-slim
2
+
3
+ ARG DEBIAN_MIRROR=http://ftp.br.debian.org
4
+ ARG WARSAW_URL=https://guardiao.itau.com.br/warsaw/warsaw_ubuntu.run
5
+ ARG WARSAW_SHA256=7b7e27961ccfb5ed9fb9d5eef00a44db81a6a0e778f96886464ffcacc28b9144
6
+
7
+ ENV DEBIAN_FRONTEND=noninteractive \
8
+ LANG=C.UTF-8 \
9
+ RESOLUTION=1366x768 \
10
+ START_URL=https://www.bb.com.br \
11
+ USER_GID=1000 \
12
+ USER_UID=1000
13
+
14
+ RUN sed -i "s#http://deb.debian.org#$DEBIAN_MIRROR#" /etc/apt/sources.list.d/debian.sources \
15
+ && apt-get update \
16
+ && apt-get install -y --no-install-recommends \
17
+ ca-certificates \
18
+ curl \
14
19
  dbus-x11 \
15
- yad \
16
- libcurl3 \
17
- libdbus-1.3 \
18
- libxss1 \
19
- lsb-release \
20
- net-tools \
21
- openssl \
22
- firefox \
23
- systemd \
24
- systemd-sysv
25
-
26
-
27
- ADD https://cloud.gastecnologia.com.br/cef/warsaw/install/GBPCEFwr64.deb /src/warsaw.deb
28
- RUN groupadd -g ${USER_GID} user && useradd -u ${USER_UID} -g ${USER_GID} -ms /bin/bash user && chown -R user.user /home/user
29
-
30
- #RUN dpkg -i /w.deb || exit 0
31
-
32
- COPY context/firefox.service /etc/systemd/system/
33
- COPY context/startbrowser.sh /usr/local/bin/
20
+ firefox-esr \
21
+ firefox-esr-l10n-pt-br \
22
+ fonts-dejavu \
23
+ fonts-liberation \
24
+ libarchive-tools \
25
+ libdbus-1-3 \
26
+ novnc \
27
+ openbox \
28
+ procps \
29
+ python3 \
30
+ tigervnc-standalone-server \
31
+ tigervnc-tools \
32
+ websockify \
33
+ zenity \
34
+ && rm -rf /var/lib/apt/lists/*
34
35
 
35
- # systemctl enable warsaw && \
36
+ RUN curl -fsSLo /tmp/warsaw.run "$WARSAW_URL" \
37
+ && echo "$WARSAW_SHA256 /tmp/warsaw.run" | sha256sum -c - \
38
+ && bsdtar -xf /tmp/warsaw.run -C /tmp --strip-components 1 'warsaw_setup/warsaw_*_amd64.deb' \
39
+ && printf '#!/bin/sh\nexit 101\n' > /usr/sbin/policy-rc.d \
40
+ && chmod +x /usr/sbin/policy-rc.d \
41
+ && touch /tmp/EULA \
42
+ && apt-get update \
43
+ && apt-get install -y --no-install-recommends /tmp/warsaw_*_amd64.deb \
44
+ && { pkill -f -x /usr/local/bin/warsaw/core || :; } \
45
+ && rm -rf /tmp/warsaw* /usr/sbin/policy-rc.d /var/lib/apt/lists/*
36
46
 
37
- RUN mkdir -p /var/run/dbus && \
38
- systemctl enable firefox && \
39
- systemctl disable systemd-resolved && systemctl disable systemd-tmpfiles-setup.service
47
+ COPY policies.json /usr/lib/firefox-esr/distribution/policies.json
48
+ COPY entrypoint.sh /usr/local/bin/entrypoint.sh
40
49
 
41
- STOPSIGNAL SIGRTMIN+3
50
+ RUN useradd --create-home --shell /bin/bash browser \
51
+ && install -d -m 1777 /tmp/.X11-unix
42
52
 
53
+ EXPOSE 6080
43
54
 
44
- ENTRYPOINT [ "/sbin/init" ]
55
+ ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
@@ -0,0 +1,87 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ export DISPLAY=:1
5
+
6
+ readonly BROWSER_USER='browser'
7
+ readonly BROWSER_HOME="/home/$BROWSER_USER"
8
+ readonly NOVNC_PORT=6080
9
+ readonly PROFILE_DIR="$BROWSER_HOME/.mozilla/firefox/bb"
10
+ readonly VNC_PASSWORD_FILE="$BROWSER_HOME/.vnc/passwd"
11
+ readonly VNC_PORT=5900
12
+ readonly WARSAW_CORE='/usr/local/bin/warsaw/core'
13
+
14
+ apply_host_ids() {
15
+ groupmod -g "$USER_GID" "$BROWSER_USER"
16
+ usermod -u "$USER_UID" -g "$USER_GID" "$BROWSER_USER"
17
+ }
18
+
19
+ as_user() {
20
+ runuser -u "$BROWSER_USER" -- env HOME="$BROWSER_HOME" DISPLAY="$DISPLAY" LANG="$LANG" \
21
+ XDG_RUNTIME_DIR="$(runtime_dir)" "$@"
22
+ }
23
+
24
+ create_runtime_dir() {
25
+ install -d -o "$BROWSER_USER" -g "$BROWSER_USER" -m 700 "$(runtime_dir)"
26
+ }
27
+
28
+ main() {
29
+ remove_stale_locks
30
+ apply_host_ids
31
+ create_runtime_dir
32
+ write_vnc_password
33
+ start_vnc
34
+ as_user openbox &
35
+ as_user mkdir -p "$PROFILE_DIR"
36
+ start_warsaw
37
+ start_novnc
38
+ run_browser
39
+ }
40
+
41
+ remove_stale_locks() {
42
+ rm -f "/tmp/.X${DISPLAY#:}-lock" "/tmp/.X11-unix/X${DISPLAY#:}" "$PROFILE_DIR/lock" \
43
+ "$PROFILE_DIR/.parentlock"
44
+ }
45
+
46
+ run_browser() {
47
+ as_user firefox-esr --profile "$PROFILE_DIR" "$START_URL"
48
+ }
49
+
50
+ runtime_dir() {
51
+ echo "/run/user/$(id -u "$BROWSER_USER")"
52
+ }
53
+
54
+ start_novnc() {
55
+ websockify --web /usr/share/novnc "$NOVNC_PORT" "localhost:$VNC_PORT" > /dev/null 2>&1 &
56
+ }
57
+
58
+ start_vnc() {
59
+ as_user Xvnc "$DISPLAY" -geometry "$RESOLUTION" -depth 24 -rfbport "$VNC_PORT" -localhost \
60
+ -SecurityTypes VncAuth -PasswordFile "$VNC_PASSWORD_FILE" -AlwaysShared &
61
+ wait_for_display
62
+ }
63
+
64
+ start_warsaw() {
65
+ "$WARSAW_CORE"
66
+ as_user "$WARSAW_CORE"
67
+ }
68
+
69
+ wait_for_display() {
70
+ local attempt
71
+ for attempt in $(seq 50); do
72
+ [ -S "/tmp/.X11-unix/X${DISPLAY#:}" ] && return 0
73
+ sleep 0.2
74
+ done
75
+ echo 'X server did not start' >&2
76
+ return 1
77
+ }
78
+
79
+ write_vnc_password() {
80
+ : "${VNC_PASSWORD:?VNC_PASSWORD must be set}"
81
+ install -d -o "$BROWSER_USER" -g "$BROWSER_USER" -m 700 "$(dirname "$VNC_PASSWORD_FILE")"
82
+ printf '%s\n' "$VNC_PASSWORD" | vncpasswd -f > "$VNC_PASSWORD_FILE"
83
+ chown "$BROWSER_USER:$BROWSER_USER" "$VNC_PASSWORD_FILE"
84
+ chmod 600 "$VNC_PASSWORD_FILE"
85
+ }
86
+
87
+ main
@@ -0,0 +1,18 @@
1
+ {
2
+ "policies": {
3
+ "DisableAppUpdate": true,
4
+ "DisableFirefoxStudies": true,
5
+ "DisableTelemetry": true,
6
+ "DontCheckDefaultBrowser": true,
7
+ "DownloadDirectory": "/downloads",
8
+ "OverrideFirstRunPage": "",
9
+ "OverridePostUpdatePage": "",
10
+ "Preferences": {
11
+ "browser.translations.enable": {
12
+ "Value": false,
13
+ "Status": "locked"
14
+ }
15
+ },
16
+ "RequestedLocales": ["pt-BR"]
17
+ }
18
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ehbrs_ruby_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.50.2
4
+ version: 0.51.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo H. Bogoni
@@ -49,14 +49,14 @@ dependencies:
49
49
  requirements:
50
50
  - - "~>"
51
51
  - !ruby/object:Gem::Version
52
- version: '0.15'
52
+ version: '0.17'
53
53
  type: :runtime
54
54
  prerelease: false
55
55
  version_requirements: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '0.15'
59
+ version: '0.17'
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: avm
62
62
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +80,7 @@ dependencies:
80
80
  version: '0.11'
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: 0.11.2
83
+ version: 0.11.3
84
84
  type: :runtime
85
85
  prerelease: false
86
86
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ dependencies:
90
90
  version: '0.11'
91
91
  - - ">="
92
92
  - !ruby/object:Gem::Version
93
- version: 0.11.2
93
+ version: 0.11.3
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: dentaku
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -154,7 +154,7 @@ dependencies:
154
154
  version: '0.1'
155
155
  - - ">="
156
156
  - !ruby/object:Gem::Version
157
- version: 0.1.1
157
+ version: 0.1.2
158
158
  type: :runtime
159
159
  prerelease: false
160
160
  version_requirements: !ruby/object:Gem::Requirement
@@ -164,7 +164,7 @@ dependencies:
164
164
  version: '0.1'
165
165
  - - ">="
166
166
  - !ruby/object:Gem::Version
167
- version: 0.1.1
167
+ version: 0.1.2
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: eac_templates
170
170
  requirement: !ruby/object:Gem::Requirement
@@ -253,14 +253,14 @@ dependencies:
253
253
  requirements:
254
254
  - - "~>"
255
255
  - !ruby/object:Gem::Version
256
- version: '0.15'
256
+ version: '0.16'
257
257
  type: :development
258
258
  prerelease: false
259
259
  version_requirements: !ruby/object:Gem::Requirement
260
260
  requirements:
261
261
  - - "~>"
262
262
  - !ruby/object:Gem::Version
263
- version: '0.15'
263
+ version: '0.16'
264
264
  executables: []
265
265
  extensions: []
266
266
  extra_rdoc_files: []
@@ -429,12 +429,9 @@ files:
429
429
  - lib/ehbrs_ruby_utils/web_utils/videos/file.rb
430
430
  - lib/ehbrs_ruby_utils/web_utils/videos/file/rename.rb
431
431
  - lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb
432
- - template/ehbrs_ruby_utils/finances/bb_browser/docker_image/.gitrepo
433
432
  - template/ehbrs_ruby_utils/finances/bb_browser/docker_image/Dockerfile
434
- - template/ehbrs_ruby_utils/finances/bb_browser/docker_image/Makefile
435
- - template/ehbrs_ruby_utils/finances/bb_browser/docker_image/README.md
436
- - template/ehbrs_ruby_utils/finances/bb_browser/docker_image/context/firefox.service
437
- - template/ehbrs_ruby_utils/finances/bb_browser/docker_image/context/startbrowser.sh
433
+ - template/ehbrs_ruby_utils/finances/bb_browser/docker_image/entrypoint.sh
434
+ - template/ehbrs_ruby_utils/finances/bb_browser/docker_image/policies.json
438
435
  - template/ehbrs_ruby_utils/music/lyrics_book/album/inner.html.erb
439
436
  - template/ehbrs_ruby_utils/music/lyrics_book/custom_style.css
440
437
  - template/ehbrs_ruby_utils/music/lyrics_book/index.html.erb
@@ -1,12 +0,0 @@
1
- ; DO NOT EDIT (unless you know what you are doing)
2
- ;
3
- ; This subdirectory is a git "subrepo", and this file is maintained by the
4
- ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
5
- ;
6
- [subrepo]
7
- remote = https://github.com/jsalatiel/wsbb-podman.git
8
- branch = master
9
- commit = 17e9e19bd755c3312b4cb7dd427acdf110b8a5f0
10
- parent = f94d3b2833c4f75b55dd64d21d3440a3ab96a106
11
- method = merge
12
- cmdver = 0.4.1
@@ -1,35 +0,0 @@
1
- IMG=jsalatiel/wsbb-podman:latest
2
- CONTAINER_NAME=wsbb
3
- DOCKERCMD=sudo podman
4
-
5
-
6
- USER_UID = $(shell id -u $(USER))
7
- USER_GID = $(shell id -g $(USER))
8
- ifeq ($(shell uname),Darwin)
9
- USER_GID = $(shell id -u $(USER))
10
- endif
11
-
12
- build:
13
- $(DOCKERCMD) build -t ${IMG} .
14
-
15
- start:
16
- $(DOCKERCMD) run -d --rm -it --name ${CONTAINER_NAME} \
17
- --cap-add CAP_AUDIT_WRITE --cap-add CAP_SYS_PTRACE \
18
- -e USER_UID=$(USER_UID) \
19
- -e USER_GID=$(USER_GID) \
20
- -v "$(HOME)/.Xauthority:/home/user/.Xauthority:ro" \
21
- -v "/tmp/.X11-unix:/tmp/.X11-unix:ro" \
22
- -v "/etc/machine-id:/etc/machine-id:ro" \
23
- $(IMG) seg.bb.com.br
24
- logs:
25
- $(DOCKERCMD) logs -f ${CONTAINER_NAME}
26
-
27
- shell:
28
- $(DOCKERCMD) exec -it ${CONTAINER_NAME} bash
29
-
30
- stop:
31
- -$(DOCKERCMD) kill ${CONTAINER_NAME}
32
-
33
- remove:
34
- -$(DOCKERCMD) image rm ${CONTAINER_NAME}
35
-
@@ -1,16 +0,0 @@
1
- # wsbb-podman
2
- Credits go to farribeiro/wscef-docker and juliohm1978/dockerbb
3
-
4
-
5
- **make build** to build the container
6
-
7
- **make start** to run the container ( It may take a while to start firefox - Just wait)
8
-
9
- When you close firefox the container will be deleted.
10
-
11
-
12
-
13
-
14
-
15
-
16
-
@@ -1,8 +0,0 @@
1
- [Unit]
2
-
3
- [Service]
4
- ExecStart=/usr/local/bin/startbrowser.sh
5
- Restart=no
6
-
7
- [Install]
8
- WantedBy=multi-user.target
@@ -1,9 +0,0 @@
1
- #!/bin/bash -xe
2
-
3
- /usr/bin/dpkg -D10 -i /src/warsaw.deb
4
- systemctl enable --now warsaw
5
-
6
- runuser -l user -c "XAUTHORITY=/home/user/.Xauthority DISPLAY=:0 firefox --no-remote --new-instance https://seg.bb.com.br"
7
-
8
- kill -SIGRTMIN+3 1
9
-