Module: QueryPackwerk::ConsoleHelpers
- Extended by:
- T::Sig
- Defined in:
- lib/query_packwerk/console_helpers.rb
Overview
typed: true
Instance Method Summary collapse
- #help(type = nil) ⇒ Object
- #help_help ⇒ Object
- #help_package ⇒ Object
- #help_packages ⇒ Object
- #help_query_packwerk ⇒ Object
- #help_violation ⇒ Object
- #help_violations ⇒ Object
- #inspect ⇒ Object
- #welcome ⇒ Object
Instance Method Details
#help(type = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/query_packwerk/console_helpers.rb', line 19 def help(type = nil) case type.to_s.downcase when 'violation' help_violation when 'violations' help_violations when 'package' help_package when 'packages' help_packages when '', 'help' help_help else puts "Unknown help topic: #{type}\n" help_help end end |
#help_help ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/query_packwerk/console_helpers.rb', line 38 def help_help puts <<~HELP Available help topics: help # This help help_violation # Help for QueryPackwerk::Violation help_violations # Help for QueryPackwerk::Violations help_package # Help for QueryPackwerk::Package help_packages # Help for QueryPackwerk::Packages HELP end |
#help_package ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/query_packwerk/console_helpers.rb', line 89 def help_package puts <<~HELP QueryPackwerk::Package (lib/query_packwerk/package.rb) ---------------------------------------------- .name # Returns the package name .enforce_dependencies # Returns whether package enforces dependencies .enforce_privacy # Returns whether package enforces privacy .metadata # Returns the package metadata from package.yml .config # Returns the package configuration .dependencies # Returns Packages collection of dependencies .dependency_names # Returns array of dependency package names .owner # Returns the package owner or 'Unowned' .directory # Returns the package directory path .todos # Returns Violations where this package is the consumer .violations # Returns Violations where this package is the producer .consumers # Returns Packages that consume this package .consumer_names # Returns array of names of consuming packages .consumer_counts # Returns hash of consumer package names and counts HELP end |
#help_packages ⇒ Object
111 112 113 114 115 116 117 118 119 |
# File 'lib/query_packwerk/console_helpers.rb', line 111 def help_packages puts <<~HELP QueryPackwerk::Packages (lib/query_packwerk/packages.rb) ------------------------------------------------ .all # Returns all packages in the application .where(conditions) # Returns new Packages filtered by conditions .violations # Returns Violations for all packages in collection HELP end |
#help_query_packwerk ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/query_packwerk/console_helpers.rb', line 122 def help_query_packwerk puts <<~HELP QueryPackwerk (lib/query_packwerk.rb) ------------------------------ Available commands: package(pack_name) # Get a package by name Packages.all # Get all packages Package Consumption (how others use this package): violations_for(pack_name) # Get all violations where others access this package violation_sources_for(pack_name) # Get where others access this package violation_counts_for(pack_name) # Get how often others access this package anonymous_violation_sources_for(pack_name) # Get the 'shape' of how others access this package anonymous_violation_counts_for(pack_name) # Get how often each access pattern occurs consumers(pack_name) # Get which packages consume this package Package Dependencies (how this package uses others): todos_for(pack_name) # Get all todos where this package accesses others Violations.all # Get all violations HELP end |
#help_violation ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/query_packwerk/console_helpers.rb', line 50 def help_violation puts <<~HELP QueryPackwerk::Violation (lib/query_packwerk/violation.rb) ------------------------------------------------ .type # Returns the violation type ('privacy' or 'dependency') .class_name # Returns the violated constant name .files # Returns array of files containing the violation .producing_pack # Returns the Package that owns the violated constant .consuming_pack # Returns the Package that violated the constant .sources # Returns array of AST nodes representing the violation occurrences .sources_with_locations # Returns array of [file:line, source] pairs for each violation .source_counts # Returns hash of how often each violation source occurs .anonymous_sources # Returns array of violation sources with arguments anonymized .anonymous_sources_with_locations # Returns array of [file:line, source] pairs for each violation with arguments anonymized .count # Returns total number of violation occurrences HELP end |
#help_violations ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/query_packwerk/console_helpers.rb', line 69 def help_violations puts <<~HELP QueryPackwerk::Violations (lib/query_packwerk/violations.rb) -------------------------------------------------- .where(conditions) # Returns new Violations filtered by conditions .raw_sources # Returns hash of constant => AST nodes for all violations .sources # Returns hash of constant => source strings for all violations .sources_with_locations # Returns hash of constant => [file:line, source] pairs .source_counts # Returns hash of constant => {source => count} with occurrence counts .sources_with_contexts # Returns hash of constant => [file:line, source] pairs for each violation with context .anonymous_sources # Returns hash of constant => anonymized sources .anonymous_sources_with_locations # Returns array of [file:line, source] pairs for each violation with arguments anonymized .consumers(threshold) # Returns hash of consuming package names and violation counts .producers(threshold) # Returns hash of producing package names and violation counts .including_files(globs) # Returns new Violations filtered to include specific files .excluding_files(globs) # Returns new Violations filtered to exclude specific files HELP end |
#inspect ⇒ Object
7 8 9 |
# File 'lib/query_packwerk/console_helpers.rb', line 7 def inspect 'query_packwerk console' end |
#welcome ⇒ Object
12 13 14 15 16 |
# File 'lib/query_packwerk/console_helpers.rb', line 12 def welcome help_query_packwerk puts help_help end |