diff --git a/bin/rprotoc b/bin/rprotoc index 9b04df5..3863767 100755 --- a/bin/rprotoc +++ b/bin/rprotoc @@ -21,6 +21,8 @@ opts.on('-o', '--out ', 'Specify the directory in which Ruby source fil opts.on_tail('-v', '--version', 'Show version.'){ puts(opts.ver); exit } opts.on_tail('-h', '--help', 'Show this message.'){ puts(opts.help); exit } +Version = Protobuf::Version + begin opts.order! rescue OptionParser::ParseError diff --git a/lib/protobuf/common/util.rb b/lib/protobuf/common/util.rb index f2323d3..702e303 100644 --- a/lib/protobuf/common/util.rb +++ b/lib/protobuf/common/util.rb @@ -14,4 +14,10 @@ def underscore(name) name.to_s.gsub(/\B[A-Z]/, '_\&').downcase end end + + begin + Version = File.read(File.dirname(__FILE__) + '/../../../VERSION') + rescue + Version = 'unknown' + end end