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
require 'gollum-lib'
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
puts %( page = wiki.page('page-name'))
+2 -1
View File
@@ -22,7 +22,8 @@ module Gollum
::File.expand_path('gollum/public', ::File.dirname(__FILE__))
end
class Error < StandardError; end
class Error < StandardError;
end
class DuplicatePageError < Error
attr_accessor :dir
+48 -16
View File
@@ -49,33 +49,53 @@ class String
end
end
module URI; class << self
module URI
;
class << self
# Does the char code correspond to an alpha-numeric char.
# isAlphaNumeric('a'.ord) => true
# isAlphaNumeric(''.ord) => false
def isAlphaNumeric(cc)
# a - z
if (97 <= cc && cc <= 122); return true end
if (97 <= cc && cc <= 122);
return true
end
# A - Z
if (65 <= cc && cc <= 90); return true end
if (65 <= cc && cc <= 90);
return true
end
# 0 - 9
if (48 <= cc && cc <= 57); return true end
if (48 <= cc && cc <= 57);
return true
end
return false
end
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
end
@@ -117,9 +137,15 @@ def URIEncodeOctets(octets, result, index)
65, 66, 67, 68, 69, 70];
end
index = URIAddEncodedOctetToBuffer(octets[0], result, index);
if (octets[1]); index = URIAddEncodedOctetToBuffer(octets[1], result, index) end
if (octets[2]); index = URIAddEncodedOctetToBuffer(octets[2], result, index) end
if (octets[3]); index = URIAddEncodedOctetToBuffer(octets[3], result, index) end
if (octets[1]);
index = URIAddEncodedOctetToBuffer(octets[1], result, index)
end
if (octets[2]);
index = URIAddEncodedOctetToBuffer(octets[2], result, index)
end
if (octets[3]);
index = URIAddEncodedOctetToBuffer(octets[3], result, index)
end
return index;
end
@@ -158,14 +184,20 @@ def Encode(uri, unescape)
result[index] = cc1;
index += 1
else
if (cc1 >= 0xDC00 && cc1 <= 0xDFFF); throw("URI malformed") end
if (cc1 >= 0xDC00 && cc1 <= 0xDFFF);
throw("URI malformed")
end
if (cc1 < 0xD800 || cc1 > 0xDBFF)
index = URIEncodeSingle(cc1, result, index);
else
k+=1;
if (k == uriLength); throw("URI malformed") end
if (k == uriLength);
throw("URI malformed")
end
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);
end
end
+2
View File
@@ -47,6 +47,7 @@ module Precious
end
@left_diff_line_number = nil
def left_diff_line_number(id, line)
if line =~ /^@@/
m, li = *line.match(/\-(\d+)/)
@@ -68,6 +69,7 @@ module Precious
end
@right_diff_line_number = nil
def right_diff_line_number(id, line)
if line =~ /^@@/
m, ri = *line.match(/\+(\d+)/)