Sha256: b1045392a8705f8213dce4eba2ff9a25f864202b425a94afbb77b9059392bfb0

Contents?: true

Size: 733 Bytes

Versions: 6

Compression:

Stored size: 733 Bytes

Contents

require 'pathname'
require 'mime/types'

module Markout

  class Document

    attr_reader :path, :base_path, :filename, :content, :history

    def initialize(path, options={ :history => true })
      @path      = File.expand_path(path)
      @base_path = Pathname.new( File.dirname(@path) )
      @filename  = File.basename(path)
      @options   = options
      raise FileNotFound, "File #{@path} not found" unless File.exist?(@path)
      raise FileNotSupported, "File #{@path} is not plain text" unless MIME::Types.type_for(@path).any? { |type| type.media_type == 'text' }
      @content   = File.read(path)
      @history   = Markout::History.new(self, :git_dir => @options[:git_dir]) if @options[:history]
    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
karmi-markout-0.1.1 lib/markout/document.rb
karmi-markout-0.1.2 lib/markout/document.rb
karmi-markout-0.1.3 lib/markout/document.rb
karmi-markout-0.1.5 lib/markout/document.rb
karmi-markout-0.1.6 lib/markout/document.rb
karmi-markout-0.1.7 lib/markout/document.rb