Class: Nanoc::OrigCLI::Commands::ShowRules Private
- Inherits:
-
CLI::CommandRunner
- Object
- CLI::CommandRunner
- Nanoc::OrigCLI::Commands::ShowRules
- Defined in:
- lib/nanoc/orig_cli/commands/show-rules.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #explain_item(item, rules:, reps:) ⇒ Object private
- #explain_layout(layout, rules:) ⇒ Object private
- #fmt_heading(str) ⇒ Object private
- #run ⇒ Object private
Instance Method Details
#explain_item(item, rules:, reps:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/nanoc/orig_cli/commands/show-rules.rb', line 29 def explain_item(item, rules:, reps:) puts(fmt_heading("Item #{item.identifier}") + ':') reps[item].each do |rep| rule = rules.compilation_rule_for(rep) puts " Rep #{rep.name}: #{rule ? rule.pattern : '(none)'}" end puts end |
#explain_layout(layout, rules:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/nanoc/orig_cli/commands/show-rules.rb', line 40 def explain_layout(layout, rules:) puts(fmt_heading("Layout #{layout.identifier}") + ':') found = false rules.layout_filter_mapping.each_key do |pattern| if pattern.match?(layout.identifier) puts " #{pattern}" found = true break end end unless found puts ' (none)' end puts end |
#fmt_heading(str) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
58 59 60 |
# File 'lib/nanoc/orig_cli/commands/show-rules.rb', line 58 def fmt_heading(str) Nanoc::CLI::ANSIStringColorizer.c(str, :bold, :yellow) end |
#run ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/nanoc/orig_cli/commands/show-rules.rb', line 13 def run site = load_site res = Nanoc::Core::Compiler.new_for(site).run_until_reps_built reps = res.fetch(:reps) action_provider = Nanoc::Core::ActionProvider.named(site.config.action_provider).for(site) rules = action_provider.rules_collection items = site.items.sort_by(&:identifier) layouts = site.layouts.sort_by(&:identifier) items.each { |e| explain_item(e, rules:, reps:) } layouts.each { |e| explain_layout(e, rules:) } end |