42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/puppeteer/query_handler_manager.rb', line 42
def detect_query_handler(selector)
unless /^[a-zA-Z]+\// =~ selector
return Result.new(
query_handler: default_handler,
selector: selector,
)
end
chunk = selector.split("/")
name = chunk.shift
updated_selector = chunk.join("/")
query_handler = query_handlers[name.to_sym]
unless query_handler
raise ArgumentError.new("Query set to use \"#{name}\", but no query handler of that name was found")
end
Result.new(
query_handler: query_handler,
selector: updated_selector,
)
end
|