PageRenderTime 63ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/plugins/addspace.rb

https://github.com/Epictetus/termtter
Ruby | 27 lines | 17 code | 2 blank | 8 comment | 0 complexity | efea3d8f04f3d7a1201a637625df0ce2 MD5 | raw file
  1. # -*- coding: utf-8 -*-
  2. config.plugins.addspace.set_default( :before, [ %r{https?://} ] )
  3. config.plugins.addspace.set_default( :after, %w{ })
  4. module Termtter::Client
  5. add_filter do |statuses, event|
  6. statuses.each do |s|
  7. config.plugins.addspace.before.each do |c|
  8. s.text.gsub!(/(?<=\S)(#{c})/, ' \1' )
  9. end
  10. end
  11. statuses.each do |s|
  12. config.plugins.addspace.after.each do |c|
  13. s.text.gsub!(/(#{c})(?=\S)/, '\1 ' )
  14. end
  15. statuses
  16. end
  17. end
  18. end
  19. # addspace
  20. # add space before or after specified words.
  21. # example:
  22. # before: ABCDEhttp://~~~
  23. # after: ABCDE http://~~~
  24. # before:
  25. # after: