PageRenderTime 40ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/DDG/Spice/CodeSearch.pm

https://github.com/robertbrook/zeroclickinfo-spice
Perl | 36 lines | 25 code | 11 blank | 0 comment | 1 complexity | 2c2bd961a70efbfefafbb2d1cbb0f0bd MD5 | raw file
  1. package DDG::Spice::CodeSearch;
  2. use DDG::Spice;
  3. triggers startend => "code", "example";
  4. spice to => 'http://searchco.de/api/jsonp_codesearch_I/?q=$1&callback={{callback}}';
  5. primary_example_queries "javascript console.log example";
  6. description "Code search";
  7. name "CodeSearch";
  8. icon_url "/i/searchco.de.ico";
  9. source "search[code]";
  10. code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/CodeSearch.pm";
  11. topics "sysadmin", "programming";
  12. category "programming";
  13. attribution github => ['https://github.com/boyter','Ben Boyter'],
  14. twitter => ['http://twitter.com/boyter','boyter'];
  15. my $languages = join "|", share('languages.txt')->slurp;
  16. handle remainder => sub {
  17. if ($_ =~ m/\b($languages)\b/x) {
  18. my $match = $1;
  19. $match =~ s/\+/\\+/g;
  20. s/\s*$match\s*//i;
  21. return "lang:".$match." ".$_;
  22. }
  23. return;
  24. };
  25. 1;