Sha256: 38410692a8c6bdde5afba965f97489c9d7aae683851a22b0e09537238f641122

Contents?: true

Size: 644 Bytes

Versions: 6

Compression:

Stored size: 644 Bytes

Contents

# frozen_string_literal: true

# Ruby internal
require 'net/http'
require 'tempfile'
require 'json'

# TLS map module
module TLSmap
  # Generic utilities
  module Utils
    def self.tmpfile(name, url)
      tmp = Tempfile.new(name)
      tmp.write(Net::HTTP.get(URI(url)))
      tmp.close
      tmp
    end

    # 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
    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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tls-map-3.0.0 lib/tls_map/utils/utils.rb
tls-map-2.2.0 lib/tls_map/utils/utils.rb
tls-map-2.1.0 lib/tls_map/utils/utils.rb
tls-map-2.0.0 lib/tls_map/utils/utils.rb
tls-map-1.3.2 lib/tls_map/utils.rb
tls-map-1.3.1 lib/tls_map/utils.rb