Class: Datahen::Scraper::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/datahen/scraper/parser.rb

Class Method Summary collapse

Class Method Details

.exec_parser_by_page(filename, page, job_id = nil, save = false, vars = {}, keep_outputs = false) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/datahen/scraper/parser.rb', line 21

def self.exec_parser_by_page(filename, page, job_id=nil, save=false, vars = {}, keep_outputs=false)
  extname = File.extname(filename)
  case extname
  when '.rb'
    executor = RubyParserExecutor.new(
      filename: filename,
      page: page,
      job_id: job_id,
      vars: vars,
      keep_outputs: keep_outputs
    )
    executor.exec_parser(save)
  else
    puts "Unable to find a parser executor for file type \"#{extname}\""
  end
end

.exec_parser_page(filename, gid, job_id = nil, save = false, vars = {}, keep_outputs = false) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/datahen/scraper/parser.rb', line 4

def self.exec_parser_page(filename, gid, job_id=nil, save=false, vars = {}, keep_outputs=false)
  extname = File.extname(filename)
  case extname
  when '.rb'
    executor = RubyParserExecutor.new(
      filename: filename,
      gid: gid,
      job_id: job_id,
      vars: vars,
      keep_outputs: keep_outputs
    )
    executor.exec_parser(save)
  else
    puts "Unable to find a parser executor for file type \"#{extname}\""
  end
end