lib/giblish/buildindex.rb in giblish-0.2.10 vs lib/giblish/buildindex.rb in giblish-0.2.11

- old
+ new

@@ -20,22 +20,36 @@ attr_accessor :converted attr_accessor :title attr_accessor :doc_id attr_accessor :purpose_str attr_accessor :status - attr_accessor :relPath - attr_accessor :srcFile attr_accessor :history attr_accessor :error_msg attr_accessor :stderr + # these two members can have encoding issues when + # running in a mixed Windows/Linux setting. + # that is why the explicit utf-8 read methods are + # provided. + attr_accessor :relPath + attr_accessor :srcFile + def relPath_utf8 + return nil if @relPath.nil? + @relPath.to_s.encode("utf-8") + end + + def srcFile_utf8 + return nil if @srcFile.nil? + @srcFile.to_s.encode("utf-8") + end + def initialize @history = [] end def to_s - "DocInfo: title: #{@title} srcFile: #{@srcFile}" + "DocInfo: title: #{@title} srcFile: #{srcFile_utf8}" end end # Base class with common functionality for all index builders class BasicIndexBuilder @@ -171,12 +185,12 @@ def format_title_and_ref(doc_info) unless doc_info.title @nof_missing_titles += 1 doc_info.title = "NO TITLE FOUND (#{@nof_missing_titles}) !" end - return "<<#{doc_info.relPath}#,#{doc_info.title}>>", - "<<#{Giblish.to_valid_id(doc_info.title)},details>>\n" + return "<<#{doc_info.relPath_utf8}#,#{doc_info.title}>>".encode("utf-8"), + "<<#{Giblish.to_valid_id(doc_info.title)},details>>\n".encode("utf-8") end # Generate an adoc string that will display as # DocTitle (warn) details # Where the DocTitle and details are links to the doc itself and a section @@ -204,11 +218,11 @@ d = node.data if d.converted tree_entry_converted prefix_str, d else # no converted file exists, show what we know - "#{prefix_str} FAIL: #{d.srcFile} <<#{d.srcFile},details>>\n" + "#{prefix_str} FAIL: #{d.srcFile_utf8} <<#{d.srcFile_utf8},details>>\n" end end def generate_tree # build up tree of paths @@ -243,15 +257,15 @@ "" end def generate_detail_fail(d) <<~FAIL_INFO - === #{d.srcFile} + === #{d.srcFile_utf8} Source file:: - #{d.srcFile} + #{d.srcFile_utf8} Error detail:: #{d.stderr} '''' @@ -260,19 +274,19 @@ end def generate_detail(d) # Generate detail info <<~DETAIL_SRC - [[#{Giblish.to_valid_id(d.title)}]] - === #{d.title} + [[#{Giblish.to_valid_id(d.title.encode("utf-8"))}]] + === #{d.title.encode("utf-8")} #{d.purpose_str} #{generate_conversion_info d} Source file:: - #{d.srcFile} + #{d.srcFile_utf8} #{generate_history_info d} '''' @@ -342,23 +356,16 @@ info.srcFile = Pathname.new(info.srcFile).relative_path_from(@git_repo_root).to_s # Get the commit history of the doc # (use a homegrown git log to get 'follow' flag) gi = Giblish::GitItf.new(@git_repo_root) - gi.file_log(info.srcFile.to_s).each do |i| + gi.file_log(info.srcFile_utf8).each do |i| h = DocInfo::DocHistory.new h.date = i["date"] h.message = i["message"] h.author = i["author"] info.history << h end - # @git_repo.log(50).object("*#{info.srcFile}").each do |l| - # h = DocInfo::DocHistory.new - # h.date = l.date - # h.message = l.message - # h.author = l.author.name - # info.history << h - # end end protected def generate_header