class MarkdownToTeX::Processor

Attributes

git_branch_name[R]
git_commit_line[R]
git_describe[R]
git_hash_wd_long[R]
git_status[R]
git_status_long[R]
git_wd_hash[R]
run_stamp[R]

Public Class Methods

new(options) click to toggle source
# File lib/markdown_to_tex/processor.rb, line 28
def initialize(options)
  @options = options
  @run_stamp = DateTime.now.to_s
  if @options[:git]
                            IO.popen("git branch -v --no-abbrev").each do |l|
                                    if l =~ /(\*|.)\s+(\S+)\s+([0-9a-f]+)\s(.*)/
                                            if $1 == "*"
                                                    @git_branch_name = $2
                                                    @git_wd_hash_long = $3
                                                    @git_wd_hash = @git_wd_hash_long[0,6]
                                                    @git_commit_line = $4
                                                    @git_commit_line.gsub!(/\#/, '\#')
                                                    @git_commit_line.gsub!(/\%/, '\%')
                                                    @git_commit_line.gsub!(/\[ahead.*\] /, '')
                                                    @git_status = @git_wd_hash + ": " + @git_commit_line
                                                    @git_status_long = @git_commit_line + '\\\\\\\\' + @git_wd_hash_long + '\\\\\\\\' + @git_branch_name
                                            end
                                    end
                            end

                            @git_describe = "(no names found for git describe)"

                            IO.popen("git describe --dirty --long").each do |l|
                                    if l =~ /(.*)/
                                            @git_describe = $1
                                    end
                            end

                            @macros = {
                                    "__OO2_RUN_STAMP__" => @run_stamp,
                                    "__OO2_GIT_DESCRIBE__" => @git_describe,
                                    "__OO2_GIT_STATUS__" => @git_status,
                                    "__OO2_GIT_STATUS_LONG__" => @git_status_long,
                                    "__OO2_GIT_HASH_LONG__" => @git_wd_hash_long
                            }
                    else
                      @macros = { }
                    end
end

Public Instance Methods

job_signature() click to toggle source
# File lib/markdown_to_tex/processor.rb, line 73
def job_signature
  s = []
  s << "% md2tex run at #{@run_stamp}"
  s << "% description: #{@git_describe}" if @git_describe
  s << "% revision: #{@git_wd_hash_long}" if @git_wd_hash_long
  if @git_commit_line
    s << "% commit log:"
    s << "% #{@git_commit_line}"
  end
  s.join("\n")+"\n"
end
process(text) click to toggle source
# File lib/markdown_to_tex/processor.rb, line 68
def process(text)
  @renderer = Redcarpet::Markdown.new(MarkdownToTeX::Renderer)
  TextProcessor.process_final(@renderer.render(text), @macros)
end