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