]> gitweb.michael.orlitzky.com - mailshears.git/commitdiff
Begin updating docs; remove two unused exit codes.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 6 Nov 2015 14:55:02 +0000 (09:55 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 6 Nov 2015 14:55:02 +0000 (09:55 -0500)
lib/common/errors.rb
lib/common/exit_codes.rb
lib/common/filesystem.rb
lib/mailshears.rb

index 6a9927af8070e561e21896c85ad7073ff00fb32e..7e2bd505ed9a5ffb888fa7cb2cf7f048dc7d3a5d 100644 (file)
@@ -1,21 +1,15 @@
-# Username is syntactically invalid.
-class InvalidUserError < StandardError
-end
+# An error indicating that a username is syntactically invalid.
+class InvalidUserError < StandardError; end
 
 
-# Domain is syntactically invalid.
-class InvalidDomainError < StandardError
-end
+# An error indicating that a domain is syntactically invalid.
+class InvalidDomainError < StandardError; end
 
 
+# An error indicating that a user does not exist.
+class NonexistentUserError < StandardError; end
 
 
-# Used to indicate that an user does not exist.
-class NonexistentUserError < StandardError
-end
+# An error indicating that a domain does not exist.
+class NonexistentDomainError < StandardError; end
 
 
-# Used to indicate that a domain does not exist.
-class NonexistentDomainError < StandardError
-end
-
-
-# When you try to rename a user on top of one that already exists.
-class UserAlreadyExistsError < StandardError
-end
+# An error indicating that some user already exists. For example, if
+# one tries to rename a user and the destination user already exists.
+class UserAlreadyExistsError < StandardError; end
index a81067bc089e1b3a9f288f6a9fd8e5e7f94a6fd5..b7928a74eb4b7c61733623536a236f676742bf33 100644 (file)
@@ -1,6 +1,7 @@
 module ExitCodes
 module ExitCodes
+  # Everything went better than expected.
   SUCCESS = 0
   SUCCESS = 0
-  FILESYSTEM_ERROR = 1
-  DATABASE_ERROR = 2
-  BAD_COMMAND_LINE = 3
+
+  # The command-line arguments were not what we expected.
+  BAD_COMMAND_LINE = 1
 end
 end
index 72ff901dd1e0dc602369c6a795a13d0164ab30d5..b44e52ce3979506a82155a9db9ac658257c6b19a 100644 (file)
@@ -1,16 +1,36 @@
 class Filesystem
 class Filesystem
+  # Convenience methods for working with the filesystem. This class
+  # only provides static methods, to be used analogously to the File
+  # class (for example, File.directory?).
 
 
-  def self.begins_with_dot(path)
+
+  # Return whether or not the given path begins with a dot (ASCII
+  # period).
+  #
+  # @param path [String] the path whose first character you want to check.
+  #
+  # @return [Boolean] whether or not *path* begins with an ASCII period.
+  #
+  def self.begins_with_dot?(path)
     return (path[0..0] == '.')
   end
 
     return (path[0..0] == '.')
   end
 
+
+  # Get a list of all real subdirectories of the given directory.
+  #
+  # @param dir [String] the directory whose subdirectories you want.
+  #
+  # @return [Array<String>] a list of subdirectories of *dir*, not
+  #   including the pseudo-directories "." and ".." (the current/parent
+  #   directories).
+  #
   def self.get_subdirs(dir)
     subdirs = []
 
     Dir.open(dir) do |d|
       d.each do |entry|
         relative_path = File.join(dir, entry)
   def self.get_subdirs(dir)
     subdirs = []
 
     Dir.open(dir) do |d|
       d.each do |entry|
         relative_path = File.join(dir, entry)
-        if (File.directory?(relative_path) and not begins_with_dot(entry))
+        if File.directory?(relative_path) and not self.begins_with_dot?(entry)
           subdirs << entry
         end
       end
           subdirs << entry
         end
       end
index e5f2e6e706750d5d4011d48e15cf538172f0baf9..55a87f8324918f317b8c4b893ef752165f77bad8 100644 (file)
@@ -1,6 +1,5 @@
-# Load the rest of the code we'll use. This loads only what we'll need
-# in the executable. The library files are supposed to require what
-# they need.
+# Load only the files needed by our executable. The library files are
+# supposed to require what they need themselves.
 
 require 'common/configuration'
 require 'common/errors'
 
 require 'common/configuration'
 require 'common/errors'