PageRenderTime 46ms CodeModel.GetById 40ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Rakefile

https://github.com/andrewrjones/ruby-duck-duck-go
Rakefile | 93 lines | 68 code | 12 blank | 13 comment | 2 complexity | 19a683e9e3fdddb519506c3f6a117969 MD5 | raw file
 1require 'rake'
 2
 3task :default => [:test]
 4
 5require 'rake/testtask'
 6desc "Run unit tests"
 7Rake::TestTask.new("test") { |t|
 8  t.pattern = 'test/tc_*.rb'
 9  t.verbose = true
10}
11
12begin
13  require 'jeweler'
14  Jeweler::Tasks.new do |gem|
15    gem.name = "duck-duck-go"
16    gem.summary = %Q{Access the DuckDuckGo Zero Click Info API}
17    gem.description = %Q{A Ruby library to access the DuckDuckGo Zero Click Info API.}
18    gem.email = "andrew@arjones.co.uk"
19    gem.homepage = "https://github.com/andrewrjones/ruby-duck-duck-go"
20    gem.authors = ["andrewrjones"]
21    gem.add_dependency('httpclient')
22    gem.add_dependency('json')
23    # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
24  end
25  Jeweler::GemcutterTasks.new
26rescue LoadError
27  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
28end
29
30begin
31  require 'rcov/rcovtask'
32  Rcov::RcovTask.new do |rcov|
33    rcov.libs << 'test'
34    rcov.pattern = 'test/tc_*.rb'
35    rcov.verbose = true
36    rcov.rcov_opts << '--exclude gems'
37  end
38rescue LoadError
39  task :rcov do
40    abort "RCov is not available. In order to run rcov, you must: sudo gem install rcov"
41  end
42end
43
44#require 'rake/rdoctask'
45#Rake::RDocTask.new do |rdoc|
46#  version = File.exist?('VERSION') ? File.read('VERSION') : ""
47#
48#  rdoc.rdoc_dir = 'rdoc'
49#  rdoc.title = "duck-duck-go #{version}"
50#  rdoc.rdoc_files.include('README*')
51#  rdoc.rdoc_files.include('LICENSE')
52#  rdoc.rdoc_files.include('lib/**/*.rb')
53#end
54
55desc "Run cane to check quality metrics"
56task :quality do
57  puts `cane --abc-max 10 --gte coverage/covered_percent,99`
58  exit $?.exitstatus unless $?.exitstatus == 0
59end
60
61# dumps out the result of the query, in JSON and Ruby
62# used during development
63task :search_dump do
64  require 'rubygems'
65  require 'httpclient'
66  require 'json'
67  require 'pp'
68  
69  unless ENV.include?("query")
70    raise "usage: rake search_dump query=___"
71  end
72  
73  args = {
74    'q' => ENV['query'],
75    'o' => 'json'
76  }
77  if ENV.include?("skip_disambiguation")
78    args['d'] = 1
79  end
80  
81  
82  http = HTTPClient.new
83  json = http.get_content('http://api.duckduckgo.com/', args)
84  ruby = JSON.parse(json)
85  
86  puts 'JSON'
87  puts '----'
88  puts json
89  puts
90  puts 'Ruby'
91  puts '----'
92  pp ruby
93end