Format code

This commit is contained in:
bootstraponline
2014-04-05 12:48:31 -04:00
parent 452d825e66
commit 2ae75978dd
12 changed files with 307 additions and 270 deletions
+3 -1
View File
@@ -151,7 +151,9 @@ if options['irb']
begin begin
require 'gollum-lib' require 'gollum-lib'
wiki = Gollum::Wiki.new(gollum_path, wiki_options) wiki = Gollum::Wiki.new(gollum_path, wiki_options)
if !wiki.exist? then raise Gollum::InvalidGitRepositoryError end if !wiki.exist? then
raise Gollum::InvalidGitRepositoryError
end
puts "Loaded Gollum wiki at #{File.expand_path(gollum_path).inspect}." puts "Loaded Gollum wiki at #{File.expand_path(gollum_path).inspect}."
puts puts
puts %( page = wiki.page('page-name')) puts %( page = wiki.page('page-name'))
+2 -1
View File
@@ -22,7 +22,8 @@ module Gollum
::File.expand_path('gollum/public', ::File.dirname(__FILE__)) ::File.expand_path('gollum/public', ::File.dirname(__FILE__))
end end
class Error < StandardError; end class Error < StandardError;
end
class DuplicatePageError < Error class DuplicatePageError < Error
attr_accessor :dir attr_accessor :dir
+48 -16
View File
@@ -49,33 +49,53 @@ class String
end end
end end
module URI; class << self module URI
;
class << self
# Does the char code correspond to an alpha-numeric char. # Does the char code correspond to an alpha-numeric char.
# isAlphaNumeric('a'.ord) => true # isAlphaNumeric('a'.ord) => true
# isAlphaNumeric(''.ord) => false # isAlphaNumeric(''.ord) => false
def isAlphaNumeric(cc) def isAlphaNumeric(cc)
# a - z # a - z
if (97 <= cc && cc <= 122); return true end if (97 <= cc && cc <= 122);
return true
end
# A - Z # A - Z
if (65 <= cc && cc <= 90); return true end if (65 <= cc && cc <= 90);
return true
end
# 0 - 9 # 0 - 9
if (48 <= cc && cc <= 57); return true end if (48 <= cc && cc <= 57);
return true
end
return false return false
end end
def unescapePredicate(cc) def unescapePredicate(cc)
if (isAlphaNumeric(cc)); return true end if (isAlphaNumeric(cc));
return true
end
# ! # !
if (cc == 33); return true end if (cc == 33);
return true
end
# '()* # '()*
if (39 <= cc && cc <= 42); return true end if (39 <= cc && cc <= 42);
return true
end
# -. # -.
if (45 <= cc && cc <= 46); return true end if (45 <= cc && cc <= 46);
return true
end
# _ # _
if (cc == 95); return true end if (cc == 95);
return true
end
# ~ # ~
if (cc == 126); return true end if (cc == 126);
return true
end
return false return false
end end
@@ -117,9 +137,15 @@ def URIEncodeOctets(octets, result, index)
65, 66, 67, 68, 69, 70]; 65, 66, 67, 68, 69, 70];
end end
index = URIAddEncodedOctetToBuffer(octets[0], result, index); index = URIAddEncodedOctetToBuffer(octets[0], result, index);
if (octets[1]); index = URIAddEncodedOctetToBuffer(octets[1], result, index) end if (octets[1]);
if (octets[2]); index = URIAddEncodedOctetToBuffer(octets[2], result, index) end index = URIAddEncodedOctetToBuffer(octets[1], result, index)
if (octets[3]); index = URIAddEncodedOctetToBuffer(octets[3], result, index) end end
if (octets[2]);
index = URIAddEncodedOctetToBuffer(octets[2], result, index)
end
if (octets[3]);
index = URIAddEncodedOctetToBuffer(octets[3], result, index)
end
return index; return index;
end end
@@ -158,14 +184,20 @@ def Encode(uri, unescape)
result[index] = cc1; result[index] = cc1;
index += 1 index += 1
else else
if (cc1 >= 0xDC00 && cc1 <= 0xDFFF); throw("URI malformed") end if (cc1 >= 0xDC00 && cc1 <= 0xDFFF);
throw("URI malformed")
end
if (cc1 < 0xD800 || cc1 > 0xDBFF) if (cc1 < 0xD800 || cc1 > 0xDBFF)
index = URIEncodeSingle(cc1, result, index); index = URIEncodeSingle(cc1, result, index);
else else
k+=1; k+=1;
if (k == uriLength); throw("URI malformed") end if (k == uriLength);
throw("URI malformed")
end
cc2 = uri.charCodeAt(k); cc2 = uri.charCodeAt(k);
if (cc2 < 0xDC00 || cc2 > 0xDFFF); throw("URI malformed") end if (cc2 < 0xDC00 || cc2 > 0xDFFF);
throw("URI malformed")
end
index = URIEncodePair(cc1, cc2, result, index); index = URIEncodePair(cc1, cc2, result, index);
end end
end end
+2
View File
@@ -47,6 +47,7 @@ module Precious
end end
@left_diff_line_number = nil @left_diff_line_number = nil
def left_diff_line_number(id, line) def left_diff_line_number(id, line)
if line =~ /^@@/ if line =~ /^@@/
m, li = *line.match(/\-(\d+)/) m, li = *line.match(/\-(\d+)/)
@@ -68,6 +69,7 @@ module Precious
end end
@right_diff_line_number = nil @right_diff_line_number = nil
def right_diff_line_number(id, line) def right_diff_line_number(id, line)
if line =~ /^@@/ if line =~ /^@@/
m, ri = *line.match(/\+(\d+)/) m, ri = *line.match(/\+(\d+)/)