ehbrs-tools 0.44.0 → 0.44.2

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: 984176f11d6307cee18e25fa57a75357c6702d7f568951db597f1383de3f5820
4
- data.tar.gz: 72faf57da473c84453d474ad060c79a8ee335462beaf2fc7e46e3e952911fc68
3
+ metadata.gz: b3079c88bc47bb89ec0fbb7b27a4d08d027f222a833a38b28c2df79bd17f699e
4
+ data.tar.gz: 96d7772718c5576d35b119770475a4c205177f30876eae208accf02788c3d114
5
5
  SHA512:
6
- metadata.gz: b629b48bc55a376b8ff8f0b2f2a8d5b65fa1d89d358a1b0188c88b29f0879482b1d703784d242cd4eb001bf97528fd30b9a9f1c7b929292499242cfc1d2b2060
7
- data.tar.gz: fcebfa71dcaaa5dab4725b7cbe73300cc0801c26ce7aa93a0e96ea48066c9a75fbb63901bf85c65407aa5bc10fb437ffcbbf0df7ba0e2fabfa28e8a61e6a8d7f
6
+ metadata.gz: '08bcd038a840b0e5d5f52bd2e6a05f2a4746bbe39faac18dfe8bceaddc1cea51a646dcb867661905b2d734f12be7cd53dbfc3f62ca548d262e54f87f51c858fd'
7
+ data.tar.gz: ede8e11a5c522e58a7a373d92a755be3c63adfdfe4d3048c4ac261e5f98d1d01202f800ea03fac679d654ad9ae46b4793ed8c3e313e5d0cf4c3ff8f96cf59253
data/Gemfile.lock CHANGED
@@ -1,64 +1,30 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ehbrs-tools (0.44.0)
4
+ ehbrs-tools (0.44.2)
5
5
  avm-files (~> 0.9)
6
- avm-tools (~> 0.163, >= 0.163.3)
7
- eac_cli (~> 0.43)
8
- eac_fs (~> 0.19)
6
+ avm-tools (~> 0.163, >= 0.163.4)
7
+ eac_cli (~> 0.44, >= 0.44.3)
8
+ eac_fs (~> 0.19, >= 0.19.1)
9
9
  eac_ruby_base0 (~> 0.19, >= 0.19.2)
10
- eac_ruby_utils (~> 0.128, >= 0.128.2)
10
+ eac_ruby_utils (~> 0.128, >= 0.128.5)
11
11
  ehbrs_ruby_utils (~> 0.45)
12
12
  filesize (~> 0.2)
13
13
  os (~> 1.1, >= 1.1.4)
14
14
  telegram-bot-ruby (~> 0.23)
15
15
 
16
16
  PATH
17
- remote: sub/eac_fs
18
- specs:
19
- eac_fs (0.19.0)
20
- content-type (~> 0.0, >= 0.0.2)
21
- eac_ruby_utils (~> 0.128, >= 0.128.2)
22
- ruby-filemagic (~> 0.7, >= 0.7.3)
23
-
24
- PATH
25
- remote: sub/eac_ruby_base0
26
- specs:
27
- eac_ruby_base0 (0.19.2)
28
- avm-eac_ruby_base1 (~> 0.37)
29
- eac_cli (~> 0.43)
30
- eac_fs (~> 0.19)
31
- eac_ruby_utils (~> 0.128, >= 0.128.2)
32
-
33
- PATH
34
- remote: sub/eac_ruby_utils
35
- specs:
36
- eac_ruby_utils (0.128.2)
37
- activesupport (>= 4, < 7)
38
- addressable (~> 2.8, >= 2.8.7)
39
- bundler
40
- filesize (~> 0.2)
41
- net-ssh (~> 4.2)
42
- zeitwerk (~> 2.6, >= 2.6.18)
43
-
44
- PATH
45
- remote: sub/ehbrs_ruby_utils
17
+ remote: sub/avm
46
18
  specs:
47
- ehbrs_ruby_utils (0.45.0)
48
- aranha (~> 0.20)
49
- aranha-parsers (~> 0.26, >= 0.26.1)
50
- aranha-selenium (~> 0.12)
51
- avm (~> 0.96, >= 0.96.1)
52
- avm-eac_rails_base0 (~> 0.11, >= 0.11.1)
53
- dentaku (~> 3.5, >= 3.5.4)
54
- eac_fs (~> 0.19)
55
- eac_rest (~> 0.12)
56
- eac_ruby_utils (~> 0.128, >= 0.128.2)
57
- eac_templates (~> 0.8, >= 0.8.1)
58
- inifile (~> 3.0)
59
- srt (~> 0.1, >= 0.1.5)
60
- taglib-ruby (~> 1.1, >= 1.1.3)
61
- ultimate_lyrics (~> 0.1, >= 0.1.3)
19
+ avm (0.98.2)
20
+ clipboard (~> 1.4, >= 1.4.1)
21
+ eac_cli (~> 0.44, >= 0.44.3)
22
+ eac_config (~> 0.15)
23
+ eac_docker (~> 0.8)
24
+ eac_fs (~> 0.19, >= 0.19.1)
25
+ eac_ruby_utils (~> 0.128, >= 0.128.5)
26
+ eac_templates (~> 0.8, >= 0.8.3)
27
+ minitar (~> 0.12, >= 0.12.1)
62
28
 
63
29
  GEM
64
30
  remote: https://rubygems.org/
@@ -69,8 +35,8 @@ GEM
69
35
  minitest (>= 5.1)
70
36
  tzinfo (~> 2.0)
71
37
  zeitwerk (~> 2.3)
72
- addressable (2.8.7)
73
- public_suffix (>= 2.0.2, < 7.0)
38
+ addressable (2.8.8)
39
+ public_suffix (>= 2.0.2, < 8.0)
74
40
  aranha (0.20.0)
75
41
  eac_ruby_utils (~> 0.128)
76
42
  aranha-parsers (0.26.1)
@@ -89,16 +55,6 @@ GEM
89
55
  selenium-webdriver (~> 3.142, >= 3.142.7)
90
56
  ast (2.4.3)
91
57
  attr_extras (7.1.0)
92
- avm (0.96.1)
93
- clipboard (~> 1.4, >= 1.4.1)
94
- eac_cli (~> 0.43)
95
- eac_config (~> 0.15)
96
- eac_docker (~> 0.7)
97
- eac_fs (~> 0.18, >= 0.18.1)
98
- eac_ruby_utils (~> 0.128)
99
- eac_templates (~> 0.8, >= 0.8.1)
100
- minitar (~> 0.12, >= 0.12.1)
101
- ruby-progressbar (~> 1.13)
102
58
  avm-eac_generic_base0 (0.15.1)
103
59
  avm (~> 0.96, >= 0.96.1)
104
60
  eac_ruby_utils (~> 0.128)
@@ -108,79 +64,88 @@ GEM
108
64
  avm-eac_rails_base0 (0.11.1)
109
65
  avm-eac_rails_base1 (~> 0.10)
110
66
  eac_ruby_utils (~> 0.121)
111
- avm-eac_rails_base1 (0.10.2)
112
- avm (~> 0.94)
113
- avm-eac_ruby_base1 (~> 0.35, >= 0.35.1)
114
- avm-eac_webapp_base0 (~> 0.20, >= 0.20.1)
115
- eac_ruby_utils (~> 0.123)
116
- avm-eac_ruby_base1 (0.37.0)
117
- avm (~> 0.96, >= 0.96.1)
67
+ avm-eac_rails_base1 (0.11.0)
68
+ avm (~> 0.98, >= 0.98.1)
69
+ avm-eac_ruby_base1 (~> 0.38, >= 0.38.1)
70
+ avm-eac_webapp_base0 (~> 0.21, >= 0.21.2)
71
+ eac_ruby_utils (~> 0.128, >= 0.128.5)
72
+ avm-eac_ruby_base1 (0.38.1)
73
+ aranha-parsers (~> 0.26, >= 0.26.1)
74
+ avm (~> 0.98, >= 0.98.1)
118
75
  avm-eac_generic_base0 (~> 0.15, >= 0.15.1)
119
- eac_envs-http (~> 0.6, >= 0.6.1)
120
- eac_ruby_utils (~> 0.128, >= 0.128.1)
121
- avm-eac_ubuntu_base0 (0.5.1)
122
- avm (~> 0.86, >= 0.86.2)
123
- eac_ruby_utils (~> 0.121)
124
- eac_templates (~> 0.5, >= 0.5.1)
125
- avm-eac_webapp_base0 (0.21.1)
126
- avm (~> 0.96, >= 0.96.1)
76
+ eac_envs-http (~> 0.7)
77
+ eac_ruby_utils (~> 0.128, >= 0.128.4)
78
+ avm-eac_ubuntu_base0 (0.6.0)
79
+ avm (~> 0.97)
80
+ eac_ruby_utils (~> 0.128, >= 0.128.3)
81
+ eac_templates (~> 0.8, >= 0.8.1)
82
+ avm-eac_webapp_base0 (0.21.2)
83
+ avm (~> 0.98, >= 0.98.1)
127
84
  avm-eac_generic_base0 (~> 0.15, >= 0.15.1)
128
85
  avm-eac_postgresql_base0 (~> 0.5, >= 0.5.3)
129
- avm-eac_ubuntu_base0 (~> 0.5, >= 0.5.1)
130
- avm-files (~> 0.9)
131
- eac_ruby_utils (~> 0.128)
86
+ avm-eac_ubuntu_base0 (~> 0.6)
87
+ eac_ruby_utils (~> 0.128, >= 0.128.4)
132
88
  htmlbeautifier (~> 1.4, >= 1.4.3)
133
89
  avm-files (0.9.0)
134
90
  avm (~> 0.95)
135
- avm-tools (0.163.3)
136
- avm (~> 0.96, >= 0.96.1)
91
+ avm-tools (0.163.4)
92
+ avm (~> 0.98, >= 0.98.1)
137
93
  clipboard (~> 1.4, >= 1.4.1)
138
- eac_ruby_base0 (~> 0.19, >= 0.19.1)
94
+ eac_ruby_base0 (~> 0.19, >= 0.19.2)
139
95
  axiom-types (0.1.1)
140
96
  descendants_tracker (~> 0.0.4)
141
97
  ice_nine (~> 0.11.0)
142
98
  thread_safe (~> 0.3, >= 0.3.1)
143
99
  base64 (0.3.0)
144
- bigdecimal (3.2.2)
100
+ bigdecimal (4.0.1)
145
101
  childprocess (3.0.0)
146
102
  clipboard (1.4.1)
147
103
  coercible (1.0.0)
148
104
  descendants_tracker (~> 0.0.1)
149
105
  colorize (0.8.1)
150
- concurrent-ruby (1.3.5)
106
+ concurrent-ruby (1.3.6)
151
107
  content-type (0.0.2)
152
108
  parslet (~> 2.0)
153
- dentaku (3.5.4)
109
+ dentaku (3.5.7)
154
110
  bigdecimal
155
111
  concurrent-ruby
156
112
  descendants_tracker (0.0.4)
157
113
  thread_safe (~> 0.3, >= 0.3.1)
158
114
  diff-lcs (1.6.2)
159
115
  dry-inflector (1.1.0)
160
- eac_cli (0.43.0)
116
+ eac_cli (0.44.3)
161
117
  colorize (~> 0.8, >= 0.8.1)
162
- eac_config (~> 0.14, >= 0.14.3)
163
- eac_ruby_utils (~> 0.127)
118
+ eac_config (~> 0.15)
119
+ eac_ruby_utils (~> 0.128, >= 0.128.5)
164
120
  tty-table (~> 0.12)
165
121
  eac_config (0.15.0)
166
122
  addressable (~> 2.8, >= 2.8.7)
167
123
  eac_ruby_utils (~> 0.127)
168
- eac_docker (0.7.0)
169
- eac_ruby_utils (~> 0.112)
170
- eac_templates (~> 0.3, >= 0.3.2)
171
- eac_envs-http (0.6.1)
172
- eac_fs (~> 0.18, >= 0.18.1)
173
- eac_ruby_utils (~> 0.123)
124
+ eac_docker (0.8.0)
125
+ eac_ruby_utils (~> 0.128, >= 0.128.2)
126
+ eac_templates (~> 0.8, >= 0.8.1)
127
+ eac_envs-http (0.7.0)
128
+ eac_fs (~> 0.19)
129
+ eac_ruby_utils (~> 0.128, >= 0.128.3)
174
130
  faraday (~> 2.8, >= 2.8.1)
175
131
  faraday-follow_redirects (~> 0.3)
176
132
  faraday-gzip (~> 0.1)
177
- faraday-multipart (~> 1.0, >= 1.0.4)
178
- faraday-retry (~> 2.2, >= 2.2.1)
133
+ faraday-multipart (~> 1.1, >= 1.1.1)
134
+ faraday-retry (~> 2.3, >= 2.3.2)
179
135
  random-port (~> 0.7, >= 0.7.1)
136
+ eac_fs (0.19.1)
137
+ content-type (~> 0.0, >= 0.0.2)
138
+ eac_ruby_utils (~> 0.128, >= 0.128.3)
139
+ ruby-filemagic (~> 0.7, >= 0.7.3)
180
140
  eac_rest (0.12.0)
181
141
  eac_envs-http (~> 0.5)
182
142
  eac_fs (~> 0.16)
183
143
  eac_ruby_utils (~> 0.120)
144
+ eac_ruby_base0 (0.19.2)
145
+ avm-eac_ruby_base1 (~> 0.37)
146
+ eac_cli (~> 0.43)
147
+ eac_fs (~> 0.19)
148
+ eac_ruby_utils (~> 0.128, >= 0.128.2)
184
149
  eac_ruby_gem_support (0.12.0)
185
150
  eac_ruby_utils (~> 0.127)
186
151
  rspec (~> 3.13, >= 3.13.1)
@@ -188,35 +153,57 @@ GEM
188
153
  rubocop-rails (~> 2.32)
189
154
  rubocop-rspec (~> 3.6)
190
155
  super_diff (~> 0.9)
191
- eac_templates (0.8.1)
156
+ eac_ruby_utils (0.128.5)
157
+ activesupport (>= 4, < 7)
158
+ addressable (~> 2.8, >= 2.8.8)
159
+ bundler
160
+ filesize (~> 0.2)
161
+ net-ssh (~> 4.2)
162
+ zeitwerk (~> 2.6, >= 2.6.18)
163
+ eac_templates (0.8.3)
192
164
  eac_config (~> 0.15)
193
- eac_ruby_utils (~> 0.127)
165
+ eac_ruby_utils (~> 0.128, >= 0.128.5)
166
+ ehbrs_ruby_utils (0.45.0)
167
+ aranha (~> 0.20)
168
+ aranha-parsers (~> 0.26, >= 0.26.1)
169
+ aranha-selenium (~> 0.12)
170
+ avm (~> 0.96, >= 0.96.1)
171
+ avm-eac_rails_base0 (~> 0.11, >= 0.11.1)
172
+ dentaku (~> 3.5, >= 3.5.4)
173
+ eac_fs (~> 0.19)
174
+ eac_rest (~> 0.12)
175
+ eac_ruby_utils (~> 0.128, >= 0.128.2)
176
+ eac_templates (~> 0.8, >= 0.8.1)
177
+ inifile (~> 3.0)
178
+ srt (~> 0.1, >= 0.1.5)
179
+ taglib-ruby (~> 1.1, >= 1.1.3)
180
+ ultimate_lyrics (~> 0.1, >= 0.1.3)
194
181
  faraday (2.8.1)
195
182
  base64
196
183
  faraday-net_http (>= 2.0, < 3.1)
197
184
  ruby2_keywords (>= 0.0.4)
198
- faraday-follow_redirects (0.3.0)
185
+ faraday-follow_redirects (0.5.0)
199
186
  faraday (>= 1, < 3)
200
187
  faraday-gzip (0.1.0)
201
188
  faraday (>= 1.0)
202
189
  zlib (~> 2.1)
203
- faraday-multipart (1.1.1)
190
+ faraday-multipart (1.2.0)
204
191
  multipart-post (~> 2.0)
205
192
  faraday-net_http (3.0.2)
206
- faraday-retry (2.3.2)
193
+ faraday-retry (2.4.0)
207
194
  faraday (~> 2.0)
208
195
  filesize (0.2.0)
209
196
  hpricot (0.8.6)
210
197
  htmlbeautifier (1.4.3)
211
- i18n (1.14.7)
198
+ i18n (1.14.8)
212
199
  concurrent-ruby (~> 1.0)
213
200
  ice_nine (0.11.2)
214
201
  inifile (3.0.0)
215
- json (2.12.2)
202
+ json (2.18.0)
216
203
  language_server-protocol (3.17.0.5)
217
204
  lint_roller (1.1.0)
218
205
  minitar (0.12.1)
219
- minitest (5.25.5)
206
+ minitest (5.26.1)
220
207
  multipart-post (2.4.1)
221
208
  net-ssh (4.2.0)
222
209
  nokogiri (1.15.7-x86_64-linux)
@@ -226,7 +213,7 @@ GEM
226
213
  optimist (3.2.1)
227
214
  os (1.1.4)
228
215
  parallel (1.27.0)
229
- parser (3.3.8.0)
216
+ parser (3.3.10.0)
230
217
  ast (~> 2.4.1)
231
218
  racc
232
219
  parslet (2.0.0)
@@ -234,27 +221,27 @@ GEM
234
221
  tty-color (~> 0.5)
235
222
  patience_diff (1.2.0)
236
223
  optimist (~> 3.0)
237
- prism (1.4.0)
224
+ prism (1.7.0)
238
225
  public_suffix (5.1.1)
239
226
  racc (1.8.1)
240
- rack (3.1.16)
227
+ rack (3.2.4)
241
228
  rainbow (3.1.1)
242
229
  random-port (0.7.1)
243
- regexp_parser (2.10.0)
244
- rspec (3.13.1)
230
+ regexp_parser (2.11.3)
231
+ rspec (3.13.2)
245
232
  rspec-core (~> 3.13.0)
246
233
  rspec-expectations (~> 3.13.0)
247
234
  rspec-mocks (~> 3.13.0)
248
- rspec-core (3.13.5)
235
+ rspec-core (3.13.6)
249
236
  rspec-support (~> 3.13.0)
250
237
  rspec-expectations (3.13.5)
251
238
  diff-lcs (>= 1.2.0, < 2.0)
252
239
  rspec-support (~> 3.13.0)
253
- rspec-mocks (3.13.5)
240
+ rspec-mocks (3.13.7)
254
241
  diff-lcs (>= 1.2.0, < 2.0)
255
242
  rspec-support (~> 3.13.0)
256
- rspec-support (3.13.4)
257
- rubocop (1.77.0)
243
+ rspec-support (3.13.6)
244
+ rubocop (1.82.1)
258
245
  json (~> 2.3)
259
246
  language_server-protocol (~> 3.17.0.2)
260
247
  lint_roller (~> 1.1.0)
@@ -262,21 +249,21 @@ GEM
262
249
  parser (>= 3.3.0.2)
263
250
  rainbow (>= 2.2.2, < 4.0)
264
251
  regexp_parser (>= 2.9.3, < 3.0)
265
- rubocop-ast (>= 1.45.1, < 2.0)
252
+ rubocop-ast (>= 1.48.0, < 2.0)
266
253
  ruby-progressbar (~> 1.7)
267
254
  unicode-display_width (>= 2.4.0, < 4.0)
268
- rubocop-ast (1.45.1)
255
+ rubocop-ast (1.49.0)
269
256
  parser (>= 3.3.7.2)
270
- prism (~> 1.4)
271
- rubocop-rails (2.32.0)
257
+ prism (~> 1.7)
258
+ rubocop-rails (2.34.3)
272
259
  activesupport (>= 4.2.0)
273
260
  lint_roller (~> 1.1)
274
261
  rack (>= 1.1)
275
262
  rubocop (>= 1.75.0, < 2.0)
276
263
  rubocop-ast (>= 1.44.0, < 2.0)
277
- rubocop-rspec (3.6.0)
264
+ rubocop-rspec (3.8.0)
278
265
  lint_roller (~> 1.1)
279
- rubocop (~> 1.72, >= 1.72.1)
266
+ rubocop (~> 1.81)
280
267
  ruby-filemagic (0.7.3)
281
268
  ruby-progressbar (1.13.0)
282
269
  ruby2_keywords (0.0.5)
@@ -325,12 +312,9 @@ PLATFORMS
325
312
  x86_64-linux
326
313
 
327
314
  DEPENDENCIES
328
- eac_fs!
329
- eac_ruby_base0!
315
+ avm!
330
316
  eac_ruby_gem_support (~> 0.12)
331
- eac_ruby_utils!
332
317
  ehbrs-tools!
333
- ehbrs_ruby_utils!
334
318
 
335
319
  BUNDLED WITH
336
320
  2.4.22
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ehbrs
4
+ module Tools
5
+ module Google
6
+ module Translate
7
+ class Session
8
+ START_URL = 'https://translate.google.com.br/#view=home&op=docs&sl=en&tl=pt'
9
+ CLOSE_POPUP_CSS = '.dismiss-button'
10
+ FILE_INPUT_XPATH = '//*[@id = "tlid-file-input"]'
11
+ SUBMIT_XPATH = '//form[@action="//translate.googleusercontent.com/translate_f"]' \
12
+ '//input[@type="submit"]'
13
+ RESULT_XPATHS = [
14
+ '//script[contains(@src, "https://translate.google.com/translate_a")]',
15
+ '/html/body/pre'
16
+ ].freeze
17
+
18
+ attr_reader :sub
19
+
20
+ def initialize
21
+ @sub = ::Aranha::Selenium::Session.new
22
+ end
23
+
24
+ def translate(source_document_path)
25
+ go_to_upload_form
26
+ input_file(source_document_path)
27
+ close_changes_alert_popup
28
+ click_on_translate_button
29
+ wait_for_load_translation
30
+ sub.current_source
31
+ end
32
+
33
+ private
34
+
35
+ def go_to_upload_form
36
+ sub.navigate.to START_URL
37
+ sub.wait_for_element(xpath: FILE_INPUT_XPATH)
38
+ end
39
+
40
+ def input_file(source_document_path)
41
+ sub.find_element(xpath: FILE_INPUT_XPATH).send_keys(source_document_path)
42
+ end
43
+
44
+ def click_on_translate_button
45
+ sub.wait_for_click(xpath: SUBMIT_XPATH)
46
+ end
47
+
48
+ def close_changes_alert_popup
49
+ sub.wait_for_click(css: CLOSE_POPUP_CSS)
50
+ end
51
+
52
+ def wait_for_load_translation
53
+ sub.wait.until do
54
+ RESULT_XPATHS.any? { |xpath| sub.find_elements(xpath: xpath).size.positive? }
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ehbrs
4
+ module Tools
5
+ module Observers
6
+ class Base
7
+ include ::EacRubyUtils::Listable
8
+
9
+ lists.add_string :blank_value, :add, :ignore, :raise
10
+
11
+ attr_reader :records, :blank_value, :last_check_time
12
+
13
+ common_constructor :options, default: [{}] do
14
+ @records = options[:records] || []
15
+ @blank_value = options[:blank_value].if_present(BLANK_VALUE_ADD) do |v|
16
+ v = v.to_s
17
+ ::Ehbrs::Tools::Observers::Base.lists.blank_value.value_validate!(v)
18
+ v
19
+ end
20
+ end
21
+
22
+ def check(value, date = ::Time.required_zone.now)
23
+ @last_check_time = date
24
+ send("check_with_blank_value_#{blank_value}", value, date)
25
+ end
26
+
27
+ def changing_value?(value)
28
+ records.if_present(true) do
29
+ last_value.if_present(value.present?) { |v| v != value }
30
+ end
31
+ end
32
+
33
+ def last_change_time
34
+ records.last.if_present(&:time)
35
+ end
36
+
37
+ def last_value
38
+ records.last.if_present(&:value)
39
+ end
40
+
41
+ private
42
+
43
+ def check_with_blank_value_add(value, time) # rubocop:disable Naming/PredicateMethod
44
+ return false unless changing_value?(value)
45
+
46
+ records << { value: value, time: time }.to_struct
47
+ true
48
+ end
49
+
50
+ def check_with_blank_value_ignore(value, date)
51
+ false if value.blank? ? false : check_with_blank_value_add(value, date)
52
+ end
53
+
54
+ def check_with_blank_value_raise(value, date)
55
+ raise(::ArgumentError, "Blank value checked (Value: #{value}, Class: #{value.class})") if
56
+ value.blank?
57
+
58
+ check_with_blank_value_add(value, date)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ehbrs
4
+ module Tools
5
+ module Observers
6
+ class WithPersistence < ::Ehbrs::Tools::Observers::Base
7
+ attr_reader :path
8
+
9
+ def initialize(path, options = {})
10
+ super(options)
11
+ @path = path.to_pathname
12
+ load
13
+ end
14
+
15
+ def check(value, date = ::Time.required_zone.now)
16
+ save if super
17
+ end
18
+
19
+ def load
20
+ save unless path.exist?
21
+ data = ::YAML.load_file(path.to_path)
22
+ @records = data.fetch(:records).map(&:to_struct)
23
+ @last_check_time = data.fetch(:last_check_time)
24
+ end
25
+
26
+ def save
27
+ path.parent.mkpath
28
+ path.write({ records: records.map(&:to_h), last_check_time: last_check_time }.to_yaml)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -75,7 +75,7 @@ module Ehbrs
75
75
  end
76
76
 
77
77
  def observer_uncached
78
- ::Ehbrs::Self::Observers::UsedSpace.new(path)
78
+ ::Ehbrs::Tools::Self::Observers::UsedSpace.new(path)
79
79
  end
80
80
 
81
81
  def changing_label(bool)
@@ -46,7 +46,7 @@ module Ehbrs
46
46
  end
47
47
 
48
48
  def session_uncached
49
- ::Ehbrs::Google::Translate::Session.new
49
+ ::Ehbrs::Tools::Google::Translate::Session.new
50
50
  end
51
51
 
52
52
  def validate
@@ -17,7 +17,7 @@ module Ehbrs
17
17
 
18
18
  def message_sending_uncached
19
19
  parsed.recipients_ids
20
- .inject(::Ehbrs::Telegram::MessageSending.new) { |a, e| a.recipient_id(e) }
20
+ .inject(::Ehbrs::Tools::Telegram::MessageSending.new) { |a, e| a.recipient_id(e) }
21
21
  .bot_token(runner_context.call(:bot_token))
22
22
  .message(parsed.message)
23
23
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ehbrs
4
+ module Tools
5
+ module Self
6
+ module Observers
7
+ class UsedSpace < ::Ehbrs::Tools::Self::Observers::WithPersistence
8
+ def path
9
+ label
10
+ end
11
+
12
+ def calculate_value
13
+ env = ::EacRubyUtils::Envs.local
14
+ env.command('du', '-sb', path.to_s).pipe(
15
+ env.command('cut', '-f', '-1')
16
+ ).execute!.strip.to_i
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ehbrs
4
+ module Tools
5
+ module Self
6
+ module Observers
7
+ class WithPersistence
8
+ enable_simple_cache
9
+ common_constructor :label
10
+
11
+ def check_current_value
12
+ observer.check(current_value)
13
+ end
14
+
15
+ def changing_value?
16
+ observer.changing_value?(current_value)
17
+ end
18
+
19
+ private
20
+
21
+ def current_value_uncached
22
+ calculate_value
23
+ end
24
+
25
+ def observer_uncached
26
+ ::Ehbrs::Tools::Observers::WithPersistence.new(persistence_path, blank_value: :raise)
27
+ end
28
+
29
+ def persistence_path_uncached
30
+ ::Ehbrs::Tools::UserDirs.data.child('observers', label.to_s.parameterize)
31
+ .content_path.to_pathname
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ehbrs
4
+ module Tools
5
+ module Telegram
6
+ class MessageSending
7
+ acts_as_immutable
8
+ immutable_accessor :bot_token, :message
9
+ immutable_accessor :recipient_id, type: :array
10
+
11
+ def run
12
+ ::Telegram::Bot::Client.run(prop(:bot_token)) do |bot|
13
+ prop(:recipient_ids).each do |recipient_id|
14
+ bot.api.sendMessage(chat_id: recipient_id, text: prop(:message))
15
+ end
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def prop(attribute)
22
+ r = send(attribute)
23
+ return r if r.present?
24
+
25
+ raise "Attribute #{attribute} is blank"
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ehbrs
4
+ module Tools
5
+ module UserDirs
6
+ class << self
7
+ include ::EacRubyUtils::SimpleCache
8
+
9
+ def application_id
10
+ 'ehbrs-tools'
11
+ end
12
+
13
+ private
14
+
15
+ def user_home_dir_uncached
16
+ ::EacFs::StorageTree.new(Dir.home)
17
+ end
18
+
19
+ def cache_uncached
20
+ user_home_dir.child('.cache', application_id)
21
+ end
22
+
23
+ def config_uncached
24
+ user_home_dir.child('.config', application_id)
25
+ end
26
+
27
+ def data_uncached
28
+ user_home_dir.child('.local', 'share', application_id)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ehbrs
4
4
  module Tools
5
- VERSION = '0.44.0'
5
+ VERSION = '0.44.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ehbrs-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.44.0
4
+ version: 0.44.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-06-30 00:00:00.000000000 Z
11
+ date: 2026-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm-files
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '0.163'
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 0.163.3
36
+ version: 0.163.4
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,21 +43,27 @@ dependencies:
43
43
  version: '0.163'
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 0.163.3
46
+ version: 0.163.4
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: eac_cli
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0.43'
53
+ version: '0.44'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 0.44.3
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.43'
63
+ version: '0.44'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 0.44.3
61
67
  - !ruby/object:Gem::Dependency
62
68
  name: eac_fs
63
69
  requirement: !ruby/object:Gem::Requirement
@@ -65,6 +71,9 @@ dependencies:
65
71
  - - "~>"
66
72
  - !ruby/object:Gem::Version
67
73
  version: '0.19'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 0.19.1
68
77
  type: :runtime
69
78
  prerelease: false
70
79
  version_requirements: !ruby/object:Gem::Requirement
@@ -72,6 +81,9 @@ dependencies:
72
81
  - - "~>"
73
82
  - !ruby/object:Gem::Version
74
83
  version: '0.19'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 0.19.1
75
87
  - !ruby/object:Gem::Dependency
76
88
  name: eac_ruby_base0
77
89
  requirement: !ruby/object:Gem::Requirement
@@ -101,7 +113,7 @@ dependencies:
101
113
  version: '0.128'
102
114
  - - ">="
103
115
  - !ruby/object:Gem::Version
104
- version: 0.128.2
116
+ version: 0.128.5
105
117
  type: :runtime
106
118
  prerelease: false
107
119
  version_requirements: !ruby/object:Gem::Requirement
@@ -111,7 +123,7 @@ dependencies:
111
123
  version: '0.128'
112
124
  - - ">="
113
125
  - !ruby/object:Gem::Version
114
- version: 0.128.2
126
+ version: 0.128.5
115
127
  - !ruby/object:Gem::Dependency
116
128
  name: ehbrs_ruby_utils
117
129
  requirement: !ruby/object:Gem::Requirement
@@ -200,18 +212,14 @@ files:
200
212
  - Gemfile.lock
201
213
  - exe/ehbrs
202
214
  - lib/ehbrs.rb
203
- - lib/ehbrs/google/translate.rb
204
- - lib/ehbrs/google/translate/session.rb
205
- - lib/ehbrs/observers/base.rb
206
- - lib/ehbrs/observers/with_persistence.rb
207
- - lib/ehbrs/self/observers/used_space.rb
208
- - lib/ehbrs/self/observers/with_persistence.rb
209
- - lib/ehbrs/telegram/message_sending.rb
210
215
  - lib/ehbrs/tools.rb
211
216
  - lib/ehbrs/tools/application.rb
212
217
  - lib/ehbrs/tools/core_ext.rb
213
218
  - lib/ehbrs/tools/executables.rb
219
+ - lib/ehbrs/tools/google/translate/session.rb
214
220
  - lib/ehbrs/tools/instance.rb
221
+ - lib/ehbrs/tools/observers/base.rb
222
+ - lib/ehbrs/tools/observers/with_persistence.rb
215
223
  - lib/ehbrs/tools/runner.rb
216
224
  - lib/ehbrs/tools/runner/booking.rb
217
225
  - lib/ehbrs/tools/runner/booking/accommodations.rb
@@ -261,8 +269,11 @@ files:
261
269
  - lib/ehbrs/tools/runner/web_utils/videos.rb
262
270
  - lib/ehbrs/tools/runner/web_utils/videos/download.rb
263
271
  - lib/ehbrs/tools/runner/web_utils/videos/upload.rb
272
+ - lib/ehbrs/tools/self/observers/used_space.rb
273
+ - lib/ehbrs/tools/self/observers/with_persistence.rb
274
+ - lib/ehbrs/tools/telegram/message_sending.rb
275
+ - lib/ehbrs/tools/user_dirs.rb
264
276
  - lib/ehbrs/tools/version.rb
265
- - lib/ehbrs/user_dirs.rb
266
277
  - template/ehbrs/cooking_book/build/base_page/layout.html.erb
267
278
  - template/ehbrs/cooking_book/build/index_page/inner.html.erb
268
279
  - template/ehbrs/cooking_book/build/recipe_page/inner.html.erb
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ehbrs
4
- module Google
5
- module Translate
6
- class Session
7
- START_URL = 'https://translate.google.com.br/#view=home&op=docs&sl=en&tl=pt'
8
- CLOSE_POPUP_CSS = '.dismiss-button'
9
- FILE_INPUT_XPATH = '//*[@id = "tlid-file-input"]'
10
- SUBMIT_XPATH = '//form[@action="//translate.googleusercontent.com/translate_f"]' \
11
- '//input[@type="submit"]'
12
- RESULT_XPATHS = [
13
- '//script[contains(@src, "https://translate.google.com/translate_a")]',
14
- '/html/body/pre'
15
- ].freeze
16
-
17
- attr_reader :sub
18
-
19
- def initialize
20
- @sub = ::Aranha::Selenium::Session.new
21
- end
22
-
23
- def translate(source_document_path)
24
- go_to_upload_form
25
- input_file(source_document_path)
26
- close_changes_alert_popup
27
- click_on_translate_button
28
- wait_for_load_translation
29
- sub.current_source
30
- end
31
-
32
- private
33
-
34
- def go_to_upload_form
35
- sub.navigate.to START_URL
36
- sub.wait_for_element(xpath: FILE_INPUT_XPATH)
37
- end
38
-
39
- def input_file(source_document_path)
40
- sub.find_element(xpath: FILE_INPUT_XPATH).send_keys(source_document_path)
41
- end
42
-
43
- def click_on_translate_button
44
- sub.wait_for_click(xpath: SUBMIT_XPATH)
45
- end
46
-
47
- def close_changes_alert_popup
48
- sub.wait_for_click(css: CLOSE_POPUP_CSS)
49
- end
50
-
51
- def wait_for_load_translation
52
- sub.wait.until do
53
- RESULT_XPATHS.any? { |xpath| sub.find_elements(xpath: xpath).size.positive? }
54
- end
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ehbrs
4
- module Google
5
- module Translate
6
- require_sub __FILE__
7
- end
8
- end
9
- end
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ehbrs
4
- module Observers
5
- class Base
6
- include ::EacRubyUtils::Listable
7
-
8
- lists.add_string :blank_value, :add, :ignore, :raise
9
-
10
- attr_reader :records, :blank_value, :last_check_time
11
-
12
- common_constructor :options, default: [{}] do
13
- @records = options[:records] || []
14
- @blank_value = options[:blank_value].if_present(BLANK_VALUE_ADD) do |v|
15
- v = v.to_s
16
- ::Ehbrs::Observers::Base.lists.blank_value.value_validate!(v)
17
- v
18
- end
19
- end
20
-
21
- def check(value, date = ::Time.required_zone.now)
22
- @last_check_time = date
23
- send("check_with_blank_value_#{blank_value}", value, date)
24
- end
25
-
26
- def changing_value?(value)
27
- records.if_present(true) do
28
- last_value.if_present(value.present?) { |v| v != value }
29
- end
30
- end
31
-
32
- def last_change_time
33
- records.last.if_present(&:time)
34
- end
35
-
36
- def last_value
37
- records.last.if_present(&:value)
38
- end
39
-
40
- private
41
-
42
- def check_with_blank_value_add(value, time) # rubocop:disable Naming/PredicateMethod
43
- return false unless changing_value?(value)
44
-
45
- records << { value: value, time: time }.to_struct
46
- true
47
- end
48
-
49
- def check_with_blank_value_ignore(value, date) # rubocop:disable Naming/PredicateMethod
50
- false if value.blank? ? false : check_with_blank_value_add(value, date)
51
- end
52
-
53
- def check_with_blank_value_raise(value, date)
54
- raise(::ArgumentError, "Blank value checked (Value: #{value}, Class: #{value.class})") if
55
- value.blank?
56
-
57
- check_with_blank_value_add(value, date)
58
- end
59
- end
60
- end
61
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ehbrs
4
- module Observers
5
- class WithPersistence < ::Ehbrs::Observers::Base
6
- attr_reader :path
7
-
8
- def initialize(path, options = {})
9
- super(options)
10
- @path = path.to_pathname
11
- load
12
- end
13
-
14
- def check(value, date = ::Time.required_zone.now)
15
- save if super
16
- end
17
-
18
- def load
19
- save unless path.exist?
20
- data = ::YAML.load_file(path.to_path)
21
- @records = data.fetch(:records).map(&:to_struct)
22
- @last_check_time = data.fetch(:last_check_time)
23
- end
24
-
25
- def save
26
- path.parent.mkpath
27
- path.write({ records: records.map(&:to_h), last_check_time: last_check_time }.to_yaml)
28
- end
29
- end
30
- end
31
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ehbrs
4
- module Self
5
- module Observers
6
- class UsedSpace < ::Ehbrs::Self::Observers::WithPersistence
7
- def path
8
- label
9
- end
10
-
11
- def calculate_value
12
- env = ::EacRubyUtils::Envs.local
13
- env.command('du', '-sb', path.to_s).pipe(
14
- env.command('cut', '-f', '-1')
15
- ).execute!.strip.to_i
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ehbrs
4
- module Self
5
- module Observers
6
- class WithPersistence
7
- enable_simple_cache
8
- common_constructor :label
9
-
10
- def check_current_value
11
- observer.check(current_value)
12
- end
13
-
14
- def changing_value?
15
- observer.changing_value?(current_value)
16
- end
17
-
18
- private
19
-
20
- def current_value_uncached
21
- calculate_value
22
- end
23
-
24
- def observer_uncached
25
- ::Ehbrs::Observers::WithPersistence.new(persistence_path, blank_value: :raise)
26
- end
27
-
28
- def persistence_path_uncached
29
- ::Ehbrs::UserDirs.data.child('observers', label.to_s.parameterize)
30
- .content_path.to_pathname
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ehbrs
4
- module Telegram
5
- class MessageSending
6
- acts_as_immutable
7
- immutable_accessor :bot_token, :message
8
- immutable_accessor :recipient_id, type: :array
9
-
10
- def run
11
- ::Telegram::Bot::Client.run(prop(:bot_token)) do |bot|
12
- prop(:recipient_ids).each do |recipient_id|
13
- bot.api.sendMessage(chat_id: recipient_id, text: prop(:message))
14
- end
15
- end
16
- end
17
-
18
- private
19
-
20
- def prop(attribute)
21
- r = send(attribute)
22
- return r if r.present?
23
-
24
- raise "Attribute #{attribute} is blank"
25
- end
26
- end
27
- end
28
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ehbrs
4
- module UserDirs
5
- class << self
6
- include ::EacRubyUtils::SimpleCache
7
-
8
- def application_id
9
- 'ehbrs-tools'
10
- end
11
-
12
- private
13
-
14
- def user_home_dir_uncached
15
- ::EacFs::StorageTree.new(Dir.home)
16
- end
17
-
18
- def cache_uncached
19
- user_home_dir.child('.cache', application_id)
20
- end
21
-
22
- def config_uncached
23
- user_home_dir.child('.config', application_id)
24
- end
25
-
26
- def data_uncached
27
- user_home_dir.child('.local', 'share', application_id)
28
- end
29
- end
30
- end
31
- end