Caged / gitnub

A Gitk-like application written in RubyCocoa that looks like it belongs on a Mac. See the wiki for downloads and screenshots.

This URL has Read+Write access

kballard (author)
Wed May 14 02:17:15 -0700 2008
commit  019f7eab430c325acd58a548baa7856fdf69b24e
tree    ae2e9089d76466d66006f680544d11a2c54d49e8
parent  ceed7d12eaa21647294939eb24010c5aa2b2f0e0
gitnub / lib / string_hacks.rb
100644 20 lines (17 sloc) 0.367 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class String
  HTML_ESCAPES = {
    ?& => "amp",
    ?" => "quot",
    ?< => "lt",
    ?> => "gt"
  }.freeze
 
  def escapeHTML
    self.split("").collect { |x| HTML_ESCAPES.key?(x.ord) ? "&#{HTML_ESCAPES[x.ord]};" : x }.join("")
  end
 
  # Ruby 1.9 forward-compatibility
  unless String.method_defined?(:ord)
    define_method :ord do
      self[0]
    end
  end
end