Index: third_party/protobuf/ruby/lib/google/protobuf.rb |
diff --git a/third_party/protobuf/python/google/protobuf/internal/message_cpp_test.py b/third_party/protobuf/ruby/lib/google/protobuf.rb |
similarity index 65% |
copy from third_party/protobuf/python/google/protobuf/internal/message_cpp_test.py |
copy to third_party/protobuf/ruby/lib/google/protobuf.rb |
index 0d84b3207bdd0a5f5b7202e9ad67d6cfcf55e0d3..f0eb626824f23b6dcd858ec820d57bcd246439de 100644 |
--- a/third_party/protobuf/python/google/protobuf/internal/message_cpp_test.py |
+++ b/third_party/protobuf/ruby/lib/google/protobuf.rb |
@@ -1,8 +1,6 @@ |
-#! /usr/bin/python |
-# |
# Protocol Buffers - Google's data interchange format |
# Copyright 2008 Google Inc. All rights reserved. |
-# http://code.google.com/p/protobuf/ |
+# https://developers.google.com/protocol-buffers/ |
# |
# Redistribution and use in source and binary forms, with or without |
# modification, are permitted provided that the following conditions are |
@@ -30,16 +28,45 @@ |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-"""Tests for google.protobuf.internal.message_cpp.""" |
+# require mixins before we hook them into the java & c code |
+require 'google/protobuf/message_exts' |
+ |
+# We define these before requiring the platform-specific modules. |
+# That way the module init can grab references to these. |
+module Google |
+ module Protobuf |
+ class Error < StandardError; end |
+ class ParseError < Error; end |
+ end |
+end |
+ |
+if RUBY_PLATFORM == "java" |
+ require 'json' |
+ require 'google/protobuf_java' |
+else |
+ require 'google/protobuf_c' |
+end |
+ |
+require 'google/protobuf/repeated_field' |
+ |
+module Google |
+ module Protobuf |
-__author__ = 'shahms@google.com (Shahms King)' |
+ def self.encode(msg) |
+ msg.to_proto |
+ end |
-import os |
-os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'cpp' |
+ def self.encode_json(msg) |
+ msg.to_json |
+ end |
-import unittest |
-from google.protobuf.internal.message_test import * |
+ def self.decode(klass, proto) |
+ klass.decode(proto) |
+ end |
+ def self.decode_json(klass, json) |
+ klass.decode_json(json) |
+ end |
-if __name__ == '__main__': |
- unittest.main() |
+ end |
+end |