(#18986) Write to the console using Unicode Win32 APIs

Previously, puppet on windows could not output unicode characters to the
console reliably, such as the box drawing characters used by the module
tool when displaying dependencies.

Ruby 1.8 uses the ANSI Win32 APIs, e.g. WriteConsole, to write to the
console. However, it uses the current console codepage. So if the current
codepage cannot handle the unicode character we're trying to write, e.g.
cp1252, then it displays garbage.

Ruby 1.9 uses the Unicode Win32 APIs, e.g. WriteConsoleW. As such, it can
correctly write unicode output, without being sensitive to the current
codepage.

However, because puppet writes ANSI escape sequences, we use the
win32console gem to color the output. This win32console gem redefines the
stdout and stderr streams to accomplish this, and sadly uses ANSI versions
of Win32 APIs to write to the console. So it has the same problems as ruby
1.8.

This commit overrides the win32console classes, Console and IO, to ensure
the Unicode APIs are used. This enables us to display ANSI escape
sequences and unicode characters that may not be compatible with the
current codepage.

Longer term we should think about removing win32console gem altogether and
moving to ruby 1.9, as these hacks would no longer be required. Though
doing so would mean losing color output, or taking more drastic measures
like ansicon.
(#14985) Fix hiera lookup for calling_module and calling_class
(#14985) Fix hiera does not lookup calling_class and calling_module
(#14985) Fix test, return downcase values and check for nil scope.source
(#14985) Fix exception when nil is returned from inner scope
(#14985) Ensure hostclass finder is private

The nested definition of the recurse_for_hostclass method caused that
method to be created lazily and as a public method. By pulling it out to
be declared outside the calling method it can be made private and
created only once. It has also been renamed to show the intention
instead of the mechanism (recursion).
(Maint) Require Hiera::Config to avoid warning

When the hiera tests were run alone the puppet_backend_spec.rb issued a
warning:

  /Users/andy/work/puppet/spec/unit/hiera/backend/puppet_backend_spec.rb:25:
  warning: toplevel constant Config referenced by Hiera::Config

The warning was caused by a reference to Hiera::Config where Hiera was
defined, but Hiera::Config was not. This resulted in getting the top
level Config constant and a warning being issued. By requiring
hiera/config this problem is avoided.
(Maint) Use real scope in testing

Using the real scope is completely possible in these tests since it has
no dependencies on the outside world and is essentially a value object.
Therefore it should be used in the tests to make them more
comprehensive.
(#14985) Describe behavior of calling_(class|module)

The original tests for calling_module and calling_class used a mock,
when this is really just a value that can be setup. It also didn't
separate out and describe the behavior of the two pieces in the
variations in which they can come up. Specifically the difference
between a `define` and a `class` for the meaning of calling_class.
(Maint) Clarify scope lookup rules

The lookup rules for variables in the puppet language have always been a
bit hard for me to understand. I knew the rules as

  the current scope => inherited => node => topscope

but the code never seemed to express that clearly. This refactors the
`lookupvar` method to extract out a few pieces to make that clearer.
Specifically the mechanism for walking from a class to the enclosing
node (which is why this gets the name "two-step" by some people) has
been called out as a lookup of the `enclosing_scope`. Calling out the
enclosing scope as a specific lookup allows for getting rid of the
`:origin` part of the options hash, which was to provide a mechanism for
skipping over some scope objects.

This also tries to remove some duplication that was occurring because
there was not a consistent symbol table concept. It turns out that the
existing `Ephemeral` fits that nicely and so it now used as the scope's
symbol table as well as for the ephemeral variables.
(#14985) Preserve casing on looked up values

The initial fix for looked up values downcased everything that was being
returned. This causes problems when the data is not a string that the
previous behavior was to only do this for the calling_class and
calling_module. This commit us returns to that behavior.
(#15791) isolate deterministic random function

We should not fiddle with the global seed, as other people
might still depend on Kernel.rand() not being that deterministic
as it is the idea with the fqdn_rand function.

However, as ruby < 1.9.2 does not provide such a nice solution, as
a dedicated Random class we simply call Kernel.srand() again on ruby
< 1.9.2 -> Reinitialize with a less deterministic seed.
(Maint) Extract constant strings as constants
(maint) Add vendoring support to puppet

This adds vendoring support to puppet based on the implementation in
mcollective.
(#11331) Add vendoring of rgen to puppet.

This adds the RGen gem 0.6.1 in transition to not yet released
RGen gem 0.6.2.
Add recognizable prefix string to profiling log statements

This commit simply prefixes the profiling log strings with
the word "PROFILE", so that they are easy to grep for in
the output.
Improve CVE 2013 1654 SSLv2 Downgrade Master test

Previously we were only checking for the applicability of the master
(since we're testing the master), but we run the check from an agent.
This ensures the agent we run the check from has the necessary openssl
client for the test.

Signed-off-by: Justin Stoller <justin@puppetlabs.com>
Merge branch 'justinstoller-maint/2.7.x/improve_downgrade_master_test' into 2.7.x

* justinstoller-maint/2.7.x/improve_downgrade_master_test:
  Improve CVE 2013 1654 SSLv2 Downgrade Master test

closes #1548
Merge branch '2.7.x' into 3.1.x

* 2.7.x:
  Improve CVE 2013 1654 SSLv2 Downgrade Master test
Merge branch '3.1.x'

* 3.1.x:
  Improve CVE 2013 1654 SSLv2 Downgrade Master test