Permalink
Browse files

Merge pull request #47 from eLobato/code_search

Code search API support
  • Loading branch information...
2 parents c1e3889 + 62eb0e7 commit d0d1ccc439cdeb9842607478ceb7edab7880bb6e @Raynes committed Dec 16, 2013
Showing with 22 additions and 1 deletion.
  1. +22 −1 src/tentacles/search.clj
View
@@ -29,4 +29,25 @@
[keyword & [options]]
(let [results (api-call :get "/legacy/user/search/%s" [keyword] options)]
(or (:users results)
- results)))
+ results)))
+
+(defn search-code
+ "Find file contents via various criteria. This method returns up to 100
+ results per page.
+ Parameters are:
+ q: string - The search terms. I.e: 'defn mymethod in:file language:cljj'
+ sort: string (optional) - Sort field, defaults to best match,
+ order: string (optional) - Sort order if sort parameter is provided.
+
+ i.e: (search/search-code \"addClass in:file language:js repo:jquery/jquery\")
+
+ More details about the search terms syntax in:
+ http://developer.github.com/v3/search/#search-code"
+ [query & [sort order options]]
+ (let [results (api-call :get "search/code" nil
+ (assoc options
+ :q query
+ :sort sort
+ :order order))]
+ (or (:code results)
+ results)))

0 comments on commit d0d1ccc

Please sign in to comment.