Subversion Repositories SmartDukaan

Rev

Rev 30 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
30 ashish 1
#
2
# Licensed to the Apache Software Foundation (ASF) under one
3
# or more contributor license agreements. See the NOTICE file
4
# distributed with this work for additional information
5
# regarding copyright ownership. The ASF licenses this file
6
# to you under the Apache License, Version 2.0 (the
7
# "License"); you may not use this file except in compliance
8
# with the License. You may obtain a copy of the License at
9
#
10
#   http://www.apache.org/licenses/LICENSE-2.0
11
#
12
# Unless required by applicable law or agreed to in writing,
13
# software distributed under the License is distributed on an
14
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
# KIND, either express or implied. See the License for the
16
# specific language governing permissions and limitations
17
# under the License.
18
#
19
 
20
require 'rubygems'
21
require 'rake'
22
require 'spec/rake/spectask'
23
 
24
THRIFT = '../../compiler/cpp/thrift'
25
 
26
task :default => [:spec]
27
 
28
task :spec => [:'gen-rb', :realspec]
29
 
30
Spec::Rake::SpecTask.new(:realspec) do |t|
31
  t.spec_files = FileList['spec/**/*_spec.rb']
32
  t.spec_opts = ['--color']
33
end
34
 
35
Spec::Rake::SpecTask.new(:'spec:rcov') do |t|
36
  t.spec_files = FileList['spec/**/*_spec.rb']
37
  t.spec_opts = ['--color']
38
  t.rcov = true
39
  t.rcov_opts = ['--exclude', '^spec,/gems/']
40
end
41
 
42
desc 'Run the compiler tests (requires full thrift checkout)'
43
task :test do
44
  # ensure this is a full thrift checkout and not a tarball of the ruby libs
45
  cmd = 'head -1 ../../README 2>/dev/null | grep Thrift >/dev/null 2>/dev/null'
46
  system(cmd) or fail "rake test requires a full thrift checkout"
47
  sh 'make', '-C', File.dirname(__FILE__) + "/../../test/rb", "check"
48
end
49
 
50
desc 'Compile the .thrift files for the specs'
51
task :'gen-rb' => [:'gen-rb:spec', :'gen-rb:benchmark', :'gen-rb:debug_proto']
52
 
53
namespace :'gen-rb' do
54
  task :'spec' do
55
    dir = File.dirname(__FILE__) + '/spec'
56
    sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/ThriftSpec.thrift"
57
  end
58
 
59
  task :'benchmark' do
60
    dir = File.dirname(__FILE__) + '/benchmark'
61
    sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/Benchmark.thrift"
62
  end
63
 
64
  task :'debug_proto' do
65
    sh "mkdir", "-p", "debug_proto_test"
66
    sh THRIFT, '--gen', 'rb', "-o", "debug_proto_test", "../../test/DebugProtoTest.thrift"
67
  end
68
end
69
 
70
desc 'Run benchmarking of NonblockingServer'
71
task :benchmark do
72
  ruby 'benchmark/benchmark.rb'
73
end
74
 
75
 
76
begin
77
  require 'echoe'
78
 
79
  Echoe.new('thrift') do |p|
80
    p.author = ['Kevin Ballard', 'Kevin Clark', 'Mark Slee']
81
    p.email = ['kevin@sb.org', 'kevin.clark@gmail.com', 'mcslee@facebook.com']
82
    p.summary = "Ruby libraries for Thrift (a language-agnostic RPC system)"
83
    p.url = "http://incubator.apache.org/thrift/"
84
    p.include_rakefile = true
85
    p.version = "0.1.0"
86
    p.rubygems_version = ">= 1.2.0"
87
  end
88
 
89
  task :install => [:check_site_lib]
90
 
91
  require 'rbconfig'
92
  task :check_site_lib do
93
    if File.exist?(File.join(Config::CONFIG['sitelibdir'], 'thrift.rb'))
94
      fail "thrift is already installed in site_ruby"
95
    end
96
  end
97
rescue LoadError
98
  [:install, :package].each do |t|
99
    desc "Stub for #{t}"
100
    task t do
101
      fail "The Echoe gem is required for this task"
102
    end
103
  end
104
end