Module: Botz
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/botz.rb,
lib/botz/version.rb
Overview
web bot dsl engine
Defined Under Namespace
Classes: Command, Definition, Downloader, HtmlScraperMacro, Shell, Spider
Constant Summary collapse
- VERSION =
'0.2.0'
Class Method Summary collapse
Class Method Details
.define(name, domain:, &block) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/botz.rb', line 31 def self.define(name, domain:, &block) crawler_definition = Class.new(Botz::Definition, &block) crawler_definition.domain = domain Crawler.const_set(name.to_s.camelize, crawler_definition) crawler_definition end |
.open(filepath) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/botz.rb', line 20 def self.open(filepath) remove_const(:Crawler) if const_defined?(:Crawler) const_set(:Crawler, Module.new) # rubocop:disable Security/Eval definition = eval(File.open(filepath).read) # rubocop:enable Security/Eval Botz::Command.new(filepath: filepath, definition: definition) end |