Skip to content
This repository was archived by the owner on Mar 24, 2018. It is now read-only.
Open
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
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ task :test => :check_dependencies

task :default => :test

require 'rake/rdoctask'
require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""

Expand Down
31 changes: 31 additions & 0 deletions lib/protobuf/generate_task.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'rubygems'
require 'rake'
require 'protobuf/compiler/compiler'

module Protobuf
class GenerateTask < Rake::TaskLib
def initialize(*proto_paths, &block)
init(proto_paths)

define(&block)
end

def init(*proto_paths)
@proto_paths = Rake::FileList.new(proto_paths)
end

def define
@proto_paths.each do |protobuf|
ruby_protobuf = File.join("lib", File.basename(protobuf, File.extname(protobuf)) + ".pb.rb")

compile_task = file ruby_protobuf => protobuf do
Protobuf::Compiler.compile(protobuf, File.dirname(protobuf), File.dirname(ruby_protobuf))
end

task :protobuf => [ compile_task ]

yield ruby_protobuf if block_given?
end
end
end
end