jobparser 0.13.1 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/jobparser/cache/mongostore.rb +11 -0
- data/lib/jobparser/cache/textfile.rb +17 -2
- data/lib/jobparser/cache.rb +4 -0
- data/lib/jobparser/version.rb +1 -1
- metadata +1 -1
@@ -23,8 +23,7 @@ module JobParser
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def clear_all
|
26
|
-
|
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
|
data/lib/jobparser/cache.rb
CHANGED
@@ -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
|
data/lib/jobparser/version.rb
CHANGED