ehbrs-tools 0.16.3 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ehbrs/cooking_book.rb +9 -0
  3. data/lib/ehbrs/cooking_book/build.rb +45 -0
  4. data/lib/ehbrs/cooking_book/build/base_page.rb +43 -0
  5. data/lib/ehbrs/cooking_book/build/index_page.rb +26 -0
  6. data/lib/ehbrs/cooking_book/build/recipe_page.rb +27 -0
  7. data/lib/ehbrs/cooking_book/project.rb +25 -0
  8. data/lib/ehbrs/cooking_book/recipe.rb +37 -0
  9. data/lib/ehbrs/cooking_book/recipe/ingredient.rb +21 -0
  10. data/lib/ehbrs/cooking_book/recipe/measure.rb +60 -0
  11. data/lib/ehbrs/cooking_book/recipe/part.rb +32 -0
  12. data/lib/ehbrs/patches/module/erb_template.rb +11 -0
  13. data/lib/ehbrs/patches/object/erb_template.rb +9 -0
  14. data/lib/ehbrs/patches/object/template.rb +7 -0
  15. data/lib/ehbrs/runner.rb +6 -13
  16. data/lib/ehbrs/runner/cooking_book.rb +30 -0
  17. data/lib/ehbrs/runner/cooking_book/build.rb +32 -0
  18. data/lib/ehbrs/runner/telegram.rb +26 -0
  19. data/lib/ehbrs/runner/telegram/send_message.rb +29 -0
  20. data/lib/ehbrs/runner/videos/unsupported.rb +1 -1
  21. data/lib/ehbrs/telegram.rb +9 -0
  22. data/lib/ehbrs/telegram/message_sending.rb +32 -0
  23. data/lib/ehbrs/tools/application.rb +13 -0
  24. data/lib/ehbrs/tools/instance.rb +16 -0
  25. data/lib/ehbrs/tools/version.rb +1 -1
  26. data/lib/ehbrs/videos/track.rb +1 -19
  27. data/lib/ehbrs/videos/unsupported/check_support.rb +1 -1
  28. data/lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb +1 -1
  29. data/lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb +1 -1
  30. data/lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb +2 -2
  31. data/lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb +1 -1
  32. data/lib/ehbrs/videos/unsupported/fix_profile.rb +0 -13
  33. data/lib/ehbrs/videos/unsupported/fixes/supported_codec.rb +10 -10
  34. data/lib/ehbrs/videos/unsupported/profiles/aoc.rb +27 -0
  35. data/template/ehbrs/cooking_book/build/base_page/layout.html.erb +20 -0
  36. data/template/ehbrs/cooking_book/build/index_page/inner.html.erb +6 -0
  37. data/template/ehbrs/cooking_book/build/recipe_page/inner.html.erb +6 -0
  38. data/template/ehbrs/cooking_book/build/recipe_page/part.html.erb +27 -0
  39. data/vendor/eac_cli/lib/eac_cli/docopt/runner_context_replacement.rb +15 -0
  40. data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +5 -0
  41. data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +4 -4
  42. data/vendor/eac_cli/lib/eac_cli/parser/alternative/long_options.rb +37 -0
  43. data/vendor/eac_cli/lib/eac_cli/parser/alternative/option_argument.rb +29 -0
  44. data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +7 -36
  45. data/vendor/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +45 -0
  46. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +3 -1
  47. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +19 -2
  48. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  49. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +22 -1
  50. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +29 -0
  51. data/vendor/eac_ruby_base0/Gemfile +5 -0
  52. data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +20 -0
  53. data/vendor/eac_ruby_base0/lib/eac_ruby_base0.rb +7 -0
  54. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +69 -0
  55. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +54 -0
  56. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner/test_all.rb +22 -0
  57. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +5 -0
  58. data/vendor/eac_ruby_base0/spec/rubocop_spec.rb +7 -0
  59. data/vendor/eac_ruby_base0/spec/spec_helper.rb +100 -0
  60. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +16 -6
  61. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +2 -99
  62. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb +29 -0
  63. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb +53 -0
  64. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb +54 -0
  65. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +10 -1
  66. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traverser.rb +0 -2
  67. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +4 -1
  68. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +38 -0
  69. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel.rb +4 -0
  70. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +8 -0
  71. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/template.rb +10 -0
  72. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/template.rb +1 -8
  73. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_sub.rb +2 -2
  74. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb +3 -2
  75. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  76. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +8 -0
  77. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +14 -4
  78. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +30 -0
  79. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +2 -1
  80. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/local_time_zone_spec.rb +17 -0
  81. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +1 -1
  82. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb +1 -1
  83. metadata +89 -9
  84. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/local_time_zone.rb +0 -25
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'ehbrs/cooking_book/build'
5
+
6
+ module Ehbrs
7
+ class Runner
8
+ class CookingBook
9
+ class Build
10
+ runner_with :help, :subcommands do
11
+ desc 'Operações para livros de receitas.'
12
+ arg_opt '-d', '--target-dir', 'Caminho para o diretório destino da construção.'
13
+ end
14
+
15
+ def run
16
+ infov 'Project', build.project
17
+ infov 'Target directory', build.target_dir
18
+ build.run
19
+ success 'Done'
20
+ end
21
+
22
+ private
23
+
24
+ def build_uncached
25
+ ::Ehbrs::CookingBook::Build.new(
26
+ runner_context.call(:project), target_dir: parsed.target_dir
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'ehbrs/tools/instance'
5
+
6
+ module Ehbrs
7
+ class Runner
8
+ class Telegram
9
+ require_sub __FILE__
10
+
11
+ runner_with :help, :subcommands do
12
+ desc 'Operações com Telegram.'
13
+ arg_opt '-b', '--bot-token', 'Token do bot Telegram.'
14
+ subcommands
15
+ end
16
+
17
+ def bot_token
18
+ parsed.bot_token || default_bot_token
19
+ end
20
+
21
+ def default_bot_token
22
+ ::Ehbrs::Tools.instance.read_entry(:telegram_bot_token)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'ehbrs/telegram/message_sending'
5
+
6
+ module Ehbrs
7
+ class Runner
8
+ class Telegram
9
+ class SendMessage
10
+ runner_with :help do
11
+ desc 'Envia mensagens Telegram.'
12
+ pos_arg :message
13
+ pos_arg :recipients_ids, repeat: true
14
+ end
15
+
16
+ delegate :run, to: :message_sending
17
+
18
+ private
19
+
20
+ def message_sending_uncached
21
+ parsed.recipients_ids
22
+ .inject(::Ehbrs::Telegram::MessageSending.new) { |a, e| a.recipient_id(e) }
23
+ .bot_token(runner_context.call(:bot_token))
24
+ .message(parsed.message)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -9,7 +9,7 @@ module Ehbrs
9
9
  class Runner
10
10
  class Videos
11
11
  class Unsupported
12
- PROFILES = %w[philco samsung].freeze
12
+ PROFILES = %w[aoc philco samsung].freeze
13
13
 
14
14
  runner_with :help do
15
15
  desc 'Procura e converte vídeos não suportados pelas TVs de EHB/RS.'
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Ehbrs
6
+ module Telegram
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/immutable'
5
+ require 'telegram/bot'
6
+
7
+ module Ehbrs
8
+ module Telegram
9
+ class MessageSending
10
+ include ::EacRubyUtils::Immutable
11
+ immutable_accessor :bot_token, :message
12
+ immutable_accessor :recipient_id, type: :array
13
+
14
+ def run
15
+ ::Telegram::Bot::Client.run(prop(:bot_token)) do |bot|
16
+ prop(:recipient_ids).each do |recipient_id|
17
+ bot.api.sendMessage(chat_id: recipient_id, text: prop(:message))
18
+ end
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def prop(attribute)
25
+ r = send(attribute)
26
+ return r if r.present?
27
+
28
+ raise "Attribute #{attribute} is blank"
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_base0/application'
4
+
5
+ module Ehbrs
6
+ module Tools
7
+ class << self
8
+ def application
9
+ @application ||= ::EacRubyBase0::Application.new(::File.expand_path('../../..', __dir__))
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Ehbrs
7
+ module Tools
8
+ INSTANCE_ID = 'ehbrs-tools_0'
9
+
10
+ class << self
11
+ def instance
12
+ @instance ||= ::Avm::Instances::Base.by_id(INSTANCE_ID)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ehbrs
4
4
  module Tools
5
- VERSION = '0.16.3'
5
+ VERSION = '0.19.0'
6
6
  end
7
7
  end
@@ -6,30 +6,12 @@ require 'ehbrs_ruby_utils/videos/stream'
6
6
  module Ehbrs
7
7
  module Videos
8
8
  class Track < ::SimpleDelegator
9
- TYPE_MAPPING = {
10
- audio: 'Audio',
11
- video: 'Video',
12
- subtitle: 'Subtitle'
13
- }.freeze
14
-
15
- def codec
16
- codec_name
17
- end
18
-
19
- def type
20
- TYPE_MAPPING.fetch(codec_type)
21
- end
22
-
23
- def number
24
- index
25
- end
26
-
27
9
  def extra
28
10
  ffprobe_data.fetch(:codec_tag_string).to_s
29
11
  end
30
12
 
31
13
  def to_s
32
- "[#{type}(#{number}): #{codec}/#{language || '-'}" +
14
+ "[#{codec_type}(#{index}): #{codec_name}/#{language || '-'}" +
33
15
  extra.if_present('') { |v| " | #{v}" } + ']'
34
16
  end
35
17
  end
@@ -26,7 +26,7 @@ module Ehbrs
26
26
 
27
27
  def ffmpeg_fix_args
28
28
  unpassed_checks.flat_map do |check|
29
- check.check.fix.ffmpeg_args(self)
29
+ check.check.fix.if_present([]) { |v| v.ffmpeg_args(self) }
30
30
  end
31
31
  end
32
32
 
@@ -10,7 +10,7 @@ module Ehbrs
10
10
  common_constructor :codec, :listed_extras
11
11
 
12
12
  def check(track)
13
- return nil unless track.codec == codec
13
+ return nil unless track.codec_name == codec
14
14
  return nil if listed_extras.any? do |extra|
15
15
  track.extra.downcase.include?(extra.downcase)
16
16
  end
@@ -12,7 +12,7 @@ module Ehbrs
12
12
  common_constructor :codec, :extra
13
13
 
14
14
  def check(track)
15
- return nil unless track.codec == codec
15
+ return nil unless track.codec_name == codec
16
16
  return nil unless track.extra.downcase.include?(extra.downcase)
17
17
 
18
18
  "Unsupported extra \"#{extra}\" for codec \"#{codec}\" and track #{track}"
@@ -10,9 +10,9 @@ module Ehbrs
10
10
  common_constructor :listed_codecs
11
11
 
12
12
  def check(track)
13
- return nil if listed_codecs.include?(track.codec)
13
+ return nil if listed_codecs.include?(track.codec_name)
14
14
 
15
- "Not listed codec \"#{track.codec}\" (Track: #{track}, listed: #{listed_codecs})"
15
+ "Not listed codec \"#{track.codec_name}\" (Track: #{track}, listed: #{listed_codecs})"
16
16
  end
17
17
 
18
18
  def fix
@@ -12,7 +12,7 @@ module Ehbrs
12
12
  common_constructor :codec
13
13
 
14
14
  def check(track)
15
- return nil unless track.codec == codec
15
+ return nil unless track.codec_name == codec
16
16
 
17
17
  "Unsupported codec \"#{codec}\" for track #{track}"
18
18
  end
@@ -35,19 +35,6 @@ module Ehbrs
35
35
  video.tracks.flat_map(&:ffmpeg_fix_args)
36
36
  end
37
37
 
38
- def track_fix_args(track)
39
- ["#{track_codec_option_by_type(track.type)}:#{track.number}",
40
- track.passed? ? 'copy' : track_codec_fix_by_type(track.type)]
41
- end
42
-
43
- def track_codec_option_by_type(track_type)
44
- TRACK_TYPE_OPTIONS.fetch(track_type)
45
- end
46
-
47
- def track_codec_fix_by_type(track_type)
48
- TRACK_TYPE_FIX_CODECS.fetch(track_type)
49
- end
50
-
51
38
  def container_fix_args
52
39
  ['-f', ::Ehbrs::Videos::Unsupported::Fixes::SupportedContainer::FIX_FORMAT]
53
40
  end
@@ -6,28 +6,28 @@ module Ehbrs
6
6
  module Fixes
7
7
  class SupportedCodec
8
8
  TRACK_TYPE_OPTIONS = {
9
- 'Audio' => '-acodec',
10
- 'Video' => '-vcodec',
11
- 'Subtitle' => '-scodec'
9
+ audio: '-acodec',
10
+ video: '-vcodec',
11
+ subtitle: '-scodec'
12
12
  }.freeze
13
13
 
14
14
  TRACK_TYPE_FIX_CODECS = {
15
- 'Audio' => 'libvorbis',
16
- 'Video' => 'libx264',
17
- 'Subtitle' => 'ass'
15
+ audio: 'aac',
16
+ video: 'libx264',
17
+ subtitle: 'ass'
18
18
  }.freeze
19
19
 
20
20
  def ffmpeg_args(track)
21
- ["#{track_codec_option_by_type(track.type)}:#{track.number}",
22
- track_codec_fix_by_type(track.type)]
21
+ ["#{track_codec_option_by_type(track.codec_type)}:#{track.index}",
22
+ track_codec_fix_by_type(track.codec_type)]
23
23
  end
24
24
 
25
25
  def track_codec_option_by_type(track_type)
26
- TRACK_TYPE_OPTIONS.fetch(track_type)
26
+ TRACK_TYPE_OPTIONS.fetch(track_type.to_s.underscore.to_sym)
27
27
  end
28
28
 
29
29
  def track_codec_fix_by_type(track_type)
30
- TRACK_TYPE_FIX_CODECS.fetch(track_type)
30
+ TRACK_TYPE_FIX_CODECS.fetch(track_type.to_s.underscore.to_sym)
31
31
  end
32
32
  end
33
33
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ehbrs/videos/unsupported/profiles/base'
4
+
5
+ module Ehbrs
6
+ module Videos
7
+ module Unsupported
8
+ module Profiles
9
+ class Aoc < ::Ehbrs::Videos::Unsupported::Profiles::Base
10
+ AUDIO_SUPPORTED_CODECS = %w[aac ac3 mp2 mp3].freeze
11
+ AUDIO_UNSUPPORTED_CODECS = %w[eac3 vorbis].freeze
12
+
13
+ VIDEO_SUPPORTED_CODECS = %w[h264 mpeg4].freeze
14
+ VIDEO_UNSUPPORTED_CODECS = %w[hevc].freeze
15
+
16
+ SUBTITLE_SUPPORTED_CODECS = %w[ass dvd_subtitle hdmv_pgs_subtitle subrip].freeze
17
+ SUBTITLE_UNSUPPORTED_CODECS = %w[mov_text].freeze
18
+
19
+ OTHER_SUPPORTED_CODECS = %w[].freeze
20
+
21
+ MPEG4_EXTRA_SUPPORTED = %w[xvid].freeze
22
+ MPEG4_EXTRA_UNSUPPORTED = %w[].freeze
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title><%= title %></title>
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css"
8
+ rel="stylesheet"
9
+ integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1"
10
+ crossorigin="anonymous">
11
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js"
12
+ integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW"
13
+ crossorigin="anonymous"
14
+ ></script>
15
+ </head>
16
+ <body>
17
+ <h1><%= title %></h1>
18
+ <%= inner_content %>
19
+ </body>
20
+ </html>
@@ -0,0 +1,6 @@
1
+ <h2>Receitas</h2>
2
+ <ul>
3
+ <% parent.recipes_pages.each do |rp| %>
4
+ <li><a href="<%= rp.href %>" ><%= rp.title %></a></li>
5
+ <% end %>
6
+ </ul>
@@ -0,0 +1,6 @@
1
+ <% if notes.present? %>
2
+ <p><%= notes %></p>
3
+ <% end %>
4
+ <% parts.each do |part| %>
5
+ <%= part.content %>
6
+ <% end %>
@@ -0,0 +1,27 @@
1
+ <h2><%= title %></h2>
2
+ <h3>Ingredientes</h3>
3
+ <% if notes.present? %>
4
+ <%= notes %>
5
+ <% end %>
6
+ <table class="table">
7
+ <thead>
8
+ <tr>
9
+ <th scope="col">Ingrediente</th>
10
+ <th scope="col">Medida</th>
11
+ </tr>
12
+ </thead>
13
+ <tbody>
14
+ <% ingredients.each do |ingredient| %>
15
+ <tr>
16
+ <th scope="row"><%= ingredient.name %></th>
17
+ <td><%= ingredient.measure %></td>
18
+ </tr>
19
+ <% end %>
20
+ </tbody>
21
+ </table>
22
+ <h3>Preparo</h3>
23
+ <ol>
24
+ <% steps.each do |step| %>
25
+ <li><%= step %></li>
26
+ <% end %>
27
+ </ol>
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacCli
6
+ module Docopt
7
+ class RunnerContextReplacement
8
+ common_constructor :runner
9
+
10
+ def argv
11
+ runner.settings[:argv] || ARGV
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_cli/docopt/doc_builder'
4
+ require 'eac_cli/docopt/runner_context_replacement'
4
5
  require 'eac_cli/runner'
5
6
  require 'eac_ruby_utils/console/docopt_runner'
6
7
 
@@ -32,6 +33,10 @@ module EacCli
32
33
  def docopt_options
33
34
  super.merge(options_first: self.class.runner_definition.options_first?)
34
35
  end
36
+
37
+ def runner_context
38
+ @runner_context ||= ::EacCli::Docopt::RunnerContextReplacement.new(self)
39
+ end
35
40
  end
36
41
 
37
42
  def extra_available_subcommands