Sha256: fc486c7725c56d35e044985b2cad1e3f2e93e27769a2494cc78a70ba64a97670

Contents?: true

Size: 772 Bytes

Versions: 2

Compression:

Stored size: 772 Bytes

Contents

require "bundler/gem_tasks"
require 'tempfile'
require 'shellwords'

namespace :geong do
  task :generate_thrift do
    output_dir = File.expand_path('../generated/geong/geocoder/', __FILE__)
    thrift_file = File.expand_path('../thrift/geocoder.thrift', __FILE__)
    command = "thrift --gen rb -out #{Shellwords.escape(output_dir)} #{Shellwords.escape(thrift_file)}"
    $stderr.puts(command)
    unless system(command)
      abort "thrift command error!"
    end
    Dir.glob(output_dir + '/*.rb').each do |file|
      file_body = nil
      File.open(file, 'r') do |in_f|
        file_body = in_f.read
      end
      File.open(file, 'w') do |out_f|
        out_f << file_body.gsub("require 'geocoder_", "require 'geong/geocoder/geocoder_")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geong-0.0.2 Rakefile
geong-0.0.1 Rakefile