Class: Puppet::ModuleTool::Applications::Searcher

Inherits:
Application show all
Includes:
Forge::Errors
Defined in:
lib/puppet/module_tool/applications/searcher.rb

Constant Summary

Constants inherited from Application

Application::DOCPATTERN

Constants included from Util

Util::AbsolutePathPosix, Util::AbsolutePathWindows, Util::DEFAULT_POSIX_MODE, Util::DEFAULT_WINDOWS_MODE, Util::RFC_3986_URI_REGEX

Constants included from Util::SymbolicFileMode

Util::SymbolicFileMode::SetGIDBit, Util::SymbolicFileMode::SetUIDBit, Util::SymbolicFileMode::StickyBit, Util::SymbolicFileMode::SymbolicMode, Util::SymbolicFileMode::SymbolicSpecialToBit

Constants included from Util::POSIX

Util::POSIX::LOCALE_ENV_VARS, Util::POSIX::USER_ENV_VARS

Instance Attribute Summary

Attributes inherited from Application

#command_line, #options

Instance Method Summary collapse

Methods inherited from Application

[], #app_defaults, available_application_names, banner, clear!, clear?, clear_everything_for_tests, #configure_indirector_routes, controlled_run, #deprecate, #deprecated?, environment_mode, exit, find, get_environment_mode, #handle_logdest_arg, #handlearg, #help, #initialize_app_defaults, interrupted?, #log_runtime_environment, #main, #name, option, option_parser_commands, #parse_options, #preinit, restart!, restart_requested?, #run_command, run_mode, #set_log_level, #setup, #setup_logs, stop!, stop_requested?, #summary, try_load_class

Methods included from Util

absolute_path?, benchmark, chuser, clear_environment, default_env, deterministic_rand, deterministic_rand_int, exit_on_fail, get_env, get_environment, logmethods, merge_environment, path_to_uri, pretty_backtrace, replace_file, safe_posix_fork, set_env, symbolizehash, thinmark, uri_encode, uri_query_encode, uri_to_path, which, withenv, withumask

Methods included from Util::SymbolicFileMode

#normalize_symbolic_mode, #symbolic_mode_to_int, #valid_symbolic_mode?

Methods included from Util::POSIX

#get_posix_field, #gid, groups_of, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid

Constructor Details

#initialize(term, forge, options = {}) ⇒ Searcher


6
7
8
9
10
# File 'lib/puppet/module_tool/applications/searcher.rb', line 6

def initialize(term, forge, options = {})
  @term = term
  @forge = forge
  super(options)
end

Instance Method Details

#runObject


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/puppet/module_tool/applications/searcher.rb', line 12

def run
  results = {}
  begin
    Puppet.notice _("Searching %{host} ...") % { host: @forge.host }
    results[:answers] = @forge.search(@term)
    results[:result] = :success
  rescue ForgeError => e
    results[:result] = :failure
    results[:error] = {
      :oneline   => e.message,
      :multiline => e.multiline,
    }
  end
  results
end