Sha256: a5a49287f8a063b992da6a0379d738847eaac2450a434732e4cfd1eae742ec9b
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
module GoldenRose class XcactivitylogReader def initialize(source_path) @source_path = source_path end def self.read(source_path) new(source_path).read end def read fail XcactivitylogExtensionError.new(extension, @source_path) unless xcactivitylog_file? Zlib::GzipReader.open(@source_path, &:read) rescue Zlib::GzipFile::Error, Errno::ENOENT => e raise XcactivitylogNotFound.new(@source_path, error: e) end def xcactivitylog_file? 'xcactivitylog' == extension end def extension @extension ||= @source_path.split('.').last end class XcactivitylogExtensionError < StandardError attr_reader :file_extension, :path def initialize(file_extension, path) @file_extension = file_extension @path = path super "File under path #{path} has not correct .xcactivity extension!" end end class XcactivitylogNotFound < StandardError attr_reader :path, :options def initialize(path, options = {}) @path = path @options = options @msg = error_msg(path, options[:error]) super @msg end private def error_msg(path, error) return "#{error.message} path => #{path}" if error "File not found or it is not archive! path => #{path}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
golden_rose-1.0.0.pre | lib/golden_rose/xcactivitylog_reader.rb |