Sha256: c497cd98d30bb01d860d7c97d22b586392d1f99e165bd56f6930337edded6b5f
Contents?: true
Size: 841 Bytes
Versions: 2
Compression:
Stored size: 841 Bytes
Contents
# frozen_string_literal: true require 'zlib' module EnterRockstar # shared utility code for different modules class Utils def self.load_json(file) if File.exist?(file) && file.end_with?('.gz') data = Zlib::GzipReader.new(StringIO.new(IO.read(file))).read elsif File.exist? file.sub('.gz', '') data = IO.read(file.sub('.gz', '')) else raise IOError, "File not found: #{file}" end data end def self.save_file(filename, contents) File.open(filename, 'w') do |f| gz = Zlib::GzipWriter.new(f) gz.write contents gz.close end puts "Saved as #{filename}" end def self.save_plain(filename, contents) File.open(filename, 'w') do |f| f.write contents end puts "Saved as #{filename}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
enter-rockstar-0.2.1 | lib/enter_rockstar/utils.rb |
enter-rockstar-0.2 | lib/enter_rockstar/utils.rb |