(maint) Whitespace error cleanup commit

This patch simply cleans up a bunch of whitespace "errors"
(maint) Add trailing newlines to all files

This is a required step before doing

    perl -p -l -i -e s/foo/bar/ baz.rb
(maint) Standardize on #!/usr/bin/env ruby -S rspec

Mass search and replace in place using

  find * -type f -print0 | xargs -0 perl -p -l -i -e s/foo/bar/
(#2157) Rename collection loader methods

Without this patch the methods used to load facts do not match up with
the instance variables bound to the loaders themselves.

This patch simply renames the methods to match the internal and external
loader instance variable names.  This fixes the problem by making it
explicit which loader is being used when the methods are called on the
collection instance.

Paired-with: Hailee Kenney <hailee@puppetlabs.com>
(#2157) Make JsonParser always available but disabled without json gem

Without this patch the tests for the JsonParser class and the class
itself are not defined if the JSON gem is not available.  This is a
problem because the end user will consider this behavior a "silent
failure" if they place *.json files in the data directory and Facter
silently skips over them because the JSON library is not loadable.

This patch fixes the problem by always defining the JsonParser class.
The class itself will issue a warning when it tries to return results
for a JSON data file and the JSON library is not available.  This patch
also marks the json parser tests as pending if the json library is
unloadable.

This patch also fixes this error with command line option parsing:

    $ facter --json
    invalid option: --json

With this patch we're getting:

    $ facter --json
    You do not have JSON support in your version of Ruby. JSON output disabled

Paired-with: Hailee Kenney <hailee@puppetlabs.com>
(#2157) Make parser matcher work with Enumerable

Without this patch the parser matcher for filename extensions was locked
into the specific class of Array and String.  The implementation is
generally applicable to Enumerable and descendants of String though.

This patch simply changes the conditional checks to use the Ruby idiom
of comparing an object instances to parent classes using a case
statement.  This is equivalent to using kind_of? or is_a? which are
themselves synonyms.

diff --git a/lib/facter/util/parser.rb b/lib/facter/util/parser.rb
index 653f297..05dec2f 100644
--- a/lib/facter/util/parser.rb
+++ b/lib/facter/util/parser.rb
@@ -10,10 +10,11 @@ module Facter::Util::Parser
   # For support mutliple extensions you can pass an array of extensions as
   # +ext+.
   def self.extension_matches?(filename, ext)
-    if ext.class == String then
-      extension = ext.downcase
-    elsif ext.class == Array then
-      extension = ext.collect {|x| x.downcase }
+    extension = case ext
+    when String
+      ext.downcase
+    when Enumerable
+      ext.collect {|x| x.downcase }
     end
     [extension].flatten.to_a.include?(file_extension(filename).downcase)
   end
(#2157) Remove needless methods

This patch simply removes two methods that could not have worked if they
were ever invoked by the implementation.  They could not have worked
because the methods they were calling do not exist in the scope they
were being called.
(#2157) Change parser specs to not touch the filesystem

Without this patch all of the parser specification examples would create
files in the filesystem and read them back out or execute them.

This is a problem because the tests are much slower to run, much harder
to maintain, and there's crap left all over the place on my system.

This patch fixes the problem by changing the parser implementations to
load content on demand.  The spec tests themselves have been changed to
stub out the File.read method when appropriate.  We've also changed the
specifications to stub out Facter::Util::Resolution.exec

Paired-with: Hailee Kenney <hailee@puppetlabs.com>