Sha256: f48464a870b01c889d85f53bad4d0455ba239a0ea1817b482920062b17f7febb

Contents?: true

Size: 536 Bytes

Versions: 5

Compression:

Stored size: 536 Bytes

Contents

module Gitdocs
  class Docfile
    attr_accessor :parent
    attr_reader :path, :name

    def initialize(path)
      @path = path
      @parent = File.dirname(path)
      @name = File.basename(path)
    end

    # within?("parent", "/root/path") => "/root/path/parent"
    def within?(dir, root)
      expanded_root = File.expand_path(dir, root)
      File.expand_path(@parent, root) == expanded_root ||
        File.expand_path(@path, root).include?(expanded_root)
    end

    def dir?
      File.directory?(@path)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gitdocs-0.5.0.pre6 lib/gitdocs/docfile.rb
gitdocs-0.5.0.pre5 lib/gitdocs/docfile.rb
gitdocs-0.5.0.pre3 lib/gitdocs/docfile.rb
gitdocs-0.5.0.pre2 lib/gitdocs/docfile.rb
gitdocs-0.5.0.pre1 lib/gitdocs/docfile.rb