ehbrs_ruby_utils 0.12.1 → 0.15.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: b04c8994ff027248ae7a38e28ac25b0b6e895b78c01fbf60ef61eebfe520efd1
4
- data.tar.gz: af8ada82641ddd7f247d2d0182d71a1a8a5b0e9bd6931dd3cc136ffa0e058140
3
+ metadata.gz: b1b4304692f05e5e54ceb820c286af557d625f2c387c88b413f79cadf23a6da2
4
+ data.tar.gz: a09d3e1bd870a882c541b161cdba964de47454cac366f5dcbc1ba905246d2d7e
5
5
  SHA512:
6
- metadata.gz: b0448fc34d7c469378b4ec8e2251c20c1ba63a8fd6461cab3dfa2520a08d8e76574eb4d19d50cd876d691ee2a4e9b8af45bc09baa5d76132985ac3552e06f3b3
7
- data.tar.gz: f4b0758f258963daf7e48a171fecd3774d141c351acb0bbc5d571d732f97255c9628b2852bcfcb3d95cd472d58d29465bf7cb959ac439bc2ebb86c1d9610f92a
6
+ metadata.gz: a205eed1a3e4659a457f57ad3f0b6965fc02e5a2105fe6dbac1adc9ac714798ba1db424024d34d1ba15cd9b04a367c853765bbdcbcdaa8714289e6c8035be1c1
7
+ data.tar.gz: f8dbde785c72cfb1641881de9d193079bbec210f9c77f33710519ada3fc8775f29a49eb7634efe295a4b20af8ef06fdbb40323989dffb5740b1897720779ab57
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_fs/traverser'
3
4
  require 'eac_ruby_utils/core_ext'
4
5
 
5
6
  module EhbrsRubyUtils
@@ -28,7 +29,16 @@ module EhbrsRubyUtils
28
29
 
29
30
  # @return [Pathname]
30
31
  def found_uncached
31
- root_path.glob("**/#{filename}").map(&:parent).sort
32
+ r = []
33
+ ft = ::EacFs::Traverser.new(
34
+ recursive: true,
35
+ hidden_directories: true,
36
+ check_file: lambda do |file|
37
+ r << file.parent if file.basename.to_path == filename.to_s
38
+ end
39
+ )
40
+ ft.check_path(root_path)
41
+ r.sort
32
42
  end
33
43
  end
34
44
  end
@@ -42,7 +42,7 @@ module EhbrsRubyUtils
42
42
 
43
43
  def albums_directories_uncached
44
44
  r = []
45
- t = ::EacRubyUtils::Fs::Traverser.new
45
+ t = ::EacFs::Traverser.new
46
46
  t.recursive = true
47
47
  t.check_directory = ->(directory) { r << directory }
48
48
  t.check_path(source_dir)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EhbrsRubyUtils
4
- VERSION = '0.12.1'
4
+ VERSION = '0.15.0'
5
5
  end
@@ -8,7 +8,8 @@ module EhbrsRubyUtils
8
8
  module Videos
9
9
  class ConvertJob
10
10
  FORMATS_TO_EXTENSIONS = {
11
- 'matroska' => '.mkv'
11
+ 'matroska' => '.mkv',
12
+ 'mp4' => '.mp4'
12
13
  }.freeze
13
14
 
14
15
  enable_speaker
@@ -53,6 +53,10 @@ module EhbrsRubyUtils
53
53
  tags[:language]
54
54
  end
55
55
 
56
+ def language_with_title
57
+ [language, title].reject(&:blank?).if_present { |v| v.join('_').variableize }
58
+ end
59
+
56
60
  def title
57
61
  tags[:title]
58
62
  end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/base'
4
+ require 'avm/result'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module EhbrsRubyUtils
8
+ module WebUtils
9
+ class Instance < ::Avm::Instances::Base
10
+ class Finances
11
+ class Bills
12
+ class Consume
13
+ class File
14
+ enable_speaker
15
+ enable_simple_cache
16
+ common_constructor(:bills, :path) { perform }
17
+ delegate :instance, to: :bills
18
+
19
+ protected
20
+
21
+ def perform
22
+ infov 'Relative path', relative_path
23
+ process_response
24
+ end
25
+
26
+ def relative_path
27
+ path.relative_path_from(bills.pending_directory.to_path)
28
+ end
29
+
30
+ def process_response
31
+ if response_status_result.success?
32
+ move_to_registered
33
+ else
34
+ warn(" * Retornou com status de erro:\n\n#{response.body}")
35
+ end
36
+ infov ' * Response status', response_status_result.label
37
+ end
38
+
39
+ def move_to_registered
40
+ ::FileUtils.mkdir_p(::File.dirname(target_path))
41
+ ::File.rename(path, target_path)
42
+ end
43
+
44
+ def target_path
45
+ ::File.join(bills.registered_directory, relative_path)
46
+ end
47
+
48
+ def response_uncached
49
+ bills.instance.http_request(
50
+ '/finances/file_imports',
51
+ method: :post,
52
+ body: {
53
+ 'record[file]' => ::File.new(path)
54
+ },
55
+ header: {
56
+ 'Accept' => 'application/json'
57
+ }
58
+ )
59
+ end
60
+
61
+ def response_status_result
62
+ ::Avm::Result.success_or_error(
63
+ response.status.to_s.match?(/\A2\d{2}\z/),
64
+ response.status
65
+ )
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EhbrsRubyUtils
7
+ module WebUtils
8
+ class Instance < ::Avm::Instances::Base
9
+ class Finances
10
+ class Bills
11
+ class Consume
12
+ require_sub __FILE__
13
+ common_constructor(:bills)
14
+ delegate :instance, :pending_directory, :registered_directory, to: :bills
15
+
16
+ def perform
17
+ bills.pending_directory.glob('**/*').each do |path|
18
+ next unless path.file?
19
+
20
+ ::EhbrsRubyUtils::WebUtils::Instance::Finances::Bills::Consume::File.new(self, path)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EhbrsRubyUtils
7
+ module WebUtils
8
+ class Instance < ::Avm::Instances::Base
9
+ class Finances
10
+ class Bills
11
+ require_sub __FILE__
12
+ common_constructor :finances
13
+ delegate :instance, to: :finances
14
+
15
+ # @return [Pathname]
16
+ def bills_directory(suffix)
17
+ instance.read_entry('finances.bills.directory').to_pathname.join(suffix)
18
+ end
19
+
20
+ # @return [EhbrsRubyUtils::WebUtils::Instance::Finances::Bills::Consume]
21
+ def consume
22
+ ::EhbrsRubyUtils::WebUtils::Instance::Finances::Bills::Consume.new(self)
23
+ end
24
+
25
+ # @return [Pathname]
26
+ def pending_directory
27
+ bills_directory('pending')
28
+ end
29
+
30
+ # @return [Pathname]
31
+ def registered_directory
32
+ bills_directory('registered')
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EhbrsRubyUtils
7
+ module WebUtils
8
+ class Instance < ::Avm::Instances::Base
9
+ class Finances
10
+ require_sub __FILE__
11
+ enable_simple_cache
12
+ common_constructor :instance
13
+
14
+ private
15
+
16
+ def bills_uncached
17
+ ::EhbrsRubyUtils::WebUtils::Instance::Finances::Bills.new(self)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -7,8 +7,14 @@ require 'httpclient'
7
7
  module EhbrsRubyUtils
8
8
  module WebUtils
9
9
  class Instance < ::Avm::Instances::Base
10
+ require_sub __FILE__
11
+
12
+ def finances
13
+ @finances ||= ::EhbrsRubyUtils::WebUtils::Instance::Finances.new(self)
14
+ end
15
+
10
16
  def root_url
11
- read_entry(:url)
17
+ read_entry(::Avm::Instances::EntryKeys::WEB_URL)
12
18
  end
13
19
 
14
20
  def resource_url(resource_url_suffix)
@@ -7,7 +7,7 @@ RSpec.describe ::EhbrsRubyUtils::Videos::Stream do
7
7
 
8
8
  def source_data(source_file)
9
9
  instance = described_class.new(::YAML.load_file(source_file))
10
- %w[codec_name codec_long_name codec_type index language title]
10
+ %w[codec_name codec_long_name codec_type index language language_with_title title]
11
11
  .map { |k| [k.to_sym, instance.send(k)] }.sort.to_h
12
12
  end
13
13
  end
@@ -4,4 +4,5 @@
4
4
  :codec_type: :attachment
5
5
  :index: 19
6
6
  :language:
7
+ :language_with_title:
7
8
  :title:
@@ -4,4 +4,5 @@
4
4
  :codec_type: :audio
5
5
  :index: 18
6
6
  :language: jpn
7
+ :language_with_title: jpn_animerg_tenshi_no_tamago_1080p_scavvykid
7
8
  :title: "[AnimeRG] Tenshi No Tamago [1080p] [ScavvyKiD]"
@@ -4,4 +4,5 @@
4
4
  :codec_type: :subtitle
5
5
  :index: 0
6
6
  :language: fre
7
+ :language_with_title: fre_french_subs
7
8
  :title: French Subs
@@ -4,4 +4,5 @@
4
4
  :codec_type: :video
5
5
  :index: 17
6
6
  :language: eng
7
+ :language_with_title: eng_animerg_tenshi_no_tamago_1080p_scavvykid
7
8
  :title: "[AnimeRG] Tenshi No Tamago [1080p] [ScavvyKiD]"
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.12.1
4
+ version: 0.15.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: 2021-10-07 00:00:00.000000000 Z
11
+ date: 2022-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -188,6 +188,10 @@ files:
188
188
  - lib/ehbrs_ruby_utils/videos/stream.rb
189
189
  - lib/ehbrs_ruby_utils/web_utils.rb
190
190
  - lib/ehbrs_ruby_utils/web_utils/instance.rb
191
+ - lib/ehbrs_ruby_utils/web_utils/instance/finances.rb
192
+ - lib/ehbrs_ruby_utils/web_utils/instance/finances/bills.rb
193
+ - lib/ehbrs_ruby_utils/web_utils/instance/finances/bills/consume.rb
194
+ - lib/ehbrs_ruby_utils/web_utils/instance/finances/bills/consume/file.rb
191
195
  - lib/ehbrs_ruby_utils/web_utils/videos.rb
192
196
  - lib/ehbrs_ruby_utils/web_utils/videos/file.rb
193
197
  - lib/ehbrs_ruby_utils/web_utils/videos/file/rename.rb