(#15398) fix typo in Scope#number? float detection regex

This allowed incorrect numbers (like 2:.34) to be recognized as
floats (with an incorrect value).

Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Implement Symbol#intern when it is missing.

In order to reduce use of `Puppet::Util#symbolize` in the code - which is
called some 90,000 times in a real-world run - being able to intern a symbol
is convenient.

This is a simple implementation: it just returns itself.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Use `intern` rather than `symbolize` in Puppet::Type

The cost of symbolize is ~ 50 percent higher than the cost of intern, when
applied to either a string or a symbol.  Given this is called some 90,000
times in my real world test run, that adds up to a non-zero amount of
wasted time.

Sadly, this only works out at 0.15 seconds real time reduction, but it is
better than nothing - and takes out 85,000 extra calls.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Eliminate `symbolize` everywhere, and remove it.

The whole `symbolize` API was confusing and complex: because it didn't do any
type enforcement, just passed through arbitrary data, we had very unclear API
in a whole pile of places.

This replaces that method entirely with a more rigid definition: we intern in
a bunch of places, add the occasional clear failure mode, and then delete the
original definition.

This eliminates one point of complexity from the codebase.

(These other uses have no notable performance penalty, just code complexity
 and clarity issues.)

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Implement `Fixnum#ord` for Ruby 1.8.5

This is a compatibility method for addressing characters introduced in 1.8.7;
we also need the same compatibility back to 1.8.5, so we monkey-patch it in
when it isn't already there.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Merge pull request #949 from daniel-pittman/bug/3.x/fix-missing-ord-on-185

Implement `Fixnum#ord` for Ruby 1.8.5
Merge remote-tracking branch 'origin/2.7.x' into 3.x
zaml: handle multi-line map keys and array values correctly.

The ZAML encoder had some bugs when handling multi-line string values in map
keys and arrays. It also changed behaviour slightly when I modified it for
speed, causing a regression in another case that was correctly handled.

This fixes that, as well as making more robust the process of tagging
structural keys that can span multiple lines.

It also adds some tests to validate that we don't regress again.

This fixes a pre-existing bug in the encoder, as well as my regression.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Merge branch 'tickets/3.0.x/15398' of https://github.com/masterzen/puppet into 3.x

* 'tickets/3.0.x/15398' of https://github.com/masterzen/puppet:
  (#15398) fix typo in Scope#number? float detection regex

Conflicts:
	lib/puppet/parser/scope.rb
Merge pull request #952 from daniel-pittman/bug/3.x/zaml-map-key-with-embedded-newline-corruption

zaml: handle multi-line map keys and array values correctly.
Fixed #14975 - Fixed incorrect help text in puppet doc application
Update main readme to have links to contrib and dev docs

Our README currently rendered on github doesn't show people how get into
the contribution process.  I've added a very small section to point to
the other doc files that exist in our repositories.  This was based on
feedback at the Community Leadership Summit 2012.

Signed-off-by: Michael Stahnke <stahnma@puppetlabs.com>
Merge branch 'maint/master/conditional-pending' of https://github.com/joshcooper/puppet into 3.x

* 'maint/master/conditional-pending' of https://github.com/joshcooper/puppet:
  Maint: Actually execute the tests on non-windows platforms
  (#14441) Require instrumentation indirections
  Make Puppet's gem package task the same name as other Puppetlabs' projects
  (maint) Make 3.0.x work with rspec-puppet
  Re-enable this test to work on windows
  Change one test to use the new confine syntax.
Switch Rakefile off deprecated rake/gempackagetask

Fixes #15463
Merge pull request #932 from daniel-pittman/perf/3.x/symbolize-is-costly-compared-to-intern

Perf/3.x/symbolize is costly compared to intern
tidy.rb: Added info about the default value of 'type' to the doc.
Implement a JSON file terminus to mirror YAML.

For a bunch of local caching and retrieval, Puppet uses a YAML backed local
file terminus to store, retrieve, and search content.  This is great, but the
YAML encoder is super-slow and painfully odd across Ruby versions.

Our PSON support is much more reliable, as well as substantially faster, and
is pretty much as capable.  There isn't much reason, other than migration
cost, to prefer YAML to PSON encoding of data transfer documents.

Having a JSON terminus allows the user to configure, manually, the use of JSON
everywhere that we previously used YAML.  While this doesn't bring the
benefits out of the box, it allows users to select this while we flush out any
lingering bugs left in the support code and system.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Add catalog JSON terminus to improve performance.

This adds a JSON backed catalog terminus, so that the catalog cache can
migrate away from YAML to a faster and more stable storage format.

This is not the default: that still falls to old, trustable YAML which we know
to be stable and effective.

To enable this, edit your routes.yaml file and add:

    agent:
      catalog:
        cache: json

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Merge pull request #930 from daniel-pittman/perf/3.x/2892-json-terminus-for-catalog-cache

#2892: json terminus for catalog cache
(maint) Add Puppet::Parser::Scope.new_for_test_harness

Without this patch there is no clear path into the internals of Puppet
for third parties who intended to exercise Puppet parser functions.

This is a problem because many 3rd parties, such as the stdlib module
and hiera-puppet extend Puppet using parser functions.  These modules
create instances of Puppet::Parser::Scope objects in their test harness
to invoke the parser functions they're testing.

The specific problem this patch means to address is the dependency of
Puppet modules on the specific method signature of
Puppet::Parser::Scope#initialize  This patch addresses the problem my
adding a new method, Puppet::Parser::Scope.new_for_test_harness which
accepts a single argument, the node name, and returns a scope instance
bound to a compiler instance and a node instance.

The common spec helper should be augmented to invoke this method.  All
Puppet modules that exercise parser functions should then decouple
themselves from Puppet itself and instead depend upon the common spec
helper behavior.

Reviewed-by: Patrick Carlisle <patrick@puppetlabs.com>