Permalink
Browse files

adds config[:eval_as_ruby_string_for_update]

  • Loading branch information...
1 parent 12f926c commit 4cee07ab0e7843fab9c7dae315a9215104330585 @jugyo committed Apr 28, 2012
Showing with 14 additions and 1 deletion.
  1. +14 −1 lib/earthquake/commands.rb
View
@@ -108,16 +108,29 @@
⚡ :aa :status $aa
HELP
+ def self._eval_as_ruby_string(text)
+ return text unless config[:eval_as_ruby_string_for_update]
+ begin
+ text = eval("\"#{text}\"")
+ rescue Exception => e
+ puts e.message.c(:notice)
+ ensure
+ text
+ end
+ end
+
command %r|^:update$|, :as => :update do
puts "[input EOF (e.g. Ctrl+D) at the last]".c(:info)
text = STDIN.gets(nil)
+ text = _eval_as_ruby_string(text)
if text && !text.split.empty?
async_e{ twitter.update(text) } if confirm("update above AA?")
end
end
command :update do |m|
- async_e { twitter.update(m[1]) } if confirm("update '#{m[1]}'")
+ text = _eval_as_ruby_string(m[1])
+ async_e { twitter.update(text) } if confirm("update '#{text}'")
end
command %r|^[^:\$].*| do |m|

0 comments on commit 4cee07a

Please sign in to comment.