Sha256: 4b7db5987cd2f9b60f3376590557790937905a96f3f36057c69a6b1b44389470
Contents?: true
Size: 1007 Bytes
Versions: 21
Compression:
Stored size: 1007 Bytes
Contents
module Protobuf module Protoable def defined_filenames @defined_filenames ||= [] end def defined_in(filename) path = File.expand_path(filename) defined_filenames << path unless defined_filenames.include?(path) end def proto_filenames defined_filenames.map do |filename| retrieve_header(File.read(filename)).first end end def proto_contents #TODO: temporary implementation because the result includes not only this message but also all messages ret = {} defined_filenames.each do |filename| header = retrieve_header(File.read(filename)) ret[header.first] = header.last end ret end def retrieve_header(contents) if contents =~ /### Generated by rprotoc\. DO NOT EDIT!\n### <proto file: (.*)>\n((# .*\n)+)/ proto_filename = $1 proto_contents = $2.gsub(/^# /, '') [proto_filename, proto_contents] else [nil, nil] end end end end
Version data entries
21 entries across 21 versions & 2 rubygems