Created
November 5, 2011 13:35
-
-
Save takkaw/1341504 to your computer and use it in GitHub Desktop.
earthquake.gem search plug_in from japanese
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| Earthquake.init do | |
| command :search_ja do |m| | |
| search_options = config[:search_options] ? config[:search_options].dup : {} | |
| search_options.merge! :lang => "ja" | |
| puts_items twitter.search(m[1], search_options)["results"].each { |s| | |
| s["user"] = {"screen_name" => s["from_user"]} | |
| s["_disable_cache"] = true | |
| words = m[1].split(/\s+/).reject{|x| x[0] =~ /^-|^(OR|AND)$/ }.map{|x| | |
| case x | |
| when /^from:(.+)/, /^to:(.+)/ | |
| $1 | |
| else | |
| x | |
| end | |
| } | |
| s["_highlights"] = words | |
| } | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment