geturl 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/geturl/geturl-file-manager.rb +35 -0
- data/lib/geturl/geturl-searcher.rb +9 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0225dfb974d2359199c76c94460e587943f1b8cf4313c9ef13bcc41e70ea9103
|
4
|
+
data.tar.gz: af50fa9455394d2c4b4d54751eba728c2f523f3f585e00133257615cdc430c87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45ec1a5193dff2631e2a02416d0702ebd083e5a540203d6712b0630f87b6ef375776e4270bceccd13baf3e60273ea88b81b9d59b0f22989e17530f9d99f6a99a
|
7
|
+
data.tar.gz: 14ecae14c7e882f37bbe6d85a7880e3e6d5c18a969eeb5d6c6ed2098139cb1a5ccb661981a7802376cf6a6e890acd2fa0fc6da8e856009bc0313235a06a96748
|
@@ -67,6 +67,41 @@ module GetUrl
|
|
67
67
|
return File.join(@sources_path, "#{id}.yaml")
|
68
68
|
end
|
69
69
|
|
70
|
+
# Returns the path of the all-items-cache file.
|
71
|
+
#
|
72
|
+
# @return [String] The path of the all-items-cache file.
|
73
|
+
def get_all_items_cache_file
|
74
|
+
File.join(Dir.home, '.geturl', 'all-items-cache.yaml')
|
75
|
+
end
|
76
|
+
|
77
|
+
# Returns true if the all-items-cache file exists.
|
78
|
+
#
|
79
|
+
# @return [TrueClass|FalseClass]
|
80
|
+
def all_items_cache_exist?
|
81
|
+
return File.exists?(get_all_items_cache_file)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Cache the given items to the all-items-cache.
|
85
|
+
#
|
86
|
+
# @param [Object] items
|
87
|
+
def cache_all_items(items)
|
88
|
+
save_items_to_yaml_file(items, get_all_items_cache_file)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Returns all items from the all-items-cache.
|
92
|
+
#
|
93
|
+
# @return [Object] The items
|
94
|
+
def get_all_items_from_cache
|
95
|
+
return load_items_from_yaml_file(get_all_items_cache_file)
|
96
|
+
end
|
97
|
+
|
98
|
+
# Clears the all-items-cache.
|
99
|
+
#
|
100
|
+
# @return [Object]
|
101
|
+
def clear_all_items_cache
|
102
|
+
unlink(get_all_items_cache_file) if all_items_cache_exist?
|
103
|
+
end
|
104
|
+
|
70
105
|
end
|
71
106
|
|
72
107
|
end
|
@@ -25,12 +25,20 @@ module GetUrl
|
|
25
25
|
# Loads all the given source ids. If ids is empty, all sources will be loaded.
|
26
26
|
# @param [Array] ids An array of source ids.
|
27
27
|
def load_sources(ids = nil)
|
28
|
-
ids = Sources.get_sources.keys + ['local'] if ids.nil? || ids.empty?
|
29
28
|
@items.clear
|
29
|
+
|
30
|
+
all_sources = (ids.nil? || ids.empty?)
|
31
|
+
if (all_sources) && (FileManager.all_items_cache_exist?)
|
32
|
+
@items = FileManager.get_all_items_from_cache
|
33
|
+
return
|
34
|
+
end
|
35
|
+
|
36
|
+
ids = Sources.get_sources.keys + ['local'] if ids.nil? || ids.empty?
|
30
37
|
load_source(LocalUrls.private_source_id) if ids.include?('local')
|
31
38
|
Sources.get_sources.keys.each {|id|
|
32
39
|
load_source(id) if ids.include?(id)
|
33
40
|
}
|
41
|
+
FileManager.cache_all_items(@items) if all_sources
|
34
42
|
end
|
35
43
|
|
36
44
|
# Returns all urls of the given ids. If ids is empty, all urls of all sources will be loaded.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geturl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taco Jan Osinga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|