class Pathname

Public Instance Methods

add(str)
Alias for: append
append(str) click to toggle source
# File vendor/qwik/lib/qwik/util-pathname.rb, line 34
def append(str)
  return self.open('ab') {|f| f.print str }
end
Also aliased as: add
check_directory() click to toggle source
# File vendor/qwik/lib/qwik/util-pathname.rb, line 43
def check_directory
  if self.exist?
    if ! self.directory?
      raise "#{self} is not directory. failed."
    end
    return    # The directory is already exist.
  end
  self.mkpath
end
erase_all() click to toggle source
# File vendor/qwik/lib/qwik/util-pathname.rb, line 53
def erase_all
  self.each_entry {|file|
    base = file.to_s
    next if base == '.' || base == '..'
    f = self + file
    if f.directory?
      f.erase_all
      next
    end
    if f.exist?
      f.unlink
    end
  }
end
erase_all_for_test() click to toggle source
# File vendor/qwik/lib/qwik/test-module-path.rb, line 62
def erase_all_for_test
  self.each_entry {|file|
    base = file.to_s
    next if base == '.' || base == '..'

    f = self + file

    if f.directory?
      f.erase_all_for_test   # Recursive.
      next
    end

    if f.exist?
      f.unlink
    end
  }
end
ext() click to toggle source
# File vendor/qwik/lib/qwik/util-pathname.rb, line 25
def ext
  return (self.extname.to_s).sub(/\A\./, '')
end
get_first() click to toggle source
# File vendor/qwik/lib/qwik/util-pathname.rb, line 39
def get_first
  return self.open('rb') {|f| f.gets }
end
path() click to toggle source
# File vendor/qwik/lib/qwik/util-pathname.rb, line 16
def path
  return self
end
put(str)
Alias for: write
remove_directory() click to toggle source
# File vendor/qwik/lib/qwik/util-pathname.rb, line 68
def remove_directory
  if self.exist?
    if self.directory?
      self.rmtree
      self.rmdir if self.directory?
    else
      raise "#{self} is not directory. failed."
    end
  end
end
setup() click to toggle source
# File vendor/qwik/lib/qwik/test-module-path.rb, line 80
def setup
  self.teardown if self.directory?
  self.check_directory
end
teardown() click to toggle source
# File vendor/qwik/lib/qwik/test-module-path.rb, line 85
def teardown
  unless self.directory?
    return
  end
  self.erase_all_for_test
end
to_win_dir() click to toggle source

/cygdrive/c -> c:

# File vendor/qwik/lib/qwik/util-pathname.rb, line 21
def to_win_dir
  return self.to_s.sub(%r!\A/cygdrive/(\w)!) {|a| $1+':' }
end
write(str) click to toggle source
# File vendor/qwik/lib/qwik/util-pathname.rb, line 29
def write(str)
  return self.open('wb') {|f| f.print str }
end
Also aliased as: put

Private Instance Methods

erase_all_db(f) click to toggle source
# File vendor/qwik/lib/qwik/test-module-path.rb, line 101
def erase_all_db(f)
  return unless f.exist?
  db = BDB::Hash.new(f.to_s, nil, 0)
  db.each {|k, v|
    db[k] = nil
  }
  db.close
end
erase_db(f) click to toggle source

test-module-bdb

# File vendor/qwik/lib/qwik/test-module-path.rb, line 93
def erase_db(f)
  begin
    erase_all_db(f)
  rescue => e
    return
  end
end