Skip to content

Commit

Permalink
merge gfm
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie committed Jul 21, 2011
2 parents fc6149a + d9b1ea3 commit 267323c
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
@@ -0,0 +1,5 @@
script: "bundle exec rake test"
rvm:
- 1.8.7
- 1.9.2
- rbx-2.0
1 change: 1 addition & 0 deletions Gemfile
@@ -1,3 +1,4 @@
source "http://rubygems.org"

gemspec
gem "rake", "~> 0.9.2"
2 changes: 1 addition & 1 deletion gollum.gemspec
Expand Up @@ -29,6 +29,7 @@ Gem::Specification.new do |s|
s.add_dependency('mustache', [">= 0.11.2", "< 1.0.0"])
s.add_dependency('sanitize', "~> 2.0.0")
s.add_dependency('nokogiri', "~> 1.4")
s.add_dependency('redcarpet')

s.add_development_dependency('RedCloth')
s.add_development_dependency('mocha')
Expand All @@ -38,7 +39,6 @@ Gem::Specification.new do |s|
s.add_development_dependency('rack-test')
s.add_development_dependency('wikicloth')
s.add_development_dependency('rake')
s.add_development_dependency('redcarpet')

# = MANIFEST =
s.files = %w[
Expand Down
18 changes: 11 additions & 7 deletions lib/gollum/git_access.rb
Expand Up @@ -28,13 +28,17 @@ def exist?
#
# ref - a String Git reference (ex: "master")
#
# Returns a String.
# Returns a String, or nil if the ref isn't found.
def ref_to_sha(ref)
if sha?(ref)
ref
else
get_cache(:ref, ref) { ref_to_sha!(ref) }
end
ref = ref.to_s
return if ref.empty?
sha =
if sha?(ref)
ref
else
get_cache(:ref, ref) { ref_to_sha!(ref) }
end.to_s
sha.empty? ? nil : sha
end

# Public: Gets a recursive list of Git blobs for the whole tree at the
Expand Down Expand Up @@ -238,4 +242,4 @@ def decode_git_path(path)
path
end
end
end
end
13 changes: 8 additions & 5 deletions lib/gollum/wiki.rb
Expand Up @@ -525,11 +525,14 @@ def page_file_name(name, format)
#
# Returns a flat Array of Gollum::Page instances.
def tree_list(ref)
sha = @access.ref_to_sha(ref)
commit = @access.commit(sha)
tree_map_for(sha).inject([]) do |list, entry|
next list unless @page_class.valid_page_name?(entry.name)
list << entry.page(self, commit)
if sha = @access.ref_to_sha(ref)
commit = @access.commit(sha)
tree_map_for(sha).inject([]) do |list, entry|
next list unless @page_class.valid_page_name?(entry.name)
list << entry.page(self, commit)
end
else
[]
end
end

Expand Down
6 changes: 6 additions & 0 deletions test/helper.rb
Expand Up @@ -38,6 +38,12 @@ def commit_details
:email => "tom@github.com" }
end

def normal(text)
text.gsub!(' ', '')
text.gsub!("\n", '')
text
end

# test/spec/mini 3
# http://gist.github.com/25455
# chris@ozmm.org
Expand Down
10 changes: 5 additions & 5 deletions test/test_markup.rb
Expand Up @@ -173,7 +173,7 @@
@wiki.write_page("Potato", :mediawiki, "a [[Potato|Potato Heaad]] ", commit_details)
page = @wiki.page("Potato")
output = page.formatted_data
assert_equal "<p>\na <a class=\"internal present\" href=\"/Potato\">Potato Heaad</a> </p>", output
assert_equal normal("<p>\na <a class=\"internal present\" href=\"/Potato\">Potato Heaad</a> </p>"), normal(output)
end

#########################################################################
Expand Down Expand Up @@ -476,8 +476,8 @@
test "id prefix added" do
content = "h2(#foo). xxxx[1]\n\nfn1.footnote"
output = "<h2 id=\"wiki-foo\">xxxx" +
"<sup class=\"footnote\"><a href=\"#wiki-fn1\">1</a></sup></h2>" +
"\n<p class=\"footnote\" id=\"wiki-fn1\"><sup>1</sup> footnote</p>"
"<sup class=\"footnote\" id=\"wiki-fnr1\"><a href=\"#wiki-fn1\">1</a></sup></h2>" +
"\n<p class=\"footnote\" id=\"wiki-fn1\"><a href=\"#wiki-fnr1\"><sup>1</sup></a> footnote</p>"
compare(content, output, :textile)
end

Expand Down Expand Up @@ -513,7 +513,7 @@ def compare(content, output, ext = "md", regexes = [])
page = @wiki.page("Bilbo Baggins")
rendered = Gollum::Markup.new(page).render
if regexes.empty?
assert_equal output, rendered
assert_equal normal(output), normal(rendered)
else
regexes.each { |r| assert_match r, output }
end
Expand All @@ -528,6 +528,6 @@ def relative_image(content, output)
@wiki.clear_cache
page = @wiki.page("Bilbo Baggins")
rendered = Gollum::Markup.new(page).render
assert_equal output, rendered
assert_equal normal(output), normal(rendered)
end
end

0 comments on commit 267323c

Please sign in to comment.