class RSocial::Runner
Public Class Methods
new(options={})
click to toggle source
# File lib/rsocial/runner.rb, line 3 def initialize(options={}) @options = options end
Public Instance Methods
run(url, injections)
click to toggle source
# File lib/rsocial/runner.rb, line 7 def run(url, injections) begin @wd = Driver.instance.send( "chrome" ) @wd.get url inject_each do injections end rescue Net::ReadTimeout => e { :error => e } end end
Private Instance Methods
execute(script)
click to toggle source
# File lib/rsocial/runner.rb, line 33 def execute(script) begin @wd.execute_script(script) rescue Selenium::WebDriver::Error::JavascriptError "Javascript Error" rescue Selenium::WebDriver::Error::UnknownError "Unknown Error" end end
inject_each(&block)
click to toggle source
# File lib/rsocial/runner.rb, line 23 def inject_each(&block) results = {} block.call.each do |key, script| response = execute(script) response = h2n(response) if keys.include? key results[key.to_sym] = response end results end
keys()
click to toggle source
# File lib/rsocial/runner.rb, line 43 def keys [ :follower_count, :following_count, :track_count, :tweet_count, :like_count, :subscriber_count, :post_count ] end