module Whowas
Constants
- VERSION
Public Class Methods
name_this_recipe()
click to toggle source
# File lib/generators/whowas/templates/recipe.rb, line 4 def self.name_this_recipe # All you have to do is specify the search method classes in the order # they should be called. The output for each search method should match # the input of the next. ::Middleware::Builder.new do # use MySearchMethod1 # use MySearchMethod2 # use MySearchMethod3 end end
search(input)
click to toggle source
# File lib/whowas.rb, line 45 def self.search(input) validate_configuration recipe = recipe_class.select(input) || Whowas.recipe_table[:default] env = {input: input, results: []} self.send(recipe).call(env) env end
validate_configuration()
click to toggle source
Ensure that the user has configured the recipe table and initialized the whowas directory in the overarching app. Does not prove the app is properly configured – this is the bare minimum, meant to be an alert for users who don't realize they have to configure anything at all.
# File lib/whowas.rb, line 65 def self.validate_configuration if recipe_table == {} || !recipe_table.include?(:default) raise Whowas::Errors::ConfigurationError, "Please configure Whowas as described at https://github.com/TuftsUniversity/whowas" end end
Public Instance Methods
select_recipe(input)
click to toggle source
Uses the recipe_table hash to match up the input to the correct recipe type. If there is an IP address in the input, it tries to match the IP address against any keys that are valid CIDR blocks. If there is a mac address, it looks for the key :mac. Otherwise, it falls back to :default.
# File lib/whowas.rb, line 58 def select_recipe(input) end