Module: TLSmap::Utils
- Defined in:
- lib/tls_map/utils/utils.rb
Overview
Generic utilities
Class Method Summary collapse
-
.json_load_file(filespec, opts = {}) ⇒ Object
bring JSON.load_file before ruby 3.0.0 https://ruby-doc.org/stdlib-3.0.0/libdoc/json/rdoc/JSON.html#method-i-load_file.
- .tmpfile(name, url) ⇒ Object
Class Method Details
.json_load_file(filespec, opts = {}) ⇒ Object
bring JSON.load_file before ruby 3.0.0 https://ruby-doc.org/stdlib-3.0.0/libdoc/json/rdoc/JSON.html#method-i-load_file
21 22 23 24 25 26 27 |
# File 'lib/tls_map/utils/utils.rb', line 21 def self.json_load_file(filespec, opts = {}) if RUBY_VERSION < '3.0.0' JSON.parse(File.read(filespec), opts) else JSON.load_file(filespec, opts) end end |
.tmpfile(name, url) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/tls_map/utils/utils.rb', line 12 def self.tmpfile(name, url) tmp = Tempfile.new(name) tmp.write(Net::HTTP.get(URI(url))) tmp.close tmp end |