jobs_chaser 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jobs_chaser.rb +24 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1dc8f1efba062771a1b54ed79ede22cd65b66a554d3c987e0f94658a564c294
4
- data.tar.gz: d5ef33b5637f1a6261d5cacc8d13a07063dd9d106073afe3c57c5646b1804c99
3
+ metadata.gz: 3971478f2205d14fb033ab493fb32868b2a389991765470106f4809c3a953716
4
+ data.tar.gz: 54b015e1c91f44edb2a0f72cc96f92ed3d27139ee8588b220f8a468208f640dd
5
5
  SHA512:
6
- metadata.gz: 815aeb76af9b5581d4677939dadf4902062ebaef6401bf15aa4733437975a2bd2a98e8329ca6869c55e110706efc5d023d8f850fc68e6884e3bde281a8948592
7
- data.tar.gz: bd2b25e69e5e0f63db736b777f88665013310a5f1f168da6cc9701da9be74f4b0426e0e511a24e4525c1e2b37d27929e1466b2851c3db9c7076fcbc325af3815
6
+ metadata.gz: f1ddcd65df8b0cf1748ae60f1038aad2a9d9b86903e3e539219ede740e7cb1508eb169a725e66ae20f1e7d8d29ae83a502c045fa50d39acf61322b645203df73
7
+ data.tar.gz: c20c8e8db0499b4518787ebe4f8e447050f5f927e5bb72159b3df90e8f8a78f7a2b31596a344be352b0a7d1e85df3fb7c93c4329ec94e88846d438da73b4271f
data/lib/jobs_chaser.rb CHANGED
@@ -1,12 +1,14 @@
1
1
  require 'httparty'
2
2
  require 'json'
3
+ require 'yaml'
3
4
  require_relative 'api_clients/getonbrd_client'
4
5
  require_relative 'api_clients/remotive_client'
5
6
  require_relative 'filtering/job_filter'
6
7
 
7
8
  class JobsChaser
8
9
  def initialize(title_keywords_file, description_keywords_file)
9
- @sites = YAML.load_file('config/sites.yml')
10
+ config_path = File.join(File.dirname(__FILE__), '..', 'config', 'sites.yml')
11
+ @sites = YAML.load_file(config_path)
10
12
  @title_keywords_file = title_keywords_file
11
13
  @description_keywords_file = description_keywords_file
12
14
  end
@@ -23,6 +25,8 @@ class JobsChaser
23
25
 
24
26
  job_list = JobFilter.discard(job_list, @title_keywords_file)
25
27
  valid_jobs = JobFilter.filter_jobs(job_list, @description_keywords_file)
28
+
29
+ export(csv_filename, valid_jobs)
26
30
  end
27
31
 
28
32
  def select_api_client(site_name)
@@ -35,4 +39,23 @@ class JobsChaser
35
39
  raise "Unsupported site: #{site_name}"
36
40
  end
37
41
  end
42
+
43
+ def export(csv_filename, offers)
44
+ if defined?(Rails)
45
+ # Running in a Rails project
46
+ rails_root = Rails.root
47
+ else
48
+ # Running outside a Rails project, use a fallback directory
49
+ rails_root = Pathname.new(__FILE__).dirname.dirname
50
+ end
51
+
52
+ output_path = rails_root.join('data', csv_filename)
53
+
54
+ CSV.open(output_path, 'w') do |csv|
55
+ csv << ['Date', 'Job Title', 'Company', 'Location', 'URL']
56
+ offers.each { |offer| csv << [Date.today, offer[:title], offer[:company], offer[:location], offer[:url]] }
57
+ end
58
+
59
+ puts "Job offers have been exported and saved to #{output_path}."
60
+ end
38
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jobs_chaser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sante Di Maio