diff --git a/lib/gollum/committer.rb b/lib/gollum/committer.rb index f100685c..e1911bdf 100644 --- a/lib/gollum/committer.rb +++ b/lib/gollum/committer.rb @@ -1,7 +1,7 @@ module Gollum - # Responsible for handling the commit process for a Wiki. It sets up the + # Responsible for handling the commit process for a Wiki. It sets up the # Git index, provides methods for modifying the tree, and stores callbacks - # to be fired after the commit has been made. This is specifically + # to be fired after the commit has been made. This is specifically # designed to handle multiple updated pages in a single commit. class Committer # Gets the instance of the Gollum::Wiki that is being updated. @@ -21,7 +21,7 @@ module Gollum # :tree - Optional String SHA of the tree to create the # index from. # :committer - Optional Gollum::Committer instance. If provided, - # assume that this operation is part of batch of + # assume that this operation is part of batch of # updates and the commit happens later. # # Returns the Committer instance. @@ -152,7 +152,7 @@ module Gollum # Adds a callback to be fired after a commit. # - # block - A block that expects this Committer instance and the created + # block - A block that expects this Committer instance and the created # commit's SHA1 as the arguments. # # Returns nothing. diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index 6f8db2c2..a7e78a7e 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -16,7 +16,7 @@ module Precious set :public_folder, "#{dir}/public" set :static, true set :default_markup, :markdown - + set :mustache, { # Tell mustache where the Views constant lives :namespace => Precious, diff --git a/lib/gollum/frontend/views/create.rb b/lib/gollum/frontend/views/create.rb index c8f9ab38..b5e974d0 100755 --- a/lib/gollum/frontend/views/create.rb +++ b/lib/gollum/frontend/views/create.rb @@ -8,15 +8,15 @@ module Precious def title "Create a new page" end - + def is_create_page true end - + def is_edit_page false end - + def format @format = (@page.format || false) if @format.nil? && @page @format.to_s.downcase @@ -39,10 +39,10 @@ module Precious def formats super(:markdown) end - + def default_markup Precious::App.settings.default_markup - end + end end end end diff --git a/lib/gollum/frontend/views/pages.rb b/lib/gollum/frontend/views/pages.rb index c6d6068c..91bc2f3a 100644 --- a/lib/gollum/frontend/views/pages.rb +++ b/lib/gollum/frontend/views/pages.rb @@ -10,8 +10,8 @@ module Precious def has_results !@results.empty? end - - def no_results + + def no_results @results.empty? end end diff --git a/lib/gollum/frontend/views/search.rb b/lib/gollum/frontend/views/search.rb index bea755a1..20f5c2a7 100644 --- a/lib/gollum/frontend/views/search.rb +++ b/lib/gollum/frontend/views/search.rb @@ -10,8 +10,8 @@ module Precious def has_results !@results.empty? end - - def no_results + + def no_results @results.empty? end diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index 6d3eb99d..b3f2d1b7 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -422,7 +422,7 @@ module Gollum # ######################################################################### - # Extract all sequence diagram blocks into the wsdmap and replace with + # Extract all sequence diagram blocks into the wsdmap and replace with # placeholders. # # data - The raw String data. @@ -436,7 +436,7 @@ module Gollum end end - # Process all diagrams from the wsdmap and replace the placeholders with + # Process all diagrams from the wsdmap and replace the placeholders with # the final HTML. # # data - The String data (with placeholders). @@ -487,7 +487,7 @@ module Gollum if Gem::Version.new(Redcarpet::VERSION) > Gem::Version.new("1.17.2") html_renderer = Redcarpet::Render::HTML.new({ :autolink => true, - :fenced_code_blocks => true, + :fenced_code_blocks => true, :tables => true, :strikethrough => true, :lax_htmlblock => true, diff --git a/lib/gollum/page.rb b/lib/gollum/page.rb index 9cb5d693..acd7c405 100644 --- a/lib/gollum/page.rb +++ b/lib/gollum/page.rb @@ -87,7 +87,7 @@ module Gollum # # filename - The string path or filename to strip # - # Returns the stripped String. + # Returns the stripped String. def self.strip_filename(filename) ::File.basename(filename, ::File.extname(filename)) end diff --git a/lib/gollum/pagination.rb b/lib/gollum/pagination.rb index b8fb518f..8ed2a336 100644 --- a/lib/gollum/pagination.rb +++ b/lib/gollum/pagination.rb @@ -19,7 +19,7 @@ module Gollum ([1, page.to_i].max - 1) * per_page end - # Fills in git-specific options for the log command using simple + # Fills in git-specific options for the log command using simple # pagination options. # # options - Hash of options: @@ -45,7 +45,7 @@ module Gollum self.class.page_to_skip(page) end - # Fills in git-specific options for the log command using simple + # Fills in git-specific options for the log command using simple # pagination options. # # options - Hash of options: diff --git a/lib/gollum/wiki.rb b/lib/gollum/wiki.rb index 10165d92..deb97c52 100644 --- a/lib/gollum/wiki.rb +++ b/lib/gollum/wiki.rb @@ -20,10 +20,10 @@ module Gollum # Sets the default email for commits. attr_accessor :default_committer_email - + # Array of chars to substitute whitespace for when trying to locate file in git repo. attr_accessor :default_ws_subs - + # Sets sanitization options. Set to false to deactivate # sanitization altogether. attr_writer :sanitization @@ -105,7 +105,7 @@ module Gollum self.default_ref = 'master' self.default_committer_name = 'Anonymous' self.default_committer_email = 'anon@anon.com' - + self.default_ws_subs = ['_','-'] # The String base path to prefix to internal links. For example, when set @@ -124,7 +124,7 @@ module Gollum # Gets the String directory in which all page files reside. attr_reader :page_file_dir - + # Gets the Array of chars to sub for ws in filenames. attr_reader :ws_subs @@ -225,10 +225,10 @@ module Gollum # :tree - Optional String SHA of the tree to create the # index from. # :committer - Optional Gollum::Committer instance. If provided, - # assume that this operation is part of batch of + # assume that this operation is part of batch of # updates and the commit happens later. # - # Returns the String SHA1 of the newly written version, or the + # Returns the String SHA1 of the newly written version, or the # Gollum::Committer instance if this is part of a batch update. def write_page(name, format, data, commit = {}) multi_commit = false @@ -239,9 +239,9 @@ module Gollum else Committer.new(self, commit) end - + filename = Gollum::Page.cname(name) - + committer.add_to_index('', filename, format, data) committer.after_commit do |index, sha| @@ -269,19 +269,19 @@ module Gollum # :tree - Optional String SHA of the tree to create the # index from. # :committer - Optional Gollum::Committer instance. If provided, - # assume that this operation is part of batch of + # assume that this operation is part of batch of # updates and the commit happens later. # - # Returns the String SHA1 of the newly written version, or the + # Returns the String SHA1 of the newly written version, or the # Gollum::Committer instance if this is part of a batch update. def update_page(page, name, format, data, commit = {}) name ||= page.name format ||= page.format dir = ::File.dirname(page.path) - dir = '' if dir == '.' + dir = '' if dir == '.' filename = (rename = page.name != name) ? Gollum::Page.cname(name) : page.filename_stripped - + multi_commit = false committer = if obj = commit[:committer] @@ -290,14 +290,14 @@ module Gollum else Committer.new(self, commit) end - + if !rename && page.format == format committer.add(page.path, normalize(data)) else committer.delete(page.path) committer.add_to_index(dir, filename, format, data, :allow_same_ext) end - + committer.after_commit do |index, sha| @access.refresh index.update_working_dir(dir, page.filename_stripped, page.format) @@ -318,10 +318,10 @@ module Gollum # :tree - Optional String SHA of the tree to create the # index from. # :committer - Optional Gollum::Committer instance. If provided, - # assume that this operation is part of batch of + # assume that this operation is part of batch of # updates and the commit happens later. # - # Returns the String SHA1 of the newly written version, or the + # Returns the String SHA1 of the newly written version, or the # Gollum::Committer instance if this is part of a batch update. def delete_page(page, commit) multi_commit = false @@ -628,7 +628,7 @@ module Gollum rescue Grit::GitRuby::Repository::NoSuchShaFound [] end - + def inspect %(#<#{self.class.name}:#{object_id} #{@repo.path}>) end diff --git a/test/test_committer.rb b/test/test_committer.rb index e9e41bbc..d8b046db 100644 --- a/test/test_committer.rb +++ b/test/test_committer.rb @@ -37,7 +37,7 @@ context "Wiki" do assert_equal committer, index end - res = wiki.write_page("Gollum", :markdown, "# Gollum", + res = wiki.write_page("Gollum", :markdown, "# Gollum", :committer => committer) assert_equal committer, res diff --git a/test/test_file.rb b/test/test_file.rb index af36b07c..4c187d92 100644 --- a/test/test_file.rb +++ b/test/test_file.rb @@ -1,5 +1,5 @@ # ~*~ encoding: utf-8 ~*~ -path = File.join(File.dirname(__FILE__), "helper") +path = File.join(File.dirname(__FILE__), "helper") require File.expand_path(path) context "File" do diff --git a/test/test_markup.rb b/test/test_markup.rb index d1dddd11..35e8f0d5 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -478,11 +478,11 @@ np.array([[2,2],[1,3]],np.float) test "sequence diagram blocks" do content = "a\n\n{{{default\nalice->bob: Test\n}}}\n\nb" output = /.*.*/ - + index = @wiki.repo.index index.add("Bilbo-Baggins.md", content) index.commit("Add sequence diagram") - + page = @wiki.page("Bilbo Baggins") rendered = Gollum::Markup.new(page).render assert_not_nil rendered.match(output) diff --git a/test/test_page.rb b/test/test_page.rb index 083a4338..5ba48a55 100644 --- a/test/test_page.rb +++ b/test/test_page.rb @@ -25,7 +25,7 @@ context "Page" do test "get existing page case insensitive" do assert_equal @wiki.page('Bilbo Baggins').path, @wiki.page('bilbo baggins').path end - + test "get existing page with hyphen" do assert_equal @wiki.page('Bilbo Baggins').path, @wiki.page('Bilbo-Baggins').path end @@ -33,19 +33,19 @@ context "Page" do test "get existing page with underscore" do assert_nil @wiki.page('Bilbo_Baggins') end - + test "get existing page where filename contains whitespace, with hypen" do assert_equal @wiki.page('Samwise Gamgee').path, @wiki.page('Samwise-Gamgee').path end - + test "get existing page where filename contains whitespace, with underscore" do assert_equal @wiki.page('Samwise Gamgee').path, @wiki.page('Samwise_Gamgee').path end - + test "get existing page where filename contains whitespace, with whitespace" do assert_equal @wiki.page('Samwise Gamgee').path, @wiki.page('Samwise Gamgee').path end - + test "get nested page" do page = @wiki.page('Eye Of Sauron') assert_equal 'Mordor/Eye-Of-Sauron.md', page.path diff --git a/test/test_wiki.rb b/test/test_wiki.rb index 651980c8..9fec5275 100644 --- a/test/test_wiki.rb +++ b/test/test_wiki.rb @@ -237,7 +237,7 @@ context "Wiki page writing with whitespace (filename contains whitespace)" do @path = cloned_testpath("examples/lotr.git") @wiki = Gollum::Wiki.new(@path) end - + test "update_page" do assert_equal :mediawiki, @wiki.page("Samwise Gamgee").format assert_equal "Samwise Gamgee.mediawiki", @wiki.page("Samwise Gamgee").filename @@ -249,7 +249,7 @@ context "Wiki page writing with whitespace (filename contains whitespace)" do assert_equal "h1. Samwise Gamgee2", @wiki.page("Samwise Gamgee").raw_data assert_equal "Samwise Gamgee.textile", @wiki.page("Samwise Gamgee").filename end - + test "update page with format change, verify non-canonicalization of filename, where filename contains Whitespace" do assert_equal :mediawiki, @wiki.page("Samwise Gamgee").format assert_equal "Samwise Gamgee.mediawiki", @wiki.page("Samwise Gamgee").filename @@ -261,7 +261,7 @@ context "Wiki page writing with whitespace (filename contains whitespace)" do assert_equal "h1. Samwise Gamgee", @wiki.page("Samwise Gamgee").raw_data assert_equal "Samwise Gamgee.textile", @wiki.page("Samwise Gamgee").filename end - + test "update page with name change, verify canonicalization of filename, where filename contains Whitespace" do assert_equal :mediawiki, @wiki.page("Samwise Gamgee").format assert_equal "Samwise Gamgee.mediawiki", @wiki.page("Samwise Gamgee").filename @@ -269,10 +269,10 @@ context "Wiki page writing with whitespace (filename contains whitespace)" do page = @wiki.page("Samwise Gamgee") @wiki.update_page(page, 'Sam Gamgee', :textile, "h1. Samwise Gamgee", commit_details) - assert_equal "h1. Samwise Gamgee", @wiki.page("Sam Gamgee").raw_data + assert_equal "h1. Samwise Gamgee", @wiki.page("Sam Gamgee").raw_data assert_equal "Sam-Gamgee.textile", @wiki.page("Sam Gamgee").filename end - + test "update page with name and format change, verify canonicalization of filename, where filename contains Whitespace" do assert_equal :mediawiki, @wiki.page("Samwise Gamgee").format assert_equal "Samwise Gamgee.mediawiki", @wiki.page("Samwise Gamgee").filename @@ -283,8 +283,8 @@ context "Wiki page writing with whitespace (filename contains whitespace)" do assert_equal :textile, @wiki.page("Sam Gamgee").format assert_equal "h1. Samwise Gamgee", @wiki.page("Sam Gamgee").raw_data assert_equal "Sam-Gamgee.textile", @wiki.page("Sam Gamgee").filename - end - + end + teardown do FileUtils.rm_rf(@path) end @@ -382,7 +382,7 @@ context "Wiki sync with working directory (filename contains whitespace)" do @wiki.delete_page(page, commit_details) assert !File.exist?(File.join(@path, "Samwise Gamgee.mediawiki")) end - + teardown do FileUtils.rm_r(@path) end @@ -401,7 +401,7 @@ context "page_file_dir option" do assert_equal "Hi", File.read(File.join(@path, @page_file_dir, "New-Page.md")) assert !File.exist?(File.join(@path, "New-Page.md")) end - + test "edit a page in a sub directory" do page = @wiki.page('foo') @wiki.update_page(page, page.name, page.format, 'new contents', commit_details)