jobparser 0.13.1 → 0.13.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,6 +37,17 @@ module JobParser
37
37
  end
38
38
  end
39
39
 
40
+ def view_cache
41
+ res = []
42
+ Job.each do |job|
43
+ res.push({
44
+ :url => job.url,
45
+ :created => job.created_at
46
+ })
47
+ end
48
+ res
49
+ end
50
+
40
51
 
41
52
  class Job
42
53
  include Mongoid::Document
@@ -23,8 +23,7 @@ module JobParser
23
23
  end
24
24
 
25
25
  def clear_all
26
- files = Dir[File.join(JobParser.config[:cache_location], "*.txt")]
27
- files.each { |f| File.delete(f) }
26
+ cache_files.each { |f| File.delete(f) }
28
27
  end
29
28
 
30
29
  def cache_expired?(url)
@@ -33,8 +32,24 @@ module JobParser
33
32
  Time.now > expire_time
34
33
  end
35
34
 
35
+ def view_cache
36
+ res = []
37
+ cache_files.each do |f|
38
+ contents = JSON.parse(IO.read(f))
39
+ res.push({
40
+ :url => contents["url"],
41
+ :created => File.mtime(f)
42
+ })
43
+ end
44
+ res
45
+ end
46
+
36
47
  private
37
48
 
49
+ def cache_files
50
+ Dir[File.join(JobParser.config[:cache_location], "*.txt")]
51
+ end
52
+
38
53
  def write_to_file(path, contents)
39
54
  File.open(path, "w") { |f| f.puts(contents) }
40
55
  end
@@ -16,6 +16,10 @@ module JobParser
16
16
  JobParser.config[:cache_storage_class].new.cache_expired?(url)
17
17
  end
18
18
 
19
+ def view_cache
20
+ JobParser.config[:cache_storage_class].new.view_cache
21
+ end
22
+
19
23
  def clear_all
20
24
  JobParser.config[:cache_storage_class].new.clear_all
21
25
  end
@@ -1,3 +1,3 @@
1
1
  module JobParser
2
- VERSION = "0.13.1"
2
+ VERSION = "0.13.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jobparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.13.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: