Permalink
Browse files

modify example

  • Loading branch information...
1 parent acb41d1 commit d32c7e5330033044eb283620d7143902609d1330 @technohippy technohippy committed Dec 28, 2008
Showing with 60 additions and 34 deletions.
  1. +1 −1 README.txt
  2. +56 −0 examples/addressbook.pb.rb
  3. +0 −30 examples/addressbook.rb
  4. +1 −1 examples/reading_a_message.rb
  5. +1 −1 examples/writing_a_message.rb
  6. +1 −1 lib/ruby_protobuf.rb
View
2 README.txt
@@ -14,7 +14,7 @@ Protocol Buffers for Ruby.
== SYNOPSIS:
- rprotoc test/addressbook.proto
+ rprotoc examples/addressbook.proto
== REQUIREMENTS:
View
56 examples/addressbook.pb.rb
@@ -0,0 +1,56 @@
+### Generated by rprotoc. DO NOT EDIT!
+### <proto file: examples/addressbook.proto>
+# package tutorial;
+#
+# message Person {
+# required string name = 1;
+# required int32 id = 2;
+# optional string email = 3;
+#
+# enum PhoneType {
+# MOBILE = 0;
+# HOME = 1;
+# WORK = 2;
+# }
+#
+# message PhoneNumber {
+# required string number = 1;
+# optional PhoneType type = 2 [default = HOME];
+# }
+#
+# repeated PhoneNumber phone = 4;
+# }
+#
+# message AddressBook {
+# repeated Person person = 1;
+# }
+
+require 'protobuf/message/message'
+require 'protobuf/message/enum'
+require 'protobuf/message/service'
+require 'protobuf/message/extend'
+
+module Tutorial
+ class Person < ::Protobuf::Message
+ defined_in __FILE__
+ required :string, :name, 1
+ required :int32, :id, 2
+ optional :string, :email, 3
+ class PhoneType < ::Protobuf::Enum
+ defined_in __FILE__
+ MOBILE = 0
+ HOME = 1
+ WORK = 2
+ end
+ class PhoneNumber < ::Protobuf::Message
+ defined_in __FILE__
+ required :string, :number, 1
+ optional :PhoneType, :type, 2, :default => :HOME
+ end
+ repeated :PhoneNumber, :phone, 4
+ end
+ class AddressBook < ::Protobuf::Message
+ defined_in __FILE__
+ repeated :Person, :person, 1
+ end
+end
View
30 examples/addressbook.rb
@@ -1,30 +0,0 @@
-require 'protobuf/message/message'
-require 'protobuf/message/enum'
-require 'protobuf/message/service'
-require 'protobuf/message/extend'
-
-module Tutorial
-
- class Person < ::Protobuf::Message
- required :string, :name, 1
- required :int32, :id, 2
- optional :string, :email, 3
-
- class PhoneType < ::Protobuf::Enum
- MOBILE = 0
- HOME = 1
- WORK = 2
- end
-
- class PhoneNumber < ::Protobuf::Message
- required :string, :number, 1
- optional :PhoneType, :type, 2, {:default => :HOME}
- end
-
- repeated :PhoneNumber, :phone, 4
- end
-
- class AddressBook < ::Protobuf::Message
- repeated :Person, :person, 1
- end
-end
View
2 examples/reading_a_message.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require 'addressbook'
+require 'addressbook.pb'
def list_people(address_book)
address_book.person.each do |person|
View
2 examples/writing_a_message.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require 'addressbook'
+require 'addressbook.pb'
def prompt_for_address(person)
print 'Enter person ID number: '
View
2 lib/ruby_protobuf.rb
@@ -1,3 +1,3 @@
class RubyProtobuf
- VERSION = '0.3.1'
+ VERSION = '0.3.2'
end

0 comments on commit d32c7e5

Please sign in to comment.