relaton-render 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relaton/render/general/render.rb +16 -4
- data/lib/relaton/render/version.rb +1 -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: 6b7a094cb951866a90ce67736e150d7723366ad8f4693ac62de82fbd90fccbdc
|
4
|
+
data.tar.gz: 5041e1e397d38d30c6e48b06fa0b78e09afb987c519393c7ba771a892cfb653f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 758a2f69ce87e0b258a0e7f5920f29f347a9fd311a11bb31199baaaaa8f7cd4d6fc46fcfdad5b8567072372b908a13fd1b1816056da0967cefb90bf6b79f0e84
|
7
|
+
data.tar.gz: a0fcbecba3f10f74b5a4dbd8ca056554c19527e5fa0277b39b007102cec98121bdfda1bc6211aa12cc8d69afbdc5e602a862015153e30b1658b4bb2a37e6f244
|
@@ -23,6 +23,7 @@ module Relaton
|
|
23
23
|
root_initalize(options)
|
24
24
|
render_initialize(options)
|
25
25
|
@parse ||= options["parse"]
|
26
|
+
@urlcache = {}
|
26
27
|
end
|
27
28
|
|
28
29
|
def read_config
|
@@ -227,7 +228,7 @@ module Relaton
|
|
227
228
|
def url_exist?(url_string)
|
228
229
|
url = URI.parse(url_string)
|
229
230
|
url.host or return true # allow file URLs
|
230
|
-
res = access_url(url)
|
231
|
+
res = access_url(url) or return false
|
231
232
|
res.is_a?(Net::HTTPRedirection) and return url_exist?(res["location"])
|
232
233
|
res.code[0] != "4"
|
233
234
|
rescue Errno::ENOENT, SocketError
|
@@ -235,11 +236,22 @@ module Relaton
|
|
235
236
|
end
|
236
237
|
|
237
238
|
def access_url(url)
|
238
|
-
req = Net::HTTP.new(url.host, url.port)
|
239
|
-
req.use_ssl = (url.scheme == "https")
|
240
239
|
path = url.path or return false
|
241
240
|
path.empty? and path = "/"
|
242
|
-
|
241
|
+
@urlcache.key?(url.to_s) and return @urlcache[url.to_s]
|
242
|
+
@urlcache[url.to_s] = url_head(url, path)
|
243
|
+
@urlcache[url.to_s]
|
244
|
+
rescue => e
|
245
|
+
warn e.backtrace
|
246
|
+
false
|
247
|
+
end
|
248
|
+
|
249
|
+
def url_head(url, path)
|
250
|
+
Net::HTTP.start(url.host, url.port,
|
251
|
+
read_timeout: 2, open_timeout: 2,
|
252
|
+
use_ssl: url.scheme == "https") do |http|
|
253
|
+
http.request_head(path)
|
254
|
+
end
|
243
255
|
end
|
244
256
|
end
|
245
257
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-render
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|