Sha256: 2d047bb656811ab110c5a0bb1e9b2c7bb60ce88dc88a221ba88512a5fd129bb0
Contents?: true
Size: 888 Bytes
Versions: 3
Compression:
Stored size: 888 Bytes
Contents
module Gitdocs class Docfile attr_reader :parent, :path, :name, :author, :modified 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 file? true end end class Docdir < Docfile attr_accessor :subdirs attr_accessor :files def initialize(path) super @subdirs = [] @files = [] end def items (subdirs + files).sort { |a,b| a.name.downcase <=> b.name.downcase } end def parent=(dir) dir.subdirs.push(self) if dir end def file? false end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gitdocs-0.4.7 | lib/gitdocs/docfile.rb |
gitdocs-0.4.6 | lib/gitdocs/docfile.rb |
gitdocs-0.4.5 | lib/gitdocs/docfile.rb |