lib/cms_scanner/finders/finder/enumerator.rb in cms_scanner-0.0.18 vs lib/cms_scanner/finders/finder/enumerator.rb in cms_scanner-0.0.19

- old
+ new

@@ -1,20 +1,20 @@ module CMSScanner module Finders class Finder # Module to provide an easy way to enumerate items such as plugins, themes etc module Enumerator + # @param [ Hash ] The target urls # @param [ Hash ] opts # @option opts [ Boolean ] :show_progression Wether or not to display the progress bar # @option opts [ Regexp ] :exclude_content # # @yield [ Typhoeus::Response, String ] - def enumerate(opts = {}) - targets = target_urls(opts) - bar = progress_bar(targets.size, progress_bar_title) if opts[:show_progression] + def enumerate(target_urls, opts = {}) + bar = progress_bar(total: target_urls.size) if opts[:show_progression] - targets.each do |url, id| + target_urls.each do |url, id| request = browser.forge_request(url, request_params) request.on_complete do |res| bar.progress += 1 if opts[:show_progression] @@ -28,39 +28,15 @@ end hydra.run end - # @param [ Hash ] opts - # # @return [ Hash ] - def target_urls(_opts = {}) - fail NotImplementedError - end - - # Progress Bar title to use, allow instance using this module - # to display a custom title if needed - # - # @return [ String ] - def progress_bar_title - ' ' # Used to create a left margin - end - - # @return [ CMSScanner::Browser ] - def browser - @browser ||= NS::Browser.instance - end - def request_params # disabling the cache, as it causes a 'stack level too deep' exception # with a large number of requests :/ # See https://github.com/typhoeus/typhoeus/issues/408 { cache_ttl: 0 } - end - - # @return [ Typhoeus::Hydra ] - def hydra - @hydra ||= browser.hydra end end end end end