-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrubyscrape.rb
77 lines (60 loc) · 1.41 KB
/
rubyscrape.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'net/http'
require 'net/https'
require 'uri'
require 'debugger'
# ruby -r "./test.rb" -e "TestClass.new.test_function 'hi'"
class Scraper
def initialize
@plugins = '/Users/willmoss26/Documents/ruby/sigads/sigads/lib/plugins' # change this to your 'plugins' directory
end
def run
debugger
# load plugin, upload to database
Dir.glob(@plugins + '*.rb') do |item|
#begin
begin
load item
name = item.sub(".rb" , "")
name = name.sub(@plugins, "")
# init
thisPlugin = Object.const_get(name).new
# output name
puts "@ "+thisPlugin.key
# run test
thisPlugin.test
# start
thisPlugin.start
rescue => e
p e.message
p e.backtrace
next
end
end
end
# for testing only
def runPlugin(plugin)
pluginName = "Plugin_" + plugin
load @plugins + pluginName + ".rb"
thisPlugin = Object.const_get(pluginName).new
puts thisPlugin.key
thisPlugin.start
rates = thisPlugin.rates
puts rates
end
end
module Helpers
def assert(desc, var1, var2)
print "@@@@ Testing #{desc} ... "
if var1==var2 then
print "PASS"
1
else
print "FAIL"
0
end
print "\n"
end
end