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.
- checksums.yaml +4 -4
- data/lib/ehbrs/cooking_book.rb +9 -0
- data/lib/ehbrs/cooking_book/build.rb +45 -0
- data/lib/ehbrs/cooking_book/build/base_page.rb +43 -0
- data/lib/ehbrs/cooking_book/build/index_page.rb +26 -0
- data/lib/ehbrs/cooking_book/build/recipe_page.rb +27 -0
- data/lib/ehbrs/cooking_book/project.rb +25 -0
- data/lib/ehbrs/cooking_book/recipe.rb +37 -0
- data/lib/ehbrs/cooking_book/recipe/ingredient.rb +21 -0
- data/lib/ehbrs/cooking_book/recipe/measure.rb +60 -0
- data/lib/ehbrs/cooking_book/recipe/part.rb +32 -0
- data/lib/ehbrs/patches/module/erb_template.rb +11 -0
- data/lib/ehbrs/patches/object/erb_template.rb +9 -0
- data/lib/ehbrs/patches/object/template.rb +7 -0
- data/lib/ehbrs/runner.rb +6 -13
- data/lib/ehbrs/runner/cooking_book.rb +30 -0
- data/lib/ehbrs/runner/cooking_book/build.rb +32 -0
- data/lib/ehbrs/runner/telegram.rb +26 -0
- data/lib/ehbrs/runner/telegram/send_message.rb +29 -0
- data/lib/ehbrs/runner/videos/unsupported.rb +1 -1
- data/lib/ehbrs/telegram.rb +9 -0
- data/lib/ehbrs/telegram/message_sending.rb +32 -0
- data/lib/ehbrs/tools/application.rb +13 -0
- data/lib/ehbrs/tools/instance.rb +16 -0
- data/lib/ehbrs/tools/version.rb +1 -1
- data/lib/ehbrs/videos/track.rb +1 -19
- data/lib/ehbrs/videos/unsupported/check_support.rb +1 -1
- data/lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb +1 -1
- data/lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb +1 -1
- data/lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb +2 -2
- data/lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb +1 -1
- data/lib/ehbrs/videos/unsupported/fix_profile.rb +0 -13
- data/lib/ehbrs/videos/unsupported/fixes/supported_codec.rb +10 -10
- data/lib/ehbrs/videos/unsupported/profiles/aoc.rb +27 -0
- data/template/ehbrs/cooking_book/build/base_page/layout.html.erb +20 -0
- data/template/ehbrs/cooking_book/build/index_page/inner.html.erb +6 -0
- data/template/ehbrs/cooking_book/build/recipe_page/inner.html.erb +6 -0
- data/template/ehbrs/cooking_book/build/recipe_page/part.html.erb +27 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_context_replacement.rb +15 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +5 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +4 -4
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/long_options.rb +37 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/option_argument.rb +29 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +7 -36
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +45 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +3 -1
- data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +19 -2
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +22 -1
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +29 -0
- data/vendor/eac_ruby_base0/Gemfile +5 -0
- data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +20 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0.rb +7 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +69 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +54 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner/test_all.rb +22 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +5 -0
- data/vendor/eac_ruby_base0/spec/rubocop_spec.rb +7 -0
- data/vendor/eac_ruby_base0/spec/spec_helper.rb +100 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +16 -6
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +2 -99
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb +29 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb +53 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb +54 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +10 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traverser.rb +0 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +4 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +38 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +8 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/template.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/template.rb +1 -8
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_sub.rb +2 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb +3 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +8 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +14 -4
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +30 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +2 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/local_time_zone_spec.rb +17 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +1 -1
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb +1 -1
- metadata +89 -9
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/local_time_zone.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e80d8d25f5c713908af2432c8f80f63c4f4de6f292c4bc915bf33951e998a1cd
|
4
|
+
data.tar.gz: ac9156efaa3625fcc64f0268231cc07756ce5ba37309ec44029559389a06bbd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de0930f5a26438deef43bbfb5a2245d30ed1d929ed28763fd8f7801f58f9ed813016d22c5c9bba61da8b3f1fcb801b0923381488b92b1279f536b0d8301eddba
|
7
|
+
data.tar.gz: 1f36ef925ce34f15f228d69f73ec277b6a56fb0545f19a43dc986516a1ac4c81db389645f6fd7d0cf720d56b1ca1d0150d189a8aec43b853a24e94f8bd622fc3
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/fs/clearable_directory'
|
5
|
+
|
6
|
+
module Ehbrs
|
7
|
+
module CookingBook
|
8
|
+
class Build
|
9
|
+
require_sub __FILE__
|
10
|
+
enable_simple_cache
|
11
|
+
enable_listable
|
12
|
+
lists.add_symbol :option, :target_dir
|
13
|
+
|
14
|
+
common_constructor :project, :options, default: [{}] do
|
15
|
+
self.options = self.class.lists.option.hash_keys_validate!(options.symbolize_keys)
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
target_dir.clear
|
20
|
+
index_page.build
|
21
|
+
recipes_pages.each(&:build)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def index_page_uncached
|
27
|
+
::Ehbrs::CookingBook::Build::IndexPage.new(self)
|
28
|
+
end
|
29
|
+
|
30
|
+
def recipes_pages_uncached
|
31
|
+
project.recipes.map do |recipe|
|
32
|
+
::Ehbrs::CookingBook::Build::RecipePage.new(self, recipe)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def target_dir_uncached
|
37
|
+
::EacRubyUtils::Fs::ClearableDirectory.new(options[OPTION_TARGET_DIR] || default_target_dir)
|
38
|
+
end
|
39
|
+
|
40
|
+
def default_target_dir
|
41
|
+
project.root.join('dist')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs/patches/object/erb_template'
|
5
|
+
|
6
|
+
module Ehbrs
|
7
|
+
module CookingBook
|
8
|
+
class Build
|
9
|
+
class BasePage < SimpleDelegator
|
10
|
+
attr_reader :parent
|
11
|
+
|
12
|
+
def initialize(parent, source_object)
|
13
|
+
super(source_object)
|
14
|
+
@parent = parent
|
15
|
+
end
|
16
|
+
|
17
|
+
def build
|
18
|
+
target_path.write(target_content)
|
19
|
+
end
|
20
|
+
|
21
|
+
def href
|
22
|
+
"#{target_basename}.html"
|
23
|
+
end
|
24
|
+
|
25
|
+
def target_path
|
26
|
+
parent.target_dir.join(href)
|
27
|
+
end
|
28
|
+
|
29
|
+
def target_content
|
30
|
+
erb_result('layout', ::Ehbrs::CookingBook::Build::BasePage)
|
31
|
+
end
|
32
|
+
|
33
|
+
def inner_content
|
34
|
+
erb_result('inner', self.class)
|
35
|
+
end
|
36
|
+
|
37
|
+
def erb_result(template_basename, template_source = self)
|
38
|
+
template_source.erb_template("#{template_basename}.html.erb", self)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs/cooking_book/build/base_page'
|
5
|
+
|
6
|
+
module Ehbrs
|
7
|
+
module CookingBook
|
8
|
+
class Build
|
9
|
+
class IndexPage < ::Ehbrs::CookingBook::Build::BasePage
|
10
|
+
TITLE = 'Início'
|
11
|
+
|
12
|
+
def initialize(parent)
|
13
|
+
super(parent, nil)
|
14
|
+
end
|
15
|
+
|
16
|
+
def target_basename
|
17
|
+
'index'
|
18
|
+
end
|
19
|
+
|
20
|
+
def title
|
21
|
+
TITLE
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs/cooking_book/build/base_page'
|
5
|
+
require 'ehbrs/patches/object/erb_template'
|
6
|
+
|
7
|
+
module Ehbrs
|
8
|
+
module CookingBook
|
9
|
+
class Build
|
10
|
+
class RecipePage < ::Ehbrs::CookingBook::Build::BasePage
|
11
|
+
def target_basename
|
12
|
+
title.variableize
|
13
|
+
end
|
14
|
+
|
15
|
+
def parts
|
16
|
+
@parts ||= super.map { |e| Part.new(e) }
|
17
|
+
end
|
18
|
+
|
19
|
+
class Part < SimpleDelegator
|
20
|
+
def content
|
21
|
+
::Ehbrs::CookingBook::Build::RecipePage.erb_template('part.html.erb', self)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs/cooking_book/recipe'
|
5
|
+
|
6
|
+
module Ehbrs
|
7
|
+
module CookingBook
|
8
|
+
class Project
|
9
|
+
enable_simple_cache
|
10
|
+
common_constructor :root do
|
11
|
+
self.root = root.to_pathname
|
12
|
+
end
|
13
|
+
|
14
|
+
delegate :to_s, to: :root
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def recipes_uncached
|
19
|
+
::Dir.glob(File.join('**', '*.{yml,yaml}'), base: root.to_path).map do |subpath|
|
20
|
+
::Ehbrs::CookingBook::Recipe.from_file(root.join(subpath))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/yaml'
|
5
|
+
|
6
|
+
module Ehbrs
|
7
|
+
module CookingBook
|
8
|
+
class Recipe
|
9
|
+
enable_simple_cache
|
10
|
+
require_sub __FILE__
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def from_file(path)
|
14
|
+
new(::EacRubyUtils::Yaml.load_file(path))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
common_constructor :source_data do
|
19
|
+
self.source_data = source_data.deep_symbolize_keys
|
20
|
+
end
|
21
|
+
|
22
|
+
def title
|
23
|
+
source_data.fetch(:title)
|
24
|
+
end
|
25
|
+
|
26
|
+
def notes
|
27
|
+
source_data[:notes]
|
28
|
+
end
|
29
|
+
|
30
|
+
def parts
|
31
|
+
@parts ||= source_data.fetch(:parts).map do |k, v|
|
32
|
+
::Ehbrs::CookingBook::Recipe::Part.new(k, v)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs/cooking_book/recipe/measure'
|
5
|
+
|
6
|
+
module Ehbrs
|
7
|
+
module CookingBook
|
8
|
+
class Recipe
|
9
|
+
class Ingredient
|
10
|
+
class << self
|
11
|
+
def build(label, value)
|
12
|
+
new(label, ::Ehbrs::CookingBook::Recipe::Measure.build(value))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
enable_simple_cache
|
17
|
+
common_constructor :name, :measure
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/yaml'
|
5
|
+
require 'ehbrs/cooking_book/recipe/ingredient'
|
6
|
+
|
7
|
+
module Ehbrs
|
8
|
+
module CookingBook
|
9
|
+
class Recipe
|
10
|
+
class Measure
|
11
|
+
FLOAT_PATTERN = /\d+(?:\.\d+)?/.freeze
|
12
|
+
FRACTION_PATTERN = %r{(#{FLOAT_PATTERN})(?:\s*/\s*(#{FLOAT_PATTERN}))?}.freeze
|
13
|
+
QUANTITY_UNIT_PATTERN = /\A#{FRACTION_PATTERN}(?:\s*(\S+))?\z/.freeze
|
14
|
+
VARIABLE_PATTERN = /\A\~\z/.freeze
|
15
|
+
VARIABLE_TEXT = 'a gosto'
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def build(value)
|
19
|
+
value = value.to_s.strip
|
20
|
+
build_from_variable(value) || build_from_pattern(value) || build_unknown(value)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def build_from_variable(value)
|
26
|
+
VARIABLE_PATTERN.if_match(value, false) do
|
27
|
+
new(nil, nil, nil)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def build_from_pattern(value)
|
32
|
+
QUANTITY_UNIT_PATTERN.if_match(value, false) do |m|
|
33
|
+
new(m[1].if_present(&:to_f), m[2].if_present(&:to_f), m[3])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_unknown(value)
|
38
|
+
new(nil, nil, "unknown format: |#{value}|")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
common_constructor :numerator, :denominator, :unit
|
43
|
+
|
44
|
+
def to_s
|
45
|
+
return VARIABLE_TEXT if variable?
|
46
|
+
|
47
|
+
"#{quantity_to_s} #{unit}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def quantity_to_s
|
51
|
+
numerator.to_s + (denominator.if_present('') { |v| "/ #{v}" })
|
52
|
+
end
|
53
|
+
|
54
|
+
def variable?
|
55
|
+
numerator.blank?
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/yaml'
|
5
|
+
require 'ehbrs/cooking_book/recipe/ingredient'
|
6
|
+
|
7
|
+
module Ehbrs
|
8
|
+
module CookingBook
|
9
|
+
class Recipe
|
10
|
+
class Part
|
11
|
+
enable_simple_cache
|
12
|
+
common_constructor :title, :source_data
|
13
|
+
|
14
|
+
def notes
|
15
|
+
source_data[:notes]
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def ingredients_uncached
|
21
|
+
source_data.fetch(:ingredients).map do |label, value|
|
22
|
+
::Ehbrs::CookingBook::Recipe::Ingredient.build(label, value)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def steps_uncached
|
27
|
+
source_data.fetch(:steps)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/ehbrs/runner.rb
CHANGED
@@ -1,26 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'ehbrs/tools/
|
3
|
+
require 'eac_ruby_base0/runner'
|
4
|
+
require 'ehbrs/tools/application'
|
5
5
|
|
6
6
|
module Ehbrs
|
7
7
|
class Runner
|
8
8
|
require_sub __FILE__
|
9
|
+
include ::EacRubyBase0::Runner
|
9
10
|
|
10
|
-
|
11
|
+
runner_definition do
|
11
12
|
desc 'Tools for EHB/RS.'
|
12
|
-
subcommands
|
13
|
-
alt do
|
14
|
-
bool_opt '-V', '--version', 'Show version.'
|
15
|
-
end
|
16
13
|
end
|
17
14
|
|
18
|
-
def
|
19
|
-
|
20
|
-
out(::Ehbrs::Tools::VERSION + "\n")
|
21
|
-
else
|
22
|
-
run_with_subcommand
|
23
|
-
end
|
15
|
+
def application
|
16
|
+
::Ehbrs::Tools.application
|
24
17
|
end
|
25
18
|
end
|
26
19
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
require 'ehbrs/cooking_book/project'
|
5
|
+
|
6
|
+
module Ehbrs
|
7
|
+
class Runner
|
8
|
+
class CookingBook
|
9
|
+
require_sub __FILE__
|
10
|
+
|
11
|
+
DEFAULT_SOURCE_DIR = '.'
|
12
|
+
|
13
|
+
runner_with :help, :subcommands do
|
14
|
+
desc 'Operações para livros de receitas.'
|
15
|
+
arg_opt '-C', '--source-dir', 'Caminho para o diretório do código-fonte.'
|
16
|
+
subcommands
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def source_dir_uncached
|
22
|
+
(parsed.source_dir || DEFAULT_SOURCE_DIR).to_pathname.expand_path
|
23
|
+
end
|
24
|
+
|
25
|
+
def project_uncached
|
26
|
+
::Ehbrs::CookingBook::Project.new(source_dir)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|