Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 82209a830f
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 50 lines (44 sloc) 1.425 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#!/usr/bin/env rake
require "bundler/gem_tasks"

require 'rake'
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
  test.libs << 'lib'
  test.pattern = 'test/**/*_test.rb'
  test.verbose = true
end

require 'cucumber/rake/task'
Cucumber::Rake::Task.new

require 'yard'
YARD::Rake::YardocTask.new do |y|
  y.options << '--no-private' << '--title' << "Brighter Planet CM1 client for Ruby"
end

task :default => [:test, :cucumber]

namespace :avro do
  task :setup do
    require 'rubygems'
    require 'bundler/setup'
    require File.expand_path("../developer/avro_helper", __FILE__)
    require File.expand_path("../developer/cm1_avro", __FILE__)
    @cm1 = Cm1Avro::Impact.new
  end
  task :api_paths => 'avro:setup' do
    ary = []
    AvroHelper.api_paths(@cm1.avro_response_schema) { |path| ary << path }
    $stdout.write ary.sort.join("\n")
  end
  task :json => 'avro:setup' do
    $stdout.write MultiJson.encode(@cm1.avro_response_schema)
  end
  task :example => 'avro:setup' do
    require 'tempfile'
    file = Tempfile.new('com.brighterplanet.Cm1.example.avr')
    parsed_schema = Avro::Schema.parse(MultiJson.encode(@cm1.avro_response_schema))
    writer = Avro::IO::DatumWriter.new(parsed_schema)
    dw = Avro::DataFile::Writer.new(file, writer, parsed_schema)
    dw << AvroHelper.recursively_stringify_keys(@cm1.example)
    dw.close
    file.close
    $stdout.write File.read(file.path)
  end
end
Something went wrong with that request. Please try again.