Skip to content

Commit

Permalink
Remove the redundant Pairtree::Obj#file method
Browse files Browse the repository at this point in the history
  • Loading branch information
mbklein committed Jun 10, 2011
1 parent dd1a188 commit 9888e0b
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions lib/pairtree/obj.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Pairtree
class Obj < ::Dir

# Alias certain class methods from File to instance methods of Pairtree::Obj
# Methods that require a filename, 0..n additional args, and maybe a block
FILE_METHODS = [:atime, :open, :read, :file?, :directory?, :exist?, :exists?, :file?, :ftype, :lstat,
:mtime, :readable?, :size, :stat, :truncate, :writable?, :zero?]
FILE_METHODS.each do |file_method|
Expand All @@ -11,12 +9,11 @@ class Obj < ::Dir
end
end

# Methods that require multiple filenames
def delete *args
File.delete(*(prepend_filenames(args)))
end
alias_method :unlink, :delete

def link *args
File.link(*(prepend_filenames(args)))
end
Expand All @@ -25,17 +22,10 @@ def rename *args
File.rename(*(prepend_filenames(args)))
end

# Methods that require non-filename args, followed by filenames
def utime atime, mtime, *args
File.utime(atime, mtime, *(prepend_filenames(args)))
end

# Alias File.open to Pairtree::Obj#file
def file fname, *args, &block
File.open(File.join(self.path, fname), *args, &block)
end

# Override Dir#entries and Dir#each to remove the dotfiles
def entries
super - ['.','..']
end
Expand All @@ -44,7 +34,6 @@ def each &block
super { |entry| yield(entry) unless entry =~ /^\.{1,2}$/ }
end

# Basic globbing
def glob(string, flags = 0)
entries.select { |entry| File.fnmatch(string, entry, flags) }
end
Expand Down

0 comments on commit 9888e0b

Please sign in to comment.