Sha256: 686540900d671142a5140d833190854e11272dd64474bdb59927d93bba004e7d
Contents?: true
Size: 1.01 KB
Versions: 18
Compression:
Stored size: 1.01 KB
Contents
module Rake module Funnel module Support class BinaryVersionReader class << self KNOWN_ATTRIBUTES = [:company_name, :file_description, :file_version, :legal_copyright, :product_name, :product_version, :assembly_version] SEPARATOR = "\0" TERMINATOR = "\0" * 3 def read_from(assembly) binary = File.binread(assembly) attributes = KNOWN_ATTRIBUTES.map { |attr| read_attribute(binary, attr) } hash = attributes.inject({}) { |memo, attr| memo.merge(attr) } VersionInfo.new(hash) end private def read_attribute(binary, attr) binary_attr = attr.pascalize.gsub(/(.)/) { |match| match + SEPARATOR } data = binary.match(/#{binary_attr}#{SEPARATOR}+(.*?)#{TERMINATOR}/) return {} if data.nil? { "#{attr}" => data[1].gsub(/#{SEPARATOR}/, '') } end end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems