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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a61037d7e9fc1193d54cb03fd7155a09431a30710990c50366112558b86d8210
4
- data.tar.gz: 7fe54372399bb332f686af101b9f6e36140497e89073cdf02f5e2bb0afec3183
3
+ metadata.gz: 6b7a094cb951866a90ce67736e150d7723366ad8f4693ac62de82fbd90fccbdc
4
+ data.tar.gz: 5041e1e397d38d30c6e48b06fa0b78e09afb987c519393c7ba771a892cfb653f
5
5
  SHA512:
6
- metadata.gz: 9f39ff4adacad120c2b2661d89ff59593b7fb41b4cbee209171ebbb92bf188bb52f36f0e8a8f7c62323cfb834bd2d296a7ce2b94bc8217e86838927c189c2794
7
- data.tar.gz: 655a9918e4559a77dbcb94bcef62037b1e13ae81aea2472e1d8fd62941ff312abdf2394b9a7dec3528faf083e0079b3111d4aec21e4e935a688807a3b348cedd
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
- req.request_head(path)
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
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Render
3
- VERSION = "0.7.1".freeze
3
+ VERSION = "0.7.2".freeze
4
4
  end
5
5
  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.1
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-02 00:00:00.000000000 Z
11
+ date: 2024-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler