Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a primitive field mapping from symbol to field class #170

Merged
merged 4 commits into from
Feb 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 40 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,56 @@
$: << ::File.expand_path('../', __FILE__)
$: << ::File.expand_path('../spec', __FILE__)

require "rubygems"
require "rubygems/package_task"
require "bundler/gem_tasks"
require "benchmark/tasks"
require 'fileutils'
require 'rubygems'
require 'rubygems/package_task'
require 'bundler/gem_tasks'
require 'benchmark/tasks'

require "rspec/core/rake_task"
require 'rspec/core/rake_task'

desc "Default: run specs."
desc 'Default: run specs.'
task :default => :spec

RSpec::Core::RakeTask.new(:spec)

desc "Run specs"
namespace :spec do
desc "Compile Test Protos in spec/supprt/"
task :compile_test_protos do |task, args|
desc 'Run specs'
namespace :compile do

desc 'Compile spec protos in spec/supprt/ directory'
task :spec do |task, args|
proto_path = ::File.expand_path('../spec/support/', __FILE__)
cmd = %Q{protoc --plugin=./bin/protoc-gen-ruby --ruby_out=#{proto_path} -I #{proto_path} #{File.join(proto_path, '**', '*.proto')}}

puts cmd
exec(cmd)
end

desc 'Compile rpc protos in protos/ directory'
task :rpc do |task, args|
proto_path = ::File.expand_path('../proto', __FILE__)
output_dir = ::File.expand_path('../tmp/rpc', __FILE__)
::FileUtils.mkdir_p(output_dir)

cmd = %Q{protoc --plugin=./bin/protoc-gen-ruby --ruby_out=#{output_dir} -I #{proto_path} #{File.join(proto_path, '**', '*.proto')}}

puts cmd
exec cmd
system(cmd)

files = {
'tmp/rpc/dynamic_discovery.pb.rb' => 'lib/protobuf/rpc',
'tmp/rpc/rpc.pb.rb' => 'lib/protobuf/rpc',
'tmp/rpc/google/protobuf/descriptor.pb.rb' => 'lib/protobuf/descriptors/google/protobuf',
'tmp/rpc/google/protobuf/compiler/plugin.pb.rb' => 'lib/protobuf/descriptors/google/protobuf/compiler'
}

files.each_pair do |source_file, destination_dir|
source_file = ::File.expand_path("../#{source_file}", __FILE__)
destination_dir = ::File.expand_path("../#{destination_dir}", __FILE__)
::FileUtils::Verbose.cp(source_file, destination_dir)
end
end

end

task :console do
Expand Down
33 changes: 17 additions & 16 deletions lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,50 @@
#
require 'protobuf/message'


##
# Imports
#
require 'google/protobuf/descriptor.pb'

module Google

module Protobuf

module Compiler

##
# Message Classes
#
class CodeGeneratorRequest < ::Protobuf::Message; end
class CodeGeneratorResponse < ::Protobuf::Message
class File < ::Protobuf::Message; end

end




##
# Message Fields
#
class CodeGeneratorRequest
repeated ::Protobuf::Field::StringField, :file_to_generate, 1
optional ::Protobuf::Field::StringField, :parameter, 2
repeated :string, :file_to_generate, 1
optional :string, :parameter, 2
repeated ::Google::Protobuf::FileDescriptorProto, :proto_file, 15
end

class CodeGeneratorResponse
class File
optional ::Protobuf::Field::StringField, :name, 1
optional ::Protobuf::Field::StringField, :insertion_point, 2
optional ::Protobuf::Field::StringField, :content, 15
optional :string, :name, 1
optional :string, :insertion_point, 2
optional :string, :content, 15
end
optional ::Protobuf::Field::StringField, :error, 1

optional :string, :error, 1
repeated ::Google::Protobuf::Compiler::CodeGeneratorResponse::File, :file, 15
end



end

end

end

Loading