Skip to content

Instantly share code, notes, and snippets.

@takkaw
Created November 5, 2011 13:35
Show Gist options
  • Select an option

  • Save takkaw/1341504 to your computer and use it in GitHub Desktop.

Select an option

Save takkaw/1341504 to your computer and use it in GitHub Desktop.
earthquake.gem search plug_in from japanese
# 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