(#13888) Fix self.instances for systemd service provider

Previously, attempting to run puppet resource service
on Fedora 16 resulted in a stack trace.

This commit resolves the issue so that self.instances should
work for systemd providers. The issue was that the instances
method was returning an Array of strings. This commit updates the
method to correctly return an Array of Provider instances.
(#12392): Colorize console output on Windows

Previously, `Puppet[:color]` was false on Windows, because the Windows
console does not support ANSI escape sequences.

The win32console gem converts ANSI color escape sequences into Win32
console API calls to change the foreground color, etc. If the output
stream has been redirected to a file, then the gem does not translate
the sequences, instead preserving them in the stream, as is done on
Unix.

To disable colorized output specify `color=false` or `--color=false` on
the command line.

This commit adds a `Puppet.features.ansicolor?` feature that defines
whether ANSI color escape sequences are supported. On Windows, this is
only true if the win32console gem can be loaded. On other platforms, the
value is always true.

The win32console gem will be packaged into the Windows installer, and
so, `Puppet[:color]` now defaults to true. If the gem can't be loaded,
then puppet will revert to its previous behavior.
Merge remote-tracking branch 'joshcooper/ticket/2.7.x/13956-colorize-windows' into 2.7.x

* joshcooper/ticket/2.7.x/13956-colorize-windows:
  (#12392): Colorize console output on Windows
maint: Fix pkg_spec test

The pkg_spec test meant to compare different hashes that were created
like

    Hash.new(:key1 => val1, :key2 => val2)

At least on ruby 1.9 this will always return an empty hash so the spec
tests didn't test correctness at all.

The fix uses just {:key1 => val1, :key2 => val2} to create the different
hashes so the comparsion does make sense again.
(#11004) Support Solaris 11 output in pkg package provider

Solaris 11 has merged the status field and the flag field when running
pkg list. So instead of

    SUNPython  2.5.5-0.111  installed  ----

a line may now look like

    compress/zip  3.0-0.175.0.0.0.2.537  i--

Change the regex in the parsing method to be able to correctly
interpret the output on Solaris 11 boxes
Just change Puppet settings in tests, rather than stubbing.

The stubbing in these tests blew up when an unexpected interaction happened;
it isn't clear why that was stubbed anyhow as we can just set settings
directly, to avoid exactly this failure mode.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Merge pull request #714 from daniel-pittman/maint/2.7.x/fix-busted-colour-tests

Maint/2.7.x/fix busted colour tests
(maint) Fix destinations_spec failure on windows

The CI spec tests for Puppet 2.7.x on windows are failing.  This is bad.

The reason they're failing is because we recently patched Puppet 2.7.x
to add a new feature, Puppet.features.ansicolor?  If this feature is
true then Puppet will output with ANSI colors.  If false, bare strings
are sent.

The existing destinations_spec test wasn't updated to reflect this new
feature.  The existing spec test assumes ANSI sequences will always be
sent if Puppet[:color] = true, but this is no longer the case because we
only send ANSI sequences if Puppet[:color] = true and
Puppet.features.ansicolor? is truthy.

This patch fixes the problem by stubbing Puppet.features.ansicolor? to
be true, matching up the spec expectation to the behavior of the system.
Just change Puppet settings in tests, rather than stubbing.

I'm following Daniel's lead from cde3bee0 on this one.

Stubbing Puppet.settings can cause bad side effects so let's just set
the setting and let the spec helper reset the settings system for us.
Merge remote-tracking branch 'jeffmccune/fix/2.7.x/specs_fail_without_win32console_gem' into 2.7.x

* jeffmccune/fix/2.7.x/specs_fail_without_win32console_gem:
  Just change Puppet settings in tests, rather than stubbing.
  (maint) Fix destinations_spec failure on windows

Signed-off-by: Jeff McCune <jeff@puppetlabs.com>
(#13956) Fix failing spec tests

The tests fail if the win32console gem isn't installed.  This patch fixes the
problem by stubbing out Puppet.features.ansicolor?
Merge branch 'fix/2.7.x/13956_fix_spec_tests_when_win32console_is_missing' into 2.7.x

* fix/2.7.x/13956_fix_spec_tests_when_win32console_is_missing:
  (#13956) Fix failing spec tests

Signed-off-by: Jeff McCune <jeff@puppetlabs.com>
(#11004) Fix regex for pkg provider line matching

The pkg provider uses the output of `pkg list` to check if a package is
present on the system. On solaris 10 the output showed a dedicated
`status` field to reflect `installed` or `known`. On Solaris 11 this
field is not present anymore, so it was marked as an optional field in
the regex that is used to parse the `pkg list` output. The field
delimiter (\s+) however were notaround not marked as optional so while

  library/python-2/pycurl-26 7.19.0.1-0.175.0.0.0.2.537  i--

worked

  library/python-2/pycurl-26 7.19.0.1-0.175.0.0.0.2.537 i--

did not (notice there is only one whitespace between version an flags).

Modify the regex so the second example is also interpreted correctly.
(#14200) Fix help face

This commit does the following:

1. Fix the help face so that--in the case where there exists both an
App and a Face by the same name, and the App is not just a stub for the
Face--help gives preference to the App instead of the Face.  The help
face (as a command line tool) is mostly going to be used to help
users navigate the other command line tools, so, e.g.,
"puppet help resource" should show help for the same tool that you
will get by running "puppet resource".  This was not the case
prior to this commit.
2. Get rid of the separation between faces and applications in the
help screen... making this distinction seems more confusing than
helpful to the users, and exposes implementation details that
users should not need to be concerned with.
3. Change all class names for Applications to conform to the
convention of "foo_bar" file names mapping to "FooBar" class names.
(#13429) refactor some settings initialization

This commit does the following:

* Move some of the settings initialization logic from
  Puppet::Util::CommandLine into the Puppet::Util::Settings class,
  so that it can be called by non-CommandLine code
* Rename / deprecate / clean up some methods related to parsing
  config files to try to promote a cleaner API for interacting with
  settings.
* Clean up / improve options for external tools to
  request puppet settings initialization.
(#13651) Use magenta, not purple in Facter::Util::Colors

This replaces all cases of the term 'purple' for the more standard 'magenta',
as per the naming used in most ANSI escape code charts.
Save face loader state in a different, more robust way.

The previous version mostly worked, but wound up showing an odd failure mode
under Ruby 1.9.3 where it didn't seem to restore state.  My best guess is that
something caused the older value to be closed over...

In any case this is an equally horrible, but more effective, way to resolve
the same problem.  I don't mind *like* either of them, but they work.

Really, the whole thing should be rethought - it may not actually be worth the
level of pain required to test the loader in the unit tests.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Merge branch 'bug/master/face-loading-order-dependent-failure'

This resolves the current build failure.
(#13349) Fix incorrect scope behavior

This commit resolves an error with class inclusion, via a resource
rather than the include statement, where if the class was a top-level
class, the class name would get resolved twice: once for adding the
resource (which happened correctly) and again when evaluating the class
(which would incorrectly re-check all the namespaces though with the ::
stripped off) finding the nested version.

Prior to this commit the following manifest would generate both notify
messages.  After this commit, the manifest only generates the top-level
notify messages.

class { 'foo::test': }
class foo::test {
	class { '::bar::baz': }
}
class bar::baz {
	notify { 'good!': }
}
class foo::bar::baz {
	notify { 'bad!': }
}
(#13349) Add integration test for incorrect scope