Module: Protomsg
- Defined in:
- lib/protomsg/parser.rb,
lib/protomsg/attribute.rb,
lib/protomsg/message_type.rb
Defined Under Namespace
Classes: Attribute, MessageType
Class Method Summary collapse
Class Method Details
.parse_file(path) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/protomsg/parser.rb', line 2 def self.parse_file(path) File.open(path) do |file| # write the standard protomsg header FileUtils.cp File.join(File.dirname(__FILE__), '..', 'templates', 'protomsg.h'), 'protomsg.h' puts "Created protomsg.h" # extract each message type definition = [] data = file.read data.scan(/(\w+)\s*\{([^\}]+)\}/) do || << MessageType.new(.size + 1, [0], [1]) end # write out each message type's header file .each do || header_name = "#{.name}_message.h" File.open(header_name, 'w') do |file| file.write .to_header_file end puts "Created #{header_name}" end end end |