class Response
Attributes
jobs[R]
Public Class Methods
new(usajobs_response, usagov_response)
click to toggle source
# File lib/data/response.rb, line 7 def initialize(usajobs_response, usagov_response) @jobs = [] # array of JobData objects parse_usajobs(usajobs_response) @jobs.uniq! parse_usagov(usagov_response) end
Public Instance Methods
match_agency(job, acct, agency)
click to toggle source
# File lib/data/response.rb, line 54 def match_agency(job, acct, agency) agency_name = job.agency_name agency_sub = job.agency_sub github_agency_id = agency['agency_id'] github_agency_name = agency['agency_name'] github_org_name = acct['organization'] github_acct = acct['account'] if github_agency_name.include?(agency_name) || github_agency_name.include?(agency_sub) || github_org_name.include?(agency_name) || github_org_name.include?(agency_sub) || agency_name.include?(github_agency_name) || agency_name.include?(github_org_name) || agency_sub.include?(github_agency_name) || agency_sub.include?(github_org_name) || agency_name.include?(github_agency_id) || agency_sub.include?(github_agency_id) || agency_name.include?(github_acct) || agency_sub.include?(github_acct) job.github_url = acct['service_url'] end end
parse_usagov(response)
click to toggle source
# File lib/data/response.rb, line 38 def parse_usagov(response) response_hash = JSON.parse(response) @jobs.each do |job| # for each job in the result set response_hash['accounts'].each do |acct| # for each github account, see if there's a match acct['agencies'].each do |agency| match_agency(job, acct, agency) end end end end
parse_usajobs(response)
click to toggle source
# File lib/data/response.rb, line 14 def parse_usajobs(response) response_hash = JSON.parse(response) response_hash['JobData'].each do |x| job_data = JobData.new job_data.id = x['AnnouncementNumber'] job_data.title = x['JobTitle'] job_data.agency_name = x['OrganizationName'] job_data.agency_sub = x['AgencySubElement'] job_data.agency_display = x['OrganizationName']+' - '+x['AgencySubElement'] job_data.salary = x['SalaryMin']+' - '+x['SalaryMax']+' '+x['SalaryBasis'] job_data.series_grade = x['PayPlan']+'-'+x['Series']+'-'+x['Grade'] job_data.eligibility = x['WhoMayApplyText'] job_data.position = x['WorkSchedule']+' - '+x['WorkType'] job_data.locations = x['Locations'] job_data.url = x['ApplyOnlineURL'] job_data.dates = x['StartDate']+' - '+x['EndDate'] job_data.summary = x['JobSummary'] @jobs << job_data end end