ehbrs-tools 0.44.0 → 0.44.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 +4 -4
- data/Gemfile.lock +59 -54
- data/lib/ehbrs/tools/google/translate/session.rb +61 -0
- data/lib/ehbrs/tools/observers/base.rb +63 -0
- data/lib/ehbrs/tools/observers/with_persistence.rb +33 -0
- data/lib/ehbrs/tools/runner/fs/used_space.rb +1 -1
- data/lib/ehbrs/tools/runner/google/translate.rb +1 -1
- data/lib/ehbrs/tools/runner/telegram/send_message.rb +1 -1
- data/lib/ehbrs/tools/self/observers/used_space.rb +22 -0
- data/lib/ehbrs/tools/self/observers/with_persistence.rb +37 -0
- data/lib/ehbrs/tools/telegram/message_sending.rb +30 -0
- data/lib/ehbrs/tools/user_dirs.rb +33 -0
- data/lib/ehbrs/tools/version.rb +1 -1
- metadata +17 -12
- data/lib/ehbrs/google/translate/session.rb +0 -59
- data/lib/ehbrs/google/translate.rb +0 -9
- data/lib/ehbrs/observers/base.rb +0 -61
- data/lib/ehbrs/observers/with_persistence.rb +0 -31
- data/lib/ehbrs/self/observers/used_space.rb +0 -20
- data/lib/ehbrs/self/observers/with_persistence.rb +0 -35
- data/lib/ehbrs/telegram/message_sending.rb +0 -28
- data/lib/ehbrs/user_dirs.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e190e89a928173f9fc58574e003f1072d3dac04227ec3e6e8e929e21baa3c4f5
|
4
|
+
data.tar.gz: aec37125c29a31d2f79d9443444a6159c173a68e3e7600f1515dab8f46b2b448
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64816ee18b95f04d1953bf0d8e67367b43e91c262d04ef21cd8995bbfcd65a8ed98730e908dd92263c521fd81f5539791586f56a382154c941dcdbb61800391a
|
7
|
+
data.tar.gz: e8455291cb23ad4c6ba1a2bc1cfb42a48e17eea64b95cfb82a685a18553f0f1e7be9999d1b3800e4a80bbab0ff11797778ac73dd168f0800b7fef0ee143afe50
|
data/Gemfile.lock
CHANGED
@@ -1,39 +1,61 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ehbrs-tools (0.44.
|
4
|
+
ehbrs-tools (0.44.1)
|
5
5
|
avm-files (~> 0.9)
|
6
6
|
avm-tools (~> 0.163, >= 0.163.3)
|
7
|
-
eac_cli (~> 0.43)
|
7
|
+
eac_cli (~> 0.43, >= 0.43.1)
|
8
8
|
eac_fs (~> 0.19)
|
9
9
|
eac_ruby_base0 (~> 0.19, >= 0.19.2)
|
10
|
-
eac_ruby_utils (~> 0.128, >= 0.128.
|
10
|
+
eac_ruby_utils (~> 0.128, >= 0.128.3)
|
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/
|
17
|
+
remote: sub/avm-eac_ruby_base1
|
18
18
|
specs:
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
avm-eac_ruby_base1 (0.37.1)
|
20
|
+
avm (~> 0.96, >= 0.96.1)
|
21
|
+
avm-eac_generic_base0 (~> 0.15, >= 0.15.1)
|
22
|
+
eac_envs-http (~> 0.7)
|
23
|
+
eac_ruby_utils (~> 0.128, >= 0.128.3)
|
23
24
|
|
24
25
|
PATH
|
25
|
-
remote: sub/
|
26
|
+
remote: sub/eac_cli
|
26
27
|
specs:
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
eac_cli (0.43.1)
|
29
|
+
colorize (~> 0.8, >= 0.8.1)
|
30
|
+
eac_config (~> 0.15)
|
31
|
+
eac_ruby_utils (~> 0.128, >= 0.128.3)
|
32
|
+
tty-table (~> 0.12)
|
33
|
+
|
34
|
+
PATH
|
35
|
+
remote: sub/eac_envs-http
|
36
|
+
specs:
|
37
|
+
eac_envs-http (0.7.0)
|
30
38
|
eac_fs (~> 0.19)
|
31
|
-
eac_ruby_utils (~> 0.128, >= 0.128.
|
39
|
+
eac_ruby_utils (~> 0.128, >= 0.128.3)
|
40
|
+
faraday (~> 2.8, >= 2.8.1)
|
41
|
+
faraday-follow_redirects (~> 0.3)
|
42
|
+
faraday-gzip (~> 0.1)
|
43
|
+
faraday-multipart (~> 1.1, >= 1.1.1)
|
44
|
+
faraday-retry (~> 2.3, >= 2.3.2)
|
45
|
+
random-port (~> 0.7, >= 0.7.1)
|
46
|
+
|
47
|
+
PATH
|
48
|
+
remote: sub/eac_fs
|
49
|
+
specs:
|
50
|
+
eac_fs (0.19.1)
|
51
|
+
content-type (~> 0.0, >= 0.0.2)
|
52
|
+
eac_ruby_utils (~> 0.128, >= 0.128.3)
|
53
|
+
ruby-filemagic (~> 0.7, >= 0.7.3)
|
32
54
|
|
33
55
|
PATH
|
34
56
|
remote: sub/eac_ruby_utils
|
35
57
|
specs:
|
36
|
-
eac_ruby_utils (0.128.
|
58
|
+
eac_ruby_utils (0.128.3)
|
37
59
|
activesupport (>= 4, < 7)
|
38
60
|
addressable (~> 2.8, >= 2.8.7)
|
39
61
|
bundler
|
@@ -41,25 +63,6 @@ PATH
|
|
41
63
|
net-ssh (~> 4.2)
|
42
64
|
zeitwerk (~> 2.6, >= 2.6.18)
|
43
65
|
|
44
|
-
PATH
|
45
|
-
remote: sub/ehbrs_ruby_utils
|
46
|
-
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)
|
62
|
-
|
63
66
|
GEM
|
64
67
|
remote: https://rubygems.org/
|
65
68
|
specs:
|
@@ -113,11 +116,6 @@ GEM
|
|
113
116
|
avm-eac_ruby_base1 (~> 0.35, >= 0.35.1)
|
114
117
|
avm-eac_webapp_base0 (~> 0.20, >= 0.20.1)
|
115
118
|
eac_ruby_utils (~> 0.123)
|
116
|
-
avm-eac_ruby_base1 (0.37.0)
|
117
|
-
avm (~> 0.96, >= 0.96.1)
|
118
|
-
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
119
|
avm-eac_ubuntu_base0 (0.5.1)
|
122
120
|
avm (~> 0.86, >= 0.86.2)
|
123
121
|
eac_ruby_utils (~> 0.121)
|
@@ -157,30 +155,21 @@ GEM
|
|
157
155
|
thread_safe (~> 0.3, >= 0.3.1)
|
158
156
|
diff-lcs (1.6.2)
|
159
157
|
dry-inflector (1.1.0)
|
160
|
-
eac_cli (0.43.0)
|
161
|
-
colorize (~> 0.8, >= 0.8.1)
|
162
|
-
eac_config (~> 0.14, >= 0.14.3)
|
163
|
-
eac_ruby_utils (~> 0.127)
|
164
|
-
tty-table (~> 0.12)
|
165
158
|
eac_config (0.15.0)
|
166
159
|
addressable (~> 2.8, >= 2.8.7)
|
167
160
|
eac_ruby_utils (~> 0.127)
|
168
161
|
eac_docker (0.7.0)
|
169
162
|
eac_ruby_utils (~> 0.112)
|
170
163
|
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)
|
174
|
-
faraday (~> 2.8, >= 2.8.1)
|
175
|
-
faraday-follow_redirects (~> 0.3)
|
176
|
-
faraday-gzip (~> 0.1)
|
177
|
-
faraday-multipart (~> 1.0, >= 1.0.4)
|
178
|
-
faraday-retry (~> 2.2, >= 2.2.1)
|
179
|
-
random-port (~> 0.7, >= 0.7.1)
|
180
164
|
eac_rest (0.12.0)
|
181
165
|
eac_envs-http (~> 0.5)
|
182
166
|
eac_fs (~> 0.16)
|
183
167
|
eac_ruby_utils (~> 0.120)
|
168
|
+
eac_ruby_base0 (0.19.2)
|
169
|
+
avm-eac_ruby_base1 (~> 0.37)
|
170
|
+
eac_cli (~> 0.43)
|
171
|
+
eac_fs (~> 0.19)
|
172
|
+
eac_ruby_utils (~> 0.128, >= 0.128.2)
|
184
173
|
eac_ruby_gem_support (0.12.0)
|
185
174
|
eac_ruby_utils (~> 0.127)
|
186
175
|
rspec (~> 3.13, >= 3.13.1)
|
@@ -191,6 +180,21 @@ GEM
|
|
191
180
|
eac_templates (0.8.1)
|
192
181
|
eac_config (~> 0.15)
|
193
182
|
eac_ruby_utils (~> 0.127)
|
183
|
+
ehbrs_ruby_utils (0.45.0)
|
184
|
+
aranha (~> 0.20)
|
185
|
+
aranha-parsers (~> 0.26, >= 0.26.1)
|
186
|
+
aranha-selenium (~> 0.12)
|
187
|
+
avm (~> 0.96, >= 0.96.1)
|
188
|
+
avm-eac_rails_base0 (~> 0.11, >= 0.11.1)
|
189
|
+
dentaku (~> 3.5, >= 3.5.4)
|
190
|
+
eac_fs (~> 0.19)
|
191
|
+
eac_rest (~> 0.12)
|
192
|
+
eac_ruby_utils (~> 0.128, >= 0.128.2)
|
193
|
+
eac_templates (~> 0.8, >= 0.8.1)
|
194
|
+
inifile (~> 3.0)
|
195
|
+
srt (~> 0.1, >= 0.1.5)
|
196
|
+
taglib-ruby (~> 1.1, >= 1.1.3)
|
197
|
+
ultimate_lyrics (~> 0.1, >= 0.1.3)
|
194
198
|
faraday (2.8.1)
|
195
199
|
base64
|
196
200
|
faraday-net_http (>= 2.0, < 3.1)
|
@@ -325,12 +329,13 @@ PLATFORMS
|
|
325
329
|
x86_64-linux
|
326
330
|
|
327
331
|
DEPENDENCIES
|
332
|
+
avm-eac_ruby_base1!
|
333
|
+
eac_cli!
|
334
|
+
eac_envs-http!
|
328
335
|
eac_fs!
|
329
|
-
eac_ruby_base0!
|
330
336
|
eac_ruby_gem_support (~> 0.12)
|
331
337
|
eac_ruby_utils!
|
332
338
|
ehbrs-tools!
|
333
|
-
ehbrs_ruby_utils!
|
334
339
|
|
335
340
|
BUNDLED WITH
|
336
341
|
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) # rubocop:disable Naming/PredicateMethod
|
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
|
@@ -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
|
data/lib/ehbrs/tools/version.rb
CHANGED
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.
|
4
|
+
version: 0.44.1
|
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-
|
11
|
+
date: 2025-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avm-files
|
@@ -51,6 +51,9 @@ dependencies:
|
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0.43'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.43.1
|
54
57
|
type: :runtime
|
55
58
|
prerelease: false
|
56
59
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,6 +61,9 @@ dependencies:
|
|
58
61
|
- - "~>"
|
59
62
|
- !ruby/object:Gem::Version
|
60
63
|
version: '0.43'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.43.1
|
61
67
|
- !ruby/object:Gem::Dependency
|
62
68
|
name: eac_fs
|
63
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,7 +107,7 @@ dependencies:
|
|
101
107
|
version: '0.128'
|
102
108
|
- - ">="
|
103
109
|
- !ruby/object:Gem::Version
|
104
|
-
version: 0.128.
|
110
|
+
version: 0.128.3
|
105
111
|
type: :runtime
|
106
112
|
prerelease: false
|
107
113
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -111,7 +117,7 @@ dependencies:
|
|
111
117
|
version: '0.128'
|
112
118
|
- - ">="
|
113
119
|
- !ruby/object:Gem::Version
|
114
|
-
version: 0.128.
|
120
|
+
version: 0.128.3
|
115
121
|
- !ruby/object:Gem::Dependency
|
116
122
|
name: ehbrs_ruby_utils
|
117
123
|
requirement: !ruby/object:Gem::Requirement
|
@@ -200,18 +206,14 @@ files:
|
|
200
206
|
- Gemfile.lock
|
201
207
|
- exe/ehbrs
|
202
208
|
- 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
209
|
- lib/ehbrs/tools.rb
|
211
210
|
- lib/ehbrs/tools/application.rb
|
212
211
|
- lib/ehbrs/tools/core_ext.rb
|
213
212
|
- lib/ehbrs/tools/executables.rb
|
213
|
+
- lib/ehbrs/tools/google/translate/session.rb
|
214
214
|
- lib/ehbrs/tools/instance.rb
|
215
|
+
- lib/ehbrs/tools/observers/base.rb
|
216
|
+
- lib/ehbrs/tools/observers/with_persistence.rb
|
215
217
|
- lib/ehbrs/tools/runner.rb
|
216
218
|
- lib/ehbrs/tools/runner/booking.rb
|
217
219
|
- lib/ehbrs/tools/runner/booking/accommodations.rb
|
@@ -261,8 +263,11 @@ files:
|
|
261
263
|
- lib/ehbrs/tools/runner/web_utils/videos.rb
|
262
264
|
- lib/ehbrs/tools/runner/web_utils/videos/download.rb
|
263
265
|
- lib/ehbrs/tools/runner/web_utils/videos/upload.rb
|
266
|
+
- lib/ehbrs/tools/self/observers/used_space.rb
|
267
|
+
- lib/ehbrs/tools/self/observers/with_persistence.rb
|
268
|
+
- lib/ehbrs/tools/telegram/message_sending.rb
|
269
|
+
- lib/ehbrs/tools/user_dirs.rb
|
264
270
|
- lib/ehbrs/tools/version.rb
|
265
|
-
- lib/ehbrs/user_dirs.rb
|
266
271
|
- template/ehbrs/cooking_book/build/base_page/layout.html.erb
|
267
272
|
- template/ehbrs/cooking_book/build/index_page/inner.html.erb
|
268
273
|
- 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
|
data/lib/ehbrs/observers/base.rb
DELETED
@@ -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
|
data/lib/ehbrs/user_dirs.rb
DELETED
@@ -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
|