ehbrs-tools 0.16.5 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) 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/tools/application.rb +13 -0
  19. data/lib/ehbrs/tools/version.rb +1 -1
  20. data/template/ehbrs/cooking_book/build/base_page/layout.html.erb +20 -0
  21. data/template/ehbrs/cooking_book/build/index_page/inner.html.erb +6 -0
  22. data/template/ehbrs/cooking_book/build/recipe_page/inner.html.erb +6 -0
  23. data/template/ehbrs/cooking_book/build/recipe_page/part.html.erb +27 -0
  24. data/vendor/eac_ruby_base0/Gemfile +5 -0
  25. data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +20 -0
  26. data/vendor/eac_ruby_base0/lib/eac_ruby_base0.rb +7 -0
  27. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +69 -0
  28. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +54 -0
  29. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner/test_all.rb +27 -0
  30. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +5 -0
  31. data/vendor/eac_ruby_base0/spec/rubocop_spec.rb +7 -0
  32. data/vendor/eac_ruby_base0/spec/spec_helper.rb +100 -0
  33. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +16 -6
  34. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +2 -99
  35. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb +29 -0
  36. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb +53 -0
  37. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb +54 -0
  38. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +10 -1
  39. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/template.rb +10 -0
  40. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/template.rb +1 -8
  41. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  42. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +8 -0
  43. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +14 -4
  44. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +30 -0
  45. metadata +35 -2
@@ -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,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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ehbrs
4
4
  module Tools
5
- VERSION = '0.16.5'
5
+ VERSION = '0.17.0'
6
6
  end
7
7
  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,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+
5
+ require 'eac_ruby_base0/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = 'eac_ruby_base0'
9
+ s.version = EacRubyBase0::VERSION
10
+ s.authors = ['Put here the authors']
11
+ s.summary = 'Put here de description.'
12
+
13
+ s.files = Dir['{lib}/**/*']
14
+
15
+ s.add_dependency 'eac_cli', '~> 0.7'
16
+ s.add_dependency 'eac_ruby_gems_utils', '~> 0.7', '>= 0.7.2'
17
+ s.add_dependency 'eac_ruby_utils', '~> 0.46'
18
+
19
+ s.add_development_dependency 'eac_ruby_gem_support', '~> 0.1', '>= 0.1.2'
20
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRubyBase0
6
+ require_sub __FILE__
7
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_gems_utils/gem'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/filesystem_cache'
6
+
7
+ module EacRubyBase0
8
+ class Application
9
+ enable_simple_cache
10
+ enable_listable
11
+ lists.add_symbol :option, :name, :home_dir
12
+
13
+ common_constructor :gemspec_dir, :options, default: [{}] do
14
+ self.gemspec_dir = gemspec_dir.to_pathname
15
+ self.options = options.symbolize_keys.assert_valid_keys(self.class.lists.option.values).freeze
16
+ end
17
+
18
+ delegate :version, to: :self_gem
19
+
20
+ def all_gems
21
+ vendor_gems + [self_gem]
22
+ end
23
+
24
+ { cache: '.cache', config: '.config', data: '.local/share' }.each do |item, subpath|
25
+ xdg_env_method_name = "#{item}_xdg_env"
26
+
27
+ define_method xdg_env_method_name do
28
+ ENV["XDG_#{item.upcase}_HOME"].if_present(&:to_pathname)
29
+ end
30
+
31
+ define_method "#{item}_dir" do
32
+ (send(xdg_env_method_name) || home_dir.join(subpath)).join(name)
33
+ end
34
+ end
35
+
36
+ def fs_cache
37
+ @fs_cache ||= ::EacRubyUtils::FilesystemCache.new(
38
+ cache_dir.join(::EacRubyUtils::FilesystemCache.name.parameterize)
39
+ )
40
+ end
41
+
42
+ def home_dir
43
+ @home_dir ||= (options[OPTION_HOME_DIR] || ENV.fetch('HOME')).to_pathname
44
+ end
45
+
46
+ def name
47
+ options[OPTION_NAME] || self_gem.name
48
+ end
49
+
50
+ def vendor_dir
51
+ gemspec_dir.join('vendor')
52
+ end
53
+
54
+ private
55
+
56
+ def self_gem_uncached
57
+ ::EacRubyGemsUtils::Gem.new(gemspec_dir)
58
+ end
59
+
60
+ def vendor_gems_uncached
61
+ r = []
62
+ vendor_dir.children.each do |c|
63
+ vgem = ::EacRubyGemsUtils::Gem.new(c)
64
+ r << vgem if vgem.gemfile_path.exist?
65
+ end
66
+ r
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner_with/help'
4
+ require 'eac_cli/runner_with/subcommands'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module EacRubyBase0
8
+ module Runner
9
+ require_sub __FILE__
10
+ enable_console_speaker
11
+ common_concern do
12
+ include ::EacCli::RunnerWith::Help
13
+ include ::EacCli::RunnerWith::Subcommands
14
+ runner_definition do
15
+ bool_opt '-q', '--quiet', 'Quiet mode.'
16
+ bool_opt '-I', '--no-input', 'Fail if a input is requested.'
17
+ subcommands
18
+ alt do
19
+ bool_opt '-V', '--version', 'Show version.', usage: true, required: true
20
+ end
21
+ end
22
+ end
23
+
24
+ def run
25
+ on_speaker_node do |node|
26
+ node.stderr = ::StringIO.new if parsed.quiet?
27
+ node.stdin = FailIfRequestInput.new if parsed.no_input?
28
+ if parsed.version?
29
+ show_version
30
+ else
31
+ run_with_subcommand
32
+ end
33
+ end
34
+ end
35
+
36
+ def application_version
37
+ runner_context.call(:application).version.to_s
38
+ end
39
+
40
+ def show_version
41
+ out("#{application_version}\n")
42
+ end
43
+
44
+ class FailIfRequestInput
45
+ enable_console_speaker
46
+
47
+ %w[gets noecho].each do |method|
48
+ define_method(method) do
49
+ raise "Input method requested (\"#{method}\") and option --no-input is set"
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/default_runner'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+ require 'eac_ruby_utils/core_ext'
6
+ require 'eac_ruby_gems_utils/tests/multiple'
7
+
8
+ module EacRubyBase0
9
+ module Runner
10
+ class TestAll < ::EacRubyUtils::Console::DocoptRunner
11
+ require_sub __FILE__
12
+ include ::EacCli::DefaultRunner
13
+
14
+ runner_definition do
15
+ desc 'Test core and local gems.'
16
+ end
17
+
18
+ def run
19
+ fatal_error 'Some test did not pass' unless tests.ok?
20
+ end
21
+
22
+ def tests_uncached
23
+ ::EacRubyGemsUtils::Tests::Multiple.new(context(:application).all_gems)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyBase0
4
+ VERSION = '0.3.2'
5
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_gem_support/spec/examples/rubocop_check'
4
+
5
+ RSpec.describe ::RuboCop, slow: true do
6
+ include_examples 'rubocop_check', ::File.expand_path('..', __dir__)
7
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
6
+ # this file to always be loaded, without a need to explicitly require it in any
7
+ # files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+ #
17
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
+ RSpec.configure do |config|
19
+ # rspec-expectations config goes here. You can use an alternate
20
+ # assertion/expectation library such as wrong or the stdlib/minitest
21
+ # assertions if you prefer.
22
+ config.expect_with :rspec do |expectations|
23
+ # This option will default to `true` in RSpec 4. It makes the `description`
24
+ # and `failure_message` of custom matchers include text for helper methods
25
+ # defined using `chain`, e.g.:
26
+ # be_bigger_than(2).and_smaller_than(4).description
27
+ # # => "be bigger than 2 and smaller than 4"
28
+ # ...rather than:
29
+ # # => "be bigger than 2"
30
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31
+ end
32
+
33
+ # rspec-mocks config goes here. You can use an alternate test double
34
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
35
+ config.mock_with :rspec do |mocks|
36
+ # Prevents you from mocking or stubbing a method that does not exist on
37
+ # a real object. This is generally recommended, and will default to
38
+ # `true` in RSpec 4.
39
+ mocks.verify_partial_doubles = true
40
+ end
41
+
42
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
43
+ # have no way to turn it off -- the option exists only for backwards
44
+ # compatibility in RSpec 3). It causes shared context metadata to be
45
+ # inherited by the metadata hash of host groups and examples, rather than
46
+ # triggering implicit auto-inclusion in groups with matching metadata.
47
+ config.shared_context_metadata_behavior = :apply_to_host_groups
48
+
49
+ # The settings below are suggested to provide a good initial experience
50
+ # with RSpec, but feel free to customize to your heart's content.
51
+ # # This allows you to limit a spec run to individual examples or groups
52
+ # # you care about by tagging them with `:focus` metadata. When nothing
53
+ # # is tagged with `:focus`, all examples get run. RSpec also provides
54
+ # # aliases for `it`, `describe`, and `context` that include `:focus`
55
+ # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
56
+ # config.filter_run_when_matching :focus
57
+ #
58
+ # # Allows RSpec to persist some state between runs in order to support
59
+ # # the `--only-failures` and `--next-failure` CLI options. We recommend
60
+ # # you configure your source control system to ignore this file.
61
+ # config.example_status_persistence_file_path = "spec/examples.txt"
62
+ #
63
+ # # Limits the available syntax to the non-monkey patched syntax that is
64
+ # # recommended. For more details, see:
65
+ # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
66
+ # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
67
+ # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
68
+ # config.disable_monkey_patching!
69
+ #
70
+ # # This setting enables warnings. It's recommended, but in some cases may
71
+ # # be too noisy due to issues in dependencies.
72
+ # config.warnings = true
73
+ #
74
+ # # Many RSpec users commonly either run the entire suite or an individual
75
+ # # file, and it's useful to allow more verbose output when running an
76
+ # # individual spec file.
77
+ # if config.files_to_run.one?
78
+ # # Use the documentation formatter for detailed output,
79
+ # # unless a formatter has already been configured
80
+ # # (e.g. via a command-line flag).
81
+ # config.default_formatter = "doc"
82
+ # end
83
+ #
84
+ # # Print the 10 slowest examples and example groups at the
85
+ # # end of the spec run, to help surface which specs are running
86
+ # # particularly slow.
87
+ # config.profile_examples = 10
88
+ #
89
+ # # Run specs in random order to surface order dependencies. If you find an
90
+ # # order dependency and want to debug it, you can fix the order by providing
91
+ # # the seed, which is printed after each run.
92
+ # # --seed 1234
93
+ # config.order = :random
94
+ #
95
+ # # Seed global randomization in this process using the `--seed` CLI option.
96
+ # # Setting this allows you to use `--seed` to deterministically reproduce
97
+ # # test failures related to randomization by passing the same `--seed` value
98
+ # # as the one that triggered the failure.
99
+ # Kernel.srand config.seed
100
+ end
@@ -17,15 +17,25 @@ module EacRubyUtils
17
17
  end
18
18
 
19
19
  def run
20
- setup = self
21
20
  a_module.extend(::ActiveSupport::Concern)
22
- a_module.included do
23
- ::EacRubyUtils::CommonConcern::ClassSetup.new(setup, self, :include).run
24
- end
25
- a_module.prepended do
26
- ::EacRubyUtils::CommonConcern::ClassSetup.new(setup, self, :prepend).run
21
+ include_or_prepend(:included, :include)
22
+ include_or_prepend(:prepended, :prepend)
23
+ end
24
+
25
+ private
26
+
27
+ def include_or_prepend(module_method, class_setup_method)
28
+ setup = self
29
+ a_module.send(module_method, *a_module_method_args(module_method)) do
30
+ ::EacRubyUtils::CommonConcern::ClassSetup.new(setup, self, class_setup_method).run
27
31
  end
28
32
  end
33
+
34
+ def a_module_method_args(module_method)
35
+ method_arity = a_module.method(module_method).arity
36
+ method_arity = -method_arity - 1 if method_arity.negative?
37
+ method_arity.times.map { |_n| a_module }
38
+ end
29
39
  end
30
40
  end
31
41
  end