class Sites::RemoteOk

Constants

HOST
JOB_ITEM_SELECTOR
PATH
STORE_DIR

Public Class Methods

new() click to toggle source
Calls superclass method Sites::Base::new
# File lib/sites/remote_ok.rb, line 11
def initialize
  super
end

Public Instance Methods

collect_jobs(limit: nil) click to toggle source
# File lib/sites/remote_ok.rb, line 15
def collect_jobs(limit: nil)
  puts "[Info] Getting the data from #{url}"
  FileUtils.mkdir_p STORE_DIR

  CSV.open(filepath, 'w') do |csv|
    doc.css(JOB_ITEM_SELECTOR).each do |link|
      return if limit == @rows_count

      job_url = "#{HOST}#{link["data-url"]}"
      puts "[Info] Parsing #{job_url}..."

      csv << get_row(job_url)

      @rows_count += 1
    end
  end

  puts "[Done] Collected #{@rows_count} job offers from #{url}. Data stored in: #{filepath}."
end

Private Instance Methods

get_jobs_count() click to toggle source
# File lib/sites/remote_ok.rb, line 48
def get_jobs_count
  jobs_count = doc.css(JOB_ITEM_SELECTOR).map { |link| link['data-url'] }.size
  puts "[Info] There are #{jobs_count} remote jobs on [RemoteOK]."
  jobs_count
end
get_row(job_url) click to toggle source
# File lib/sites/remote_ok.rb, line 37
def get_row(job_url)
  job_page = Nokogiri::HTML(open_page(job_url))
  offer_text = job_page.css('td.heading').to_s

  location = Support::OfferParser.get_location(offer_text)
  keywords = Support::OfferParser.get_keywords(offer_text)
  company = job_page.css('a.companyLink h3').text

  [job_url, location, keywords, company]
end