lib/boom/platform.rb in boom-0.2.3 vs lib/boom/platform.rb in boom-0.2.4
- old
+ new
@@ -46,13 +46,13 @@
# method is designed to handle multiple platforms.
#
# Returns a String of the Item value.
def open(item)
unless windows?
- system("#{open_command} '#{item.url.gsub("\'","\\'")}'")
+ system("#{open_command} '#{item.url.gsub("\'","'\\\\''")}'")
else
- system("#{open_command} #{item.url.gsub("\'","\\'")}")
+ system("#{open_command} #{item.url.gsub("\'","'\\\\''")}")
end
item.value
end
@@ -73,28 +73,28 @@
# Public: copies a given Item's value to the clipboard. This method is
# designed to handle multiple platforms.
#
# Returns the String value of the Item.
def copy(item)
- unless windows?
- system("printf '#{item.value.gsub("\'","\\'")}' | #{copy_command}")
- else
- system("echo #{item.value.gsub("\'","\\'")} | #{copy_command}")
- end
-
+ IO.popen(copy_command,"w") {|cc| cc.write(item.value)}
item.value
end
# Public: opens the JSON file in an editor for you to edit. Uses the
# $EDITOR environment variable, or %EDITOR% on Windows for editing.
# This method is designed to handle multiple platforms.
+ # If $EDITOR is nil, try to open using the open_command.
#
# Returns a String with a helpful message.
def edit(json_file)
- unless windows?
- system("`echo $EDITOR` #{json_file} &")
+ unless $EDITOR.nil?
+ unless windows?
+ system("`echo $EDITOR` #{json_file} &")
+ else
+ system("start %EDITOR% #{json_file}")
+ end
else
- system("start %EDITOR% #{json_file}")
+ system("#{open_command} #{json_file}")
end
"Make your edits, and do be sure to save."
end
end