Sha256: 0904bda3571acc3905313d4c3d29034fb52bf212ef17424fe304cc054f851fe2

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

namespace :protobuf do
  src_directory = 'lib/connect_proto/src'

  def compile(src_directory, path)
    print "Compiling #{path}"
    `protoc --proto_path=#{src_directory} --ruby_out=lib/connect_proto/build #{path}`
    puts ' - done' if $?.exitstatus.zero?
  end

  namespace :build do
    task :default do
      Dir.glob("#{src_directory}/**/*.proto").each do |protobuf|
        compile(src_directory, protobuf)
      end
    end

    desc 'Watch protobuf src directory and compile after any changes'
    task :watch do
      require 'listen'
      listener = Listen.to(src_directory, only: /.proto$/, relative: true) do |modified, added, removed|
        (modified + added).each do |path|
          compile(src_directory, path)
        end
        removed.each do |path|
          puts "Deleting #{path}"
          File.delete(path) if File.exist?(path)
        end
      end
      listener.start
      puts "Watching #{src_directory}/**/*.proto"
      sleep
    end
  end

  desc 'Compile all protobufs'
  task build: 'build:default'
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
primary_connect_proto-0.5.0 Rakefile
primary_connect_proto-0.4.0 Rakefile
primary_connect_proto-0.3.0 Rakefile
primary_connect_proto-0.2.0 Rakefile
primary_connect_proto-0.1.0 Rakefile
primary_connect_proto-0.0.8 Rakefile
primary_connect_proto-0.0.7 Rakefile
primary_connect_proto-0.0.6 Rakefile