ehbrs_ruby_utils 0.50.1 → 0.51.0

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: e27fa8e7b9de67f4c480a9d60988c49fdcd84240e1932c41f73eb46802e974d4
4
- data.tar.gz: cafca570ed8faae4d48ea9be69bced3aa0dadf987a6b0ee7d767b5c544133c4e
3
+ metadata.gz: 59fd088c78768f47d8c0d60dd1a323ee1aff664fddc42da69ae116c0987a5bef
4
+ data.tar.gz: 21b1c837106b2db71f5840adad05dbd4f37ed262cb5b6b98b1ad4569c04d5474
5
5
  SHA512:
6
- metadata.gz: 19b9c40f54a1f47eed3cdd57c6fced7378b3e67442e65d775a15b2c8ecd8c4460f8aace63bf5b470d243e245561a841a452b78f196638ed8ffab7d8b0a227ef2
7
- data.tar.gz: edb00210dad61f083e695f1f0258b9f03a973e9d42b7b4a2239c58a290bb3e273e0bc11c8c9e5f9507b6817526e3aa8bcb44c14c7b13b544f23aab3a10ce593c
6
+ metadata.gz: c65b15d5e7a402059e623fb7a66e02bd03a35baaed05253adfac8878bcea3bc5bd89e3503058385682e9966195c0218231f4ef3018f5254fb28740023de43ba6
7
+ data.tar.gz: 28138be728e5eb054bb3105088432e94161a2425a014ff8427234a5415ef2ab8b9792ec92285835538534d0f229fe46b55ab1dd0884656735e08907d519d6430
@@ -69,7 +69,7 @@ module EhbrsRubyUtils
69
69
  # @param prices [Enumerable<Float, nil>]
70
70
  # @return [Float]
71
71
  def build_price(*prices)
72
- prices.reject(&:blank?).min
72
+ prices.reject(&:blank?).min # rubocop:disable Rails/CompactBlank
73
73
  end
74
74
 
75
75
  # @param text [String]
@@ -15,7 +15,8 @@ module EhbrsRubyUtils
15
15
  field :name, :string, './div[@class = "name"]/a/text()'
16
16
  field :score, :integer_optional, './div[@class = "score"]'
17
17
  field :elo_increment, :string, './/*[starts-with(@id, "winpoints_value_")]/text()'
18
- field :elo_reached, :integer_optional, './/*[@class = "gamerank_value"]/text()'
18
+ field :elo_reached, :integer_optional,
19
+ './/*[normalize-space(@class) = "gamerank_value"]/text()'
19
20
  field :penalty_clock, :boolean,
20
21
  './/*[@class = "clockpenalty" and @style = "display: inline;"]'
21
22
  field :penalty_leave, :boolean,
@@ -4,7 +4,7 @@ module EhbrsRubyUtils
4
4
  module Bga
5
5
  module Parsers
6
6
  class Table < ::Aranha::Parsers::Html::Item
7
- GAME_IMAGE_URL_PARSER = %r{/gamemedia/([^/]+)/box/}.to_parser { |m| m[1] }
7
+ GAME_IMAGE_URL_PARSER = %r{/gamemedia/([^/]+)/}.to_parser { |m| m[1] }
8
8
  ITEM_XPATH = '/'
9
9
  PLAYERS_IDS = {
10
10
  'game_result' => ::EhbrsRubyUtils::Bga::Parsers::Table::EndedPlayers,
@@ -8,7 +8,7 @@ module EhbrsRubyUtils
8
8
  enable_simple_cache
9
9
  common_constructor :data
10
10
 
11
- GAME_MODE_KEY = 'Modo de Jogo'
11
+ GAME_MODE_KEYS = ['Modo do jogo', 'Modo de Jogo'].freeze
12
12
  GAME_MODE_FRIENDLY_VALUE = 'Modo Amigável'
13
13
  GAME_MODE_NORMAL_VALUE = 'Modo Normal'
14
14
  SET_ITEMS = %i[options players].freeze
@@ -22,11 +22,11 @@ module EhbrsRubyUtils
22
22
 
23
23
  # @return [Boolean]
24
24
  def friendly?
25
- value = option_value(GAME_MODE_KEY)
25
+ value = game_mode_value
26
26
  return true if value == GAME_MODE_FRIENDLY_VALUE
27
27
  return false if value == GAME_MODE_NORMAL_VALUE
28
28
 
29
- raise "Unknown \"#{GAME_MODE_KEY}\" value: \"#{value}\""
29
+ raise "Unknown value for game mode: \"#{value}\" (Options: #{options_to_s})"
30
30
  end
31
31
 
32
32
  # @return [Boolean]
@@ -34,6 +34,18 @@ module EhbrsRubyUtils
34
34
  game_conceded
35
35
  end
36
36
 
37
+ # @return [String]
38
+ def game_mode_value
39
+ GAME_MODE_KEYS.lazy.map { |k| option_value(k) }.find(&:present?) ||
40
+ raise("No option found with one of the labels #{GAME_MODE_KEYS} " \
41
+ "(Options: #{options_to_s})")
42
+ end
43
+
44
+ # @return [String]
45
+ def options_to_s
46
+ options.map { |o| "#{o.label}=\"#{o.value}\"" }.join(', ')
47
+ end
48
+
37
49
  # @param key [String]
38
50
  # @return [String, nil]
39
51
  def option_value(label)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EhbrsRubyUtils
4
- VERSION = '0.50.1'
4
+ VERSION = '0.51.0'
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.1
4
+ version: 0.51.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo H. Bogoni
@@ -49,20 +49,14 @@ dependencies:
49
49
  requirements:
50
50
  - - "~>"
51
51
  - !ruby/object:Gem::Version
52
- version: '0.14'
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: 0.14.1
52
+ version: '0.15'
56
53
  type: :runtime
57
54
  prerelease: false
58
55
  version_requirements: !ruby/object:Gem::Requirement
59
56
  requirements:
60
57
  - - "~>"
61
58
  - !ruby/object:Gem::Version
62
- version: '0.14'
63
- - - ">="
64
- - !ruby/object:Gem::Version
65
- version: 0.14.1
59
+ version: '0.15'
66
60
  - !ruby/object:Gem::Dependency
67
61
  name: avm
68
62
  requirement: !ruby/object:Gem::Requirement
@@ -160,7 +154,7 @@ dependencies:
160
154
  version: '0.1'
161
155
  - - ">="
162
156
  - !ruby/object:Gem::Version
163
- version: 0.1.1
157
+ version: 0.1.2
164
158
  type: :runtime
165
159
  prerelease: false
166
160
  version_requirements: !ruby/object:Gem::Requirement
@@ -170,7 +164,7 @@ dependencies:
170
164
  version: '0.1'
171
165
  - - ">="
172
166
  - !ruby/object:Gem::Version
173
- version: 0.1.1
167
+ version: 0.1.2
174
168
  - !ruby/object:Gem::Dependency
175
169
  name: eac_templates
176
170
  requirement: !ruby/object:Gem::Requirement
@@ -435,12 +429,9 @@ files:
435
429
  - lib/ehbrs_ruby_utils/web_utils/videos/file.rb
436
430
  - lib/ehbrs_ruby_utils/web_utils/videos/file/rename.rb
437
431
  - lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb
438
- - template/ehbrs_ruby_utils/finances/bb_browser/docker_image/.gitrepo
439
432
  - template/ehbrs_ruby_utils/finances/bb_browser/docker_image/Dockerfile
440
- - template/ehbrs_ruby_utils/finances/bb_browser/docker_image/Makefile
441
- - template/ehbrs_ruby_utils/finances/bb_browser/docker_image/README.md
442
- - template/ehbrs_ruby_utils/finances/bb_browser/docker_image/context/firefox.service
443
- - 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
444
435
  - template/ehbrs_ruby_utils/music/lyrics_book/album/inner.html.erb
445
436
  - template/ehbrs_ruby_utils/music/lyrics_book/custom_style.css
446
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
-