]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - lib/common/configuration.rb
Document everything with YARD and fix some bugs along the way.
[mailshears.git] / lib / common / configuration.rb
index caeab92a655a8dd92aa9b4dfa8784b2edc64ff14..b810b02f86c9d44711fbdae7836c391035d72c80 100644 (file)
@@ -1,10 +1,32 @@
 require 'yaml'
 
+# A configuration object that knows how to read options out of a file
+# in <tt>~/.mailshears.conf.yml</tt>. The configuration options can be
+# accessed via methods even though the internal representation is a
+# hash.
+#
+# === Examples
+#
+#   >> cfg = Configuration.new()
+#   >> cfg.i_mean_business()
+#   => true
+#
 class Configuration
 
+  # The default path to the user's configuration file.
   USERCONF_PATH = ENV['HOME'] + '/.mailshears.conf.yml'
+
+  # The hash structure in which we store our configuration options
+  # internally.
   @dict = {}
 
+
+  # Initialize a {Configuration} object with the config file at *path*.
+  #
+  # @param path [String] the path to the configuration file to
+  #   load. We check for a file named ".mailshears.conf.yml" in the
+  #   user's home directory by default.
+  #
   def initialize(path = USERCONF_PATH)
     cfg = default_configuration()
 
@@ -28,14 +50,26 @@ class Configuration
   end
 
 
+  # Replace all missing method calls with hash lookups. This lets us
+  # retrieve the values in our option hash by using methods named
+  # after the associated keys.
+  #
+  # @param sym [Symbol] the method that was called.
+  #
+  # @return [Object] the config file value associated with *sym*.
+  #
   def method_missing(sym, *args)
-    # Replace all missing method calls with dictionary lookups.
     return @dict[sym]
   end
 
 
   private;
 
+
+  # A default config hash.
+  #
+  # @return [Hash] sensible default configuration values.
+  #
   def default_configuration()
     d = {}