Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: dagolden/data-guid-any
base: 727c742a0a
...
head fork: dagolden/data-guid-any
compare: 67703d0c95
Checking mergeability… Don't worry, you can still create the pull request.
  • 14 commits
  • 28 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 18, 2012
@dagolden dzilify distribution 85f3fe8
@dagolden fix up dzilification 50c9799
@dagolden add meta files 16d716c
@dagolden ensure LibUUID returns version 1 GUID as documented 9d0edaf
@dagolden Revise list of modules and generator subs
All modules now explictly call uc() to be sure return is uppercase.

Added Data::UUID::MT and UUID::Tiny as potential generators.
87b2006
@dagolden convert test to done_testing style ea92063
@dagolden massive refactoring of GUID provider selection
- The ordering has changed and there are now separate functions for
  generic GUID (any supported type), v1 and v4 type GUIDs.

- UUID::Generator::PurePerl has been dropped.

- The uuid binary is now preferred to pure-perl UUID::Tiny.

- Data::UUID::MT is now preferred, since it offers good speed and the
  best control.
296e3f2
@dagolden updated Changes 92b2dbc
@dagolden updated README.pod 3fc47dd
@dagolden revise dist.ini for Makefile.PL generation and other fixes fef0023
@dagolden revise custom Makefile plugin 3554e5b
@dagolden make critic/spelling test pass 8f0ecdc
@dagolden updated docs 1d863a2
@dagolden bump Changes 67703d0
View
2  .gitignore
@@ -12,3 +12,5 @@
/pm_to_blib
/PM_to_blib
/MYMETA.yml
+/Data-GUID-Any*
+/.build
View
51 Build.PL
@@ -1,51 +0,0 @@
-# Copyright (c) 2009 by David Golden. All rights reserved.
-# Licensed under Apache License, Version 2.0 (the "License").
-# You may not use this file except in compliance with the License.
-# A copy of the License was distributed with this file or you may obtain a
-# copy of the License from http://www.apache.org/licenses/LICENSE-2.0
-
-use 5.006;
-use strict;
-use warnings;
-use lib 'inc';
-eval "require Pod::WikiDoc";
-my $class = $@ ? "Module::Build" : "Module::Build::WikiDoc";
-eval "require $class";
-
-my @maybe_reqs;
-
-unless ( eval { require 'lib/Data/GUID/Any.pm'; 1 } ) {
- push @maybe_reqs, 'Data::GUID', 0;
-}
-
-my $build = $class->new(
- module_name => 'Data::GUID::Any',
- dist_author => 'David Golden <dagolden@cpan.org>',
- license => 'apache',
- create_readme => 1,
- requires => {
- 'perl' => 5.006,
- 'base' => 0,
- 'Exporter' => 0,
- 'File::Spec' => 3.12,
- @maybe_reqs,
- },
- build_requires => {
- 'File::Find' => 0,
- 'Test::More' => 0.62,
- },
- meta_add => {
- configure_requires => {
- 'Module::Build' => 0.30
- },
- no_index => {
- directory => [ qw/ examples inc t xt /],
- },
- resources => {
- repository => "http://github.com/dagolden/data-guid-any/",
- bugtracker => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-GUID-Any",
- },
- },
-);
-$build->create_build_script;
-
View
25 Changes
@@ -1,12 +1,23 @@
-# Changes
-# Copyright (c) 2009 by David Golden. All rights reserved.
-# Licensed under Apache License, Version 2.0 (the "License").
-# You may not use this file except in compliance with the License.
-# A copy of the License was distributed with this file or you may obtain a
-# copy of the License from http://www.apache.org/licenses/LICENSE-2.0
-
Revision history for Data-GUID-Any
+{{$NEXT}}
+
+0.003 2012-04-18 12:59:58 America/New_York
+
+ - The ordering of GUID providers has changed and there are now
+ separate functions for generic GUID (any supported type), v1 and v4
+ type GUIDs.
+
+ - Data::UUID::MT is now preferred, since it offers good speed and the
+ best control.
+
+ - The uuid binary is now preferred to pure-perl UUID::Tiny.
+
+ - UUID::Generator::PurePerl has been dropped as the author has listed
+ it as deprecated.
+
+ - distribution converted to Dist::Zilla style
+
0.002 Fri Apr 10 10:19:55 EDT 2009
- added UUID::Generator::PurePerl
- cleaned up some internals
View
28 INSTALL
@@ -1,28 +0,0 @@
-# Copyright (c) 2009 by David Golden. All rights reserved.
-# Licensed under Apache License, Version 2.0 (the "License").
-# You may not use this file except in compliance with the License.
-# A copy of the License was distributed with this file or you may obtain a
-# copy of the License from http://www.apache.org/licenses/LICENSE-2.0
-
-INSTALLATION
-
-This distribution may be installed via one of the following
-methods:
-
-
-1. If Build.PL exists and Module::Build is installed:
-
- perl Build.PL
- perl Build
- perl Build test
- perl Build install
-
-2. If Makefile.PL exists:
-
- perl Makefile.PL
- make
- make test
- make install
-
-If you are on a Windows machine you should use
-'nmake' or 'dmake' rather than 'make'.
View
201 LICENSE
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
View
24 MANIFEST
@@ -1,24 +0,0 @@
-Build.PL
-Changes
-inc/Module/Build/WikiDoc.pm
-INSTALL
-lib/Data/GUID/Any.pm
-lib/Data/GUID/Any.pod
-LICENSE
-MANIFEST
-MANIFEST.SKIP
-META.yml
-README
-t/00-compile.t
-t/01-Data-GUID-Any.t
-t/bin/uuid
-t/Util.pm
-Todo
-xt/critic.t
-xt/kwalitee.t
-xt/metayml.t
-xt/perlcriticrc
-xt/pod-coverage.t
-xt/pod-format.t
-xt/spelling.t
-xt/stopwords.txt
View
34 MANIFEST.SKIP
@@ -1,34 +0,0 @@
-# Copyright (c) 2009 by David Golden. All rights reserved.
-# Licensed under Apache License, Version 2.0 (the "License").
-# You may not use this file except in compliance with the License.
-# A copy of the License was distributed with this file or you may obtain a
-# copy of the License from http://www.apache.org/licenses/LICENSE-2.0
-
-# Version control files and dirs.
-\bRCS\b
-\bCVS\b
-,v$
-.svn/
-^.git
-
-# Generated by Perl module toolchain
-^MANIFEST\.(?!SKIP)
-^Makefile$
-^blib/
-^blibdirs$
-^PM_to_blib$
-^MakeMaker-\d
-^Build$
-^_build
-^cover_db
-^.*\.bat$
-^MYMETA.yml$
-
-# Temp, old, vi and emacs files.
-~$
-\.old$
-\#\.*\#$
-\.\#$
-\.swp$
-\.bak$
-^pod.*\.tmp$
View
79 META.json
@@ -0,0 +1,79 @@
+{
+ "abstract" : "Generic interface for GUID/UUID creation",
+ "author" : [
+ "David Golden <dagolden@cpan.org>"
+ ],
+ "dynamic_config" : "1",
+ "generated_by" : "Dist::Zilla version 4.300014, CPAN::Meta::Converter version 2.120630",
+ "license" : [
+ "apache_2_0"
+ ],
+ "meta-spec" : {
+ "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+ "version" : "2"
+ },
+ "name" : "Data-GUID-Any",
+ "no_index" : {
+ "directory" : [
+ "t",
+ "xt",
+ "examples",
+ "corpus"
+ ],
+ "package" : [
+ "DB"
+ ]
+ },
+ "prereqs" : {
+ "configure" : {
+ "requires" : {
+ "ExtUtils::CBuilder" : "0.26",
+ "ExtUtils::MakeMaker" : "6.30"
+ }
+ },
+ "develop" : {
+ "requires" : {
+ "Dist::Zilla::Plugin::MakeMaker::Awesome" : "0.07"
+ }
+ },
+ "runtime" : {
+ "requires" : {
+ "Exporter" : "0",
+ "IPC::Cmd" : "0",
+ "perl" : "5.006",
+ "strict" : "0",
+ "warnings" : "0"
+ }
+ },
+ "test" : {
+ "requires" : {
+ "Config" : "0",
+ "File::Find" : "0",
+ "File::Spec" : "0",
+ "File::Temp" : "0",
+ "Test::More" : "0.92"
+ }
+ }
+ },
+ "provides" : {
+ "Data::GUID::Any" : {
+ "file" : "lib/Data/GUID/Any.pm",
+ "version" : "0.003"
+ }
+ },
+ "release_status" : "stable",
+ "resources" : {
+ "bugtracker" : {
+ "mailto" : "bug-data-guid-any at rt.cpan.org",
+ "web" : "http://rt.cpan.org/Public/Dist/Display.html?Name=Data-GUID-Any"
+ },
+ "homepage" : "https://github.com/dagolden/data-guid-any",
+ "repository" : {
+ "type" : "git",
+ "url" : "https://github.com/dagolden/data-guid-any.git",
+ "web" : "https://github.com/dagolden/data-guid-any"
+ }
+ },
+ "version" : "0.003"
+}
+
View
34 META.yml
@@ -1,34 +0,0 @@
----
-name: Data-GUID-Any
-version: 0.002
-author:
- - 'David Golden <dagolden@cpan.org>'
-abstract: Generic interface for GUID creation
-license: apache
-resources:
- bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-GUID-Any
- repository: http://github.com/dagolden/data-guid-any/
-requires:
- Exporter: 0
- File::Spec: 3.12
- base: 0
- perl: 5.006
-build_requires:
- File::Find: 0
- Test::More: 0.62
-provides:
- Data::GUID::Any:
- file: lib/Data/GUID/Any.pm
- version: 0.002
-generated_by: Module::Build version 0.32
-meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.2.html
- version: 1.2
-no_index:
- directory:
- - examples
- - inc
- - t
- - xt
-configure_requires:
- Module::Build: 0.3
View
78 README
@@ -1,78 +0,0 @@
-NAME
- Data::GUID::Any - Generic interface for GUID creation
-
-VERSION
- This documentation describes version 0.002.
-
-SYNOPSIS
- use Data::GUID::Any 'guid_as_string';
-
- my $guid = guid_as_string();
-
-DESCRIPTION
- This module is a generic wrapper around various ways of obtaining
- Globally Unique ID's (GUID's). It will use any of the following, listed
- from most preferred to least preferred:
-
- * Data::GUID
-
- * Data::UUID
-
- * Data::UUID::LibUUID
-
- * UUID
-
- * Win32 (using GuidGen())
-
- * APR::UUID (random)
-
- * UUID::Random (random)
-
- * uuid (external program)
-
- If none are available when Data::GUID::Any is installed, it will add
- Data::GUID as a prerequisite.
-
-USAGE
- guid_as_string()
- my $guid = guid_as_string();
-
- Returns a guid in string format with upper-case hex characters:
-
- FA2D5B34-23DB-11DE-B548-0018F34EC37C
-
- Except for modules that only produce random GUID's, these are 'version
- 1' GUID's.
-
-BUGS
- Please report any bugs or feature requests using the CPAN Request
- Tracker web interface at
- <http://rt.cpan.org/Dist/Display.html?Queue=Data-GUID-Any>
-
- When submitting a bug or request, please include a test-file or a patch
- to an existing test-file that illustrates the bug or desired feature.
-
-SEE ALSO
- * RFC 4122 <http://tools.ietf.org/html/rfc4122>
-
-AUTHOR
- David A. Golden (DAGOLDEN)
-
-COPYRIGHT AND LICENSE
- Copyright (c) 2009 by David A. Golden. All rights reserved.
-
- Licensed under Apache License, Version 2.0 (the "License"). You may not
- use this file except in compliance with the License. A copy of the
- License was distributed with this file or you may obtain a copy of the
- License from http://www.apache.org/licenses/LICENSE-2.0
-
- Files produced as output though the use of this software, shall not be
- considered Derivative Works, but shall be considered the original work
- of the Licensor.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
View
42 README.PATCHING
@@ -0,0 +1,42 @@
+README.PATCHING
+
+Thank you for considering contributing to this distribution. This file
+contains instructions that will help you work with the source code.
+
+The distribution is managed with Dist::Zilla. This means than many of the
+usual files you might expect are not in the repository, but are generated
+at release time (e.g. Makefile.PL).
+
+However, you can run tests directly using the 'prove' tool:
+
+ $ prove -l
+ $ prove -lv t/some_test_file.t
+
+For most distributions, 'prove' is entirely sufficent for you to test any
+patches you have.
+
+Likewise, much of the documentation Pod is generated at release time.
+Depending on the distribution, some documentation may be written in a Pod
+dialect called WikiDoc. (See Pod::WikiDoc on CPAN.) If you would like to
+submit a documentation edit, please limit yourself to the documentation you
+see.
+
+If you see typos or documentation issues in the generated docs, please
+email or open a bug ticket instead of patching.
+
+Dist::Zilla is a very powerful authoring tool, but requires a number of
+author-specific plugins. If you would like to use it for contributing,
+install it from CPAN, then run one of the following commands, depending on
+your CPAN client:
+
+ $ cpan `dzil authordeps`
+ $ dzil authordeps | cpanm
+
+Once installed, here are some dzil commands you might try:
+
+ $ dzil build
+ $ dzil test
+ $ dzil xtest
+
+You can learn more about Dist::Zilla at http://dzil.org/
+
View
198 README.pod
@@ -0,0 +1,198 @@
+=pod
+
+=head1 NAME
+
+Data::GUID::Any - Generic interface for GUID/UUID creation
+
+=head1 VERSION
+
+version 0.003
+
+=head1 SYNOPSIS
+
+ use Data::GUID::Any 'guid_as_string';
+
+ my $guid = guid_as_string();
+
+=head1 DESCRIPTION
+
+This module is a generic wrapper around various ways of obtaining Globally
+Unique ID's (GUID's), also known as Universally Unique Identifiers (UUID's).
+
+On installation, if Data::GUID::Any can't detect a way of generating both
+version 1 and version 4 GUID's, it will add either Data::UUID::MT or UUID::Tiny
+as a prerequisite, depending on whether or not a compiler is available.
+
+=head1 USAGE
+
+The following functions are available for export.
+
+=head2 guid_as_string()
+
+ my $guid = guid_as_string();
+
+Returns a guid in string format with upper-case hex characters:
+
+ FA2D5B34-23DB-11DE-B548-0018F34EC37C
+
+This is the most general subroutine that offers the least amount of control
+over the result. This routine returns whatever is the default type of GUID for
+a source, which could be version 1 or version 4 (or, in the case of Win32,
+something resembling a version 1, but specific to Microsoft).
+
+It will use any of the following sources, listed from most preferred to least
+preferred:
+
+=over 4
+
+=item *
+
+L<Data::UUID::MT> (v4)
+
+=item *
+
+L<Data::GUID> (v1)
+
+=item *
+
+L<Data::UUID> (v1)
+
+=item *
+
+L<Data::UUID::LibUUID> (v4 or v1)
+
+=item *
+
+L<UUID> (v4 or v1)
+
+=item *
+
+L<Win32> (using GuidGen()) (similar to v1)
+
+=item *
+
+uuid (external program) (v1)
+
+=item *
+
+L<APR::UUID> (v4 or v1)
+
+=item *
+
+L<UUID::Tiny> (v1)
+
+=back
+
+At least one of them is guaranteed to exist or Data::GUID::Any will
+throw an exception when loaded. This shouldn't happen if prerequisites
+were correctly installed.
+
+=head2 v1_guid_as_string()
+
+ my $guid = v1_guid_as_string();
+
+Returns a version 1 (timestamp+MAC/random-identifier) GUID in string format
+with upper-case hex characters from one of the following sources:
+
+=over 4
+
+=item *
+
+L<Data::UUID::MT>
+
+=item *
+
+L<Data::GUID>
+
+=item *
+
+L<Data::UUID>
+
+=item *
+
+L<Data::UUID::LibUUID>
+
+=item *
+
+uuid (external program)
+
+=item *
+
+L<UUID::Tiny>
+
+=back
+
+If none of them are available, an exception will be thrown when this is called.
+This shouldn't happen if prerequisites were correctly installed.
+
+=head2 v4_guid_as_string()
+
+ my $guid = v4_guid_as_string();
+
+Returns a version 4 (random) GUID in string format with upper-case hex
+characters from one of the following modules:
+
+=over 4
+
+=item *
+
+L<Data::UUID::MT>
+
+=item *
+
+L<Data::UUID::LibUUID>
+
+=item *
+
+uuid (external program)
+
+=item *
+
+L<UUID::Tiny>
+
+=back
+
+If none of them are available, an exception will be thrown when this is called.
+This shouldn't happen if prerequisites were correctly installed.
+
+=head1 SEE ALSO
+
+=over 4
+
+=item *
+
+RFC 4122 [http://tools.ietf.org/html/rfc4122]
+
+=back
+
+=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
+
+=head1 SUPPORT
+
+=head2 Bugs / Feature Requests
+
+Please report any bugs or feature requests through the issue tracker
+at L<http://rt.cpan.org/Public/Dist/Display.html?Name=Data-GUID-Any>.
+You will be notified automatically of any progress on your issue.
+
+=head2 Source Code
+
+This is open source software. The code repository is available for
+public review and contribution under the terms of the license.
+
+L<https://github.com/dagolden/data-guid-any>
+
+ git clone https://github.com/dagolden/data-guid-any.git
+
+=head1 AUTHOR
+
+David Golden <dagolden@cpan.org>
+
+=head1 COPYRIGHT AND LICENSE
+
+This software is Copyright (c) 2012 by David Golden.
+
+This is free software, licensed under:
+
+ The Apache License, Version 2.0, January 2004
+
View
26 dist.ini
@@ -0,0 +1,26 @@
+name = Data-GUID-Any
+author = David Golden <dagolden@cpan.org>
+license = Apache_2_0
+copyright_holder = David Golden
+
+[@Filter]
+bundle = @DAGOLDEN
+remove = Test::PodSpelling
+remove = MakeMaker
+
+[=inc::MakeMaker]
+; N.B. requires MakeMaker::Awesome
+
+[Meta::Dynamic::Config]
+
+[Prereqs / ConfigureRequires]
+ExtUtils::CBuilder = 0.26
+
+[Prereqs / DevelopRequires]
+Dist::Zilla::Plugin::MakeMaker::Awesome = 0.07
+
+[Test::PodSpelling]
+stopwords = GUID's
+stopwords = UUID's
+stopwords = ID's
+stopwords = guid
View
47 inc/MakeMaker.pm
@@ -0,0 +1,47 @@
+package inc::MakeMaker;
+use Moose;
+extends 'Dist::Zilla::Plugin::MakeMaker::Awesome';
+
+use namespace::autoclean;
+
+override _build_WriteMakefile_dump => sub {
+ my ($self) = @_;
+
+ my $str = super;
+
+ $str .= ";\n\n";
+
+ $str .= <<'END_NONSENSE';
+$WriteMakefileArgs{PREREQ_PM} ||= {};
+
+eval {
+ local @INC = ('lib', @INC);
+ require Data::GUID::Any;
+ Data::GUID::Any::v1_guid_as_string(); # dies if no provider
+ Data::GUID::Any::v4_guid_as_string(); # dies if no provider
+ 1;
+} or do {
+ require ExtUtils::CBuilder;
+ if ( ExtUtils::CBuilder->new->have_compiler ) {
+ $WriteMakefileArgs{PREREQ_PM}{'Data::UUID::MT'} = '0';
+ }
+ else {
+ $WriteMakefileArgs{PREREQ_PM}{'UUID::Tiny'} = '0';
+ }
+};
+
+# Hey, CPAN Testers, go ahead and test with extra prereqs
+# that don't have external library dependencies
+if ( $ENV{AUTOMATED_TESTING} ) {
+ require ExtUtils::CBuilder;
+ $WriteMakefileArgs{BUILD_REQUIRES}{'Data::UUID::MT'} = '0'
+ if ExtUtils::CBuilder->new->have_compiler;
+ $WriteMakefileArgs{BUILD_REQUIRES}{'UUID::Tiny'} = '0';
+}
+
+END_NONSENSE
+
+ return $str;
+};
+
+1;
View
62 inc/Module/Build/WikiDoc.pm
@@ -1,62 +0,0 @@
-# Copyright (c) 2009 by David Golden. All rights reserved.
-# Licensed under Apache License, Version 2.0 (the "License").
-# You may not use this file except in compliance with the License.
-# A copy of the License was distributed with this file or you may obtain a
-# copy of the License from http://www.apache.org/licenses/LICENSE-2.0
-
-package Module::Build::WikiDoc;
-use strict;
-use base qw/Module::Build/;
-use File::Spec;
-
-sub ACTION_wikidoc {
- my $self = shift;
- eval "use Pod::WikiDoc";
- if ( $@ eq '' ) {
- my $parser = Pod::WikiDoc->new({
- comment_blocks => 1,
- keywords => { VERSION => $self->dist_version },
- });
- for my $src ( keys %{ $self->find_pm_files() } ) {
- (my $tgt = $src) =~ s{\.pm$}{.pod};
- $parser->filter( {
- input => $src,
- output => $tgt,
- });
- print "Creating $tgt\n";
- $tgt =~ s{\\}{/}g;
- $self->_add_to_manifest( 'MANIFEST', $tgt );
- }
- }
- else {
- warn "Pod::WikiDoc not available. Skipping wikidoc.\n";
- }
-}
-
-sub ACTION_test {
- my $self = shift;
- my $missing_pod;
- for my $src ( keys %{ $self->find_pm_files() } ) {
- (my $tgt = $src) =~ s{\.pm$}{.pod};
- $missing_pod = 1 if ! -e $tgt;
- }
- if ( $missing_pod ) {
- $self->depends_on('wikidoc');
- $self->depends_on('build');
- }
- $self->SUPER::ACTION_test;
-}
-
-sub ACTION_testpod {
- my $self = shift;
- $self->depends_on('wikidoc');
- $self->SUPER::ACTION_testpod;
-}
-
-sub ACTION_distmeta {
- my $self = shift;
- $self->depends_on('wikidoc');
- $self->SUPER::ACTION_distmeta;
-}
-
-1;
View
316 lib/Data/GUID/Any.pm
@@ -1,23 +1,16 @@
-# Copyright (c) 2009 by David Golden. All rights reserved.
-# Licensed under Apache License, Version 2.0 (the "License").
-# You may not use this file except in compliance with the License.
-# A copy of the License was distributed with this file or you may obtain a
-# copy of the License from http://www.apache.org/licenses/LICENSE-2.0
-
-package Data::GUID::Any;
use 5.006;
use strict;
use warnings;
-use Config;
-use File::Spec;
-use base 'Exporter';
-
-our $VERSION = '0.002';
-$VERSION = eval $VERSION; ## no critic
+package Data::GUID::Any;
+# ABSTRACT: Generic interface for GUID/UUID creation
+# VERSION
-our @EXPORT_OK = qw/ guid_as_string /;
+use IPC::Cmd;
+use Exporter;
+our @ISA = qw/Exporter/;
+our @EXPORT_OK = qw/ guid_as_string v1_guid_as_string v4_guid_as_string/;
-our $Using;
+our ($Using_vX, $Using_v1, $Using_v4) = ("") x 3;
#--------------------------------------------------------------------------#
@@ -30,70 +23,140 @@ sub _looks_like_guid {
#--------------------------------------------------------------------------#
-my @binaries = (
- [ uuid => 'uuid' => '-v1'],
+# state variables for generator closures
+my ($dumt_v1, $dumt_v4, $uuid_v1, $uuid_v4) = (undef) x 4; # reset if reloaded
+
+my %generators = (
+ # v1 or v4
+ 'Data::UUID::MT' => {
+ type => 'module',
+ v1 => sub {
+ $dumt_v1 ||= Data::UUID::MT->new(version => 1);
+ return uc $dumt_v1->create_string;
+ },
+ v4 => sub {
+ $dumt_v4 ||= Data::UUID::MT->new(version => 4);
+ return uc $dumt_v4->create_string;
+ },
+ },
+ 'Data::UUID::LibUUID' => {
+ type => 'module',
+ v1 => sub { return uc Data::UUID::LibUUID::new_uuid_string(2) },
+ v4 => sub { return uc Data::UUID::LibUUID::new_uuid_string(4) },
+ vX => sub { return uc Data::UUID::LibUUID::new_uuid_string() },
+ },
+ 'UUID::Tiny' => {
+ type => 'module',
+ v1 => sub { return uc UUID::Tiny::create_UUID_as_string(UUID::Tiny::UUID_V1()) },
+ v4 => sub { return uc UUID::Tiny::create_UUID_as_string(UUID::Tiny::UUID_V4()) },
+ },
+ 'uuid' => {
+ type => 'binary',
+ v1 => sub {
+ $uuid_v1 ||= IPC::Cmd::can_run('uuid');
+ chomp( my $guid = qx/$uuid_v1 -v1/ ); return uc $guid;
+ },
+ v4 => sub {
+ $uuid_v4 ||= IPC::Cmd::can_run('uuid');
+ chomp( my $guid = qx/$uuid_v4 -v4/ ); return uc $guid;
+ },
+ },
+ # v1 only
+ 'Data::GUID' => {
+ type => 'module',
+ v1 => sub { return uc Data::GUID->new->as_string },
+ },
+ 'Data::UUID' => {
+ type => 'module',
+ v1 => sub { return uc Data::UUID->new->create_str },
+ },
+ # system dependent or custom
+ 'UUID' => {
+ type => 'module',
+ vX => sub { my ($u,$s); UUID::generate($u); UUID::unparse($u, $s); return uc $s },
+ },
+ 'Win32' => {
+ type => 'module',
+ vX => sub { my $guid = Win32::GuidGen(); return uc substr($guid,1,-1) },
+ },
+ 'APR::UUID' => {
+ type => 'module',
+ vX => sub { return uc APR::UUID->new->format },
+ },
);
-sub _check_binaries {
- BIN:
- for my $bin ( @binaries ) {
- my ($name, $cmd, $args) = @$bin;
- my $path;
- my @suffixes = $^O eq 'MSWin32' ? (qw/.exe .com .bat/) : ( '' );
- SUFFIX:
- for my $suffix ( @suffixes ) {
- ($path) = grep { -x }
- map { File::Spec->catfile( $_, $cmd ) . $suffix }
- File::Spec->path;
- next SUFFIX unless $path;
- }
- next BIN unless $path;
- my $sub = sub { chomp( my $guid = qx/$path $args/ ); return uc $guid };
- return ($name, $sub) if _looks_like_guid( $sub->() );
+our $NO_BINARY; # for testing
+sub _is_available {
+ my ($name) = @_;
+ if ( $generators{$name}{type} eq 'binary' ) {
+ return $NO_BINARY ? undef : IPC::Cmd::can_run($name);
+ }
+ else {
+ return eval "require $name";
}
}
-#--------------------------------------------------------------------------#
-
-my @modules = (
- ['Data::GUID' => sub { return Data::GUID->new->as_string }],
- ['Data::UUID' => sub { return Data::UUID->new->create_str }],
- ['Data::UUID::LibUUID' => sub{ return uc Data::UUID::LibUUID::new_uuid_string() }],
- ['UUID' => sub { my ($u,$s); UUID::generate($u); UUID::unparse($u, $s); return uc $s }],
- ['Win32' => sub { my $guid = Win32::GuidGen(); return substr($guid,1,-1) }],
- ['UUID::Generator::PurePerl' => sub { return uc UUID::Generator::PurePerl->new->generate_v1->as_string }],
- ['APR::UUID' => sub { return uc APR::UUID->new->format }],
- ['UUID::Random' => sub { return uc UUID::Random::generate() }],
-);
-
-sub _preferred_modules {
- return map { $_->[0] } @modules;
-}
-
-sub _check_modules {
- for my $option ( @modules ) {
- my ($mod,$sub) = @$option;
- next unless eval "require $mod; 1";
- return ($mod, $sub) if _looks_like_guid( $sub->() );
+sub _best_generator {
+ my ($list) = @_;
+ for my $option ( @$list ) {
+ my ($name, $version) = @$option;
+ next unless my $g = $generators{$name};
+ next unless _is_available($name);
+ return ($name, $g->{$version})
+ if $g->{$version} && _looks_like_guid( $g->{$version}->() );
}
+ return;
}
#--------------------------------------------------------------------------#
-my ($which_bin, $bin_sub) = _check_binaries();
-my ($which_mod, $mod_sub) = _check_modules();
+my %sets = (
+ any => [
+ ['Data::UUID::MT' => 'v4'],
+ ['Data::GUID' => 'v1'],
+ ['Data::UUID' => 'v1'],
+ ['Data::UUID::LibUUID' => 'vX'],
+ ['UUID' => 'vX'],
+ ['Win32' => 'vX'],
+ ['uuid' => 'v1'],
+ ['APR::UUID' => 'vX'],
+ ['UUID::Tiny' => 'v1'],
+ ],
+ v1 => [
+ ['Data::UUID::MT' => 'v1'],
+ ['Data::GUID' => 'v1'],
+ ['Data::UUID' => 'v1'],
+ ['Data::UUID::LibUUID' => 'v1'],
+ ['uuid' => 'v1'],
+ ['UUID::Tiny' => 'v1'],
+ ],
+ v4 => [
+ ['Data::UUID::MT' => 'v4'],
+ ['Data::UUID::LibUUID' => 'v4'],
+ ['uuid' => 'v4'],
+ ['UUID::Tiny' => 'v4'],
+ ],
+);
-die "Couldn't find a GUID module or binary" unless $bin_sub || $mod_sub;
+sub _generator_set { return $sets{$_[0]} }
{
- no warnings;
- if ( $mod_sub ) {
- *guid_as_string = $mod_sub;
- $Using = $which_mod
+ no warnings qw/once redefine/;
+ {
+ my ($n, $s) = _best_generator(_generator_set("any"));
+ die "Couldn't find a GUID provider" unless $n;
+ *guid_as_string = $s;
+ $Using_vX = $n;
}
- else {
- *guid_as_string = $bin_sub;
- $Using = $which_bin
+ {
+ my ($n, $s) = _best_generator(_generator_set("v1"));
+ *v1_guid_as_string = $s || sub { die "No v1 GUID provider found\n" };
+ $Using_v1 = $n || '';
+ }
+ {
+ my ($n, $s) = _best_generator(_generator_set("v4"));
+ *v4_guid_as_string = $s || sub { die "No v4 GUID provider found\n" };
+ $Using_v4 = $n || '';
}
}
@@ -101,90 +164,95 @@ die "Couldn't find a GUID module or binary" unless $bin_sub || $mod_sub;
__END__
-=begin wikidoc
-
-= NAME
-
-Data::GUID::Any - Generic interface for GUID creation
-
-= VERSION
-
-This documentation describes version %%VERSION%%.
-
-= SYNOPSIS
+=head1 SYNOPSIS
use Data::GUID::Any 'guid_as_string';
my $guid = guid_as_string();
-= DESCRIPTION
+=head1 DESCRIPTION
-This module is a generic wrapper around various ways of obtaining
-Globally Unique ID's (GUID's). It will use any of the following, listed
-from most preferred to least preferred:
+This module is a generic wrapper around various ways of obtaining Globally
+Unique ID's (GUID's), also known as Universally Unique Identifiers (UUID's).
-* [Data::GUID]
-* [Data::UUID]
-* [Data::UUID::LibUUID]
-* [UUID]
-* [Win32] (using GuidGen())
-* [UUID::Generator::PurePerl]
-* [APR::UUID] (random)
-* [UUID::Random] (random)
-* uuid (external program)
+On installation, if Data::GUID::Any can't detect a way of generating both
+version 1 and version 4 GUID's, it will add either Data::UUID::MT or UUID::Tiny
+as a prerequisite, depending on whether or not a compiler is available.
-If none are available when Data::GUID::Any is installed, it will
-add Data::GUID as a prerequisite.
+=head1 USAGE
-= USAGE
+The following functions are available for export.
-== guid_as_string()
+=head2 guid_as_string()
my $guid = guid_as_string();
-Returns a guid in string format with upper-case hex characters:
+Returns a guid in string format with upper-case hex characters:
FA2D5B34-23DB-11DE-B548-0018F34EC37C
-Except for modules that only produce random GUID's, these are 'version 1'
-GUID's.
-
-= BUGS
-
-Please report any bugs or feature requests using the CPAN Request Tracker
-web interface at [http://rt.cpan.org/Dist/Display.html?Queue=Data-GUID-Any]
-
-When submitting a bug or request, please include a test-file or a patch to an
-existing test-file that illustrates the bug or desired feature.
+This is the most general subroutine that offers the least amount of control
+over the result. This routine returns whatever is the default type of GUID for
+a source, which could be version 1 or version 4 (or, in the case of Win32,
+something resembling a version 1, but specific to Microsoft).
+
+It will use any of the following sources, listed from most preferred to least
+preferred:
+
+=for :list
+* L<Data::UUID::MT> (v4)
+* L<Data::GUID> (v1)
+* L<Data::UUID> (v1)
+* L<Data::UUID::LibUUID> (v4 or v1)
+* L<UUID> (v4 or v1)
+* L<Win32> (using GuidGen()) (similar to v1)
+* uuid (external program) (v1)
+* L<APR::UUID> (v4 or v1)
+* L<UUID::Tiny> (v1)
+
+At least one of them is guaranteed to exist or Data::GUID::Any will
+throw an exception when loaded. This shouldn't happen if prerequisites
+were correctly installed.
+
+=head2 v1_guid_as_string()
+
+ my $guid = v1_guid_as_string();
+
+Returns a version 1 (timestamp+MAC/random-identifier) GUID in string format
+with upper-case hex characters from one of the following sources:
+
+=for :list
+* L<Data::UUID::MT>
+* L<Data::GUID>
+* L<Data::UUID>
+* L<Data::UUID::LibUUID>
+* uuid (external program)
+* L<UUID::Tiny>
-= SEE ALSO
+If none of them are available, an exception will be thrown when this is called.
+This shouldn't happen if prerequisites were correctly installed.
-* RFC 4122 [http://tools.ietf.org/html/rfc4122]
-= AUTHOR
+=head2 v4_guid_as_string()
-David A. Golden (DAGOLDEN)
+ my $guid = v4_guid_as_string();
-= COPYRIGHT AND LICENSE
+Returns a version 4 (random) GUID in string format with upper-case hex
+characters from one of the following modules:
-Copyright (c) 2009 by David A. Golden. All rights reserved.
-
-Licensed under Apache License, Version 2.0 (the "License").
-You may not use this file except in compliance with the License.
-A copy of the License was distributed with this file or you may obtain a
-copy of the License from http://www.apache.org/licenses/LICENSE-2.0
+=for :list
+* L<Data::UUID::MT>
+* L<Data::UUID::LibUUID>
+* uuid (external program)
+* L<UUID::Tiny>
-Files produced as output though the use of this software, shall not be
-considered Derivative Works, but shall be considered the original work of the
-Licensor.
+If none of them are available, an exception will be thrown when this is called.
+This shouldn't happen if prerequisites were correctly installed.
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
+=head1 SEE ALSO
-=end wikidoc
+=for :list
+* RFC 4122 [http://tools.ietf.org/html/rfc4122]
=cut
View
118 lib/Data/GUID/Any.pod
@@ -1,118 +0,0 @@
-# Generated by Pod::WikiDoc version 0.18
-
-=pod
-
-=head1 NAME
-
-Data::GUID::Any - Generic interface for GUID creation
-
-=head1 VERSION
-
-This documentation describes version 0.002.
-
-=head1 SYNOPSIS
-
- use Data::GUID::Any 'guid_as_string';
-
- my $guid = guid_as_string();
-
-=head1 DESCRIPTION
-
-This module is a generic wrapper around various ways of obtaining
-Globally Unique ID's (GUID's). It will use any of the following, listed
-from most preferred to least preferred:
-
-=over
-
-=item *
-
-L<Data::GUID>
-
-=item *
-
-L<Data::UUID>
-
-=item *
-
-L<Data::UUID::LibUUID>
-
-=item *
-
-L<UUID>
-
-=item *
-
-L<Win32> (using GuidGen())
-
-=item *
-
-L<APR::UUID> (random)
-
-=item *
-
-L<UUID::Random> (random)
-
-=item *
-
-uuid (external program)
-
-=back
-
-If none are available when Data::GUID::Any is installed, it will
-add Data::GUID as a prerequisite.
-
-=head1 USAGE
-
-=head2 guid_as_string()
-
- my $guid = guid_as_string();
-
-Returns a guid in string format with upper-case hex characters:
-
- FA2D5B34-23DB-11DE-B548-0018F34EC37C
-
-Except for modules that only produce random GUID's, these are 'version 1'
-GUID's.
-
-=head1 BUGS
-
-Please report any bugs or feature requests using the CPAN Request Tracker
-web interface at L<http://rt.cpan.org/Dist/Display.html?Queue=Data-GUID-Any>
-
-When submitting a bug or request, please include a test-file or a patch to an
-existing test-file that illustrates the bug or desired feature.
-
-=head1 SEE ALSO
-
-=over
-
-=item *
-
-RFC 4122 L<http://tools.ietf.org/html/rfc4122>
-
-=back
-
-=head1 AUTHOR
-
-David A. Golden (DAGOLDEN)
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright (c) 2009 by David A. Golden. All rights reserved.
-
-Licensed under Apache License, Version 2.0 (the "License").
-You may not use this file except in compliance with the License.
-A copy of the License was distributed with this file or you may obtain a
-copy of the License from http:E<sol>E<sol>www.apache.orgE<sol>licensesE<sol>LICENSE-2.0
-
-Files produced as output though the use of this software, shall not be
-considered Derivative Works, but shall be considered the original work of the
-Licensor.
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-
View
0  xt/perlcriticrc → perlcritic.rc
File renamed without changes
View
31 t/00-compile.t
@@ -1,31 +0,0 @@
-# Copyright (c) 2009 by David Golden. All rights reserved.
-# Licensed under Apache License, Version 2.0 (the "License").
-# You may not use this file except in compliance with the License.
-# A copy of the License was distributed with this file or you may obtain a
-# copy of the License from http://www.apache.org/licenses/LICENSE-2.0
-
-use strict;
-use warnings;
-
-use Test::More;
-use File::Find;
-use File::Spec;
-
-my @pms;
-find( sub { return if /^\.\.?$/; push @pms, $File::Find::name if /\.pm/ }, 'lib' );
-
-if ( @pms ) {
- plan tests => scalar @pms;
-}
-else {
- plan skip_all => 'no .pm files found';
-}
-
-my $null = File::Spec->devnull;
-
-for my $file ( @pms ) {
- system("$^X -c $file > $null 2>&1");
- ok( $? == 0, "compiled $file" );
-}
-
-
View
101 t/01-Data-GUID-Any.t
@@ -1,13 +1,8 @@
-# Copyright (c) 2009 by David Golden. All rights reserved.
-# Licensed under Apache License, Version 2.0 (the "License").
-# You may not use this file except in compliance with the License.
-# A copy of the License was distributed with this file or you may obtain a
-# copy of the License from http://www.apache.org/licenses/LICENSE-2.0
-
use strict;
use warnings;
+no warnings 'once';
-use Test::More;
+use Test::More 0.92;
use Config;
use File::Spec;
use t::Util;
@@ -39,51 +34,67 @@ unshift @INC, \&_hider;
# Start tests
#--------------------------------------------------------------------------#
-plan 'no_plan';
+my %fcn = (
+ any => sub { Data::GUID::Any::guid_as_string() },
+ v1 => sub { Data::GUID::Any::v1_guid_as_string() },
+ v4 => sub { Data::GUID::Any::v4_guid_as_string() },
+);
+
+my %using = (
+ any => sub { $Data::GUID::Any::Using_vX },
+ v1 => sub { $Data::GUID::Any::Using_v1 },
+ v4 => sub { $Data::GUID::Any::Using_v4 },
+);
require_ok( "Data::GUID::Any" )
or BAIL_OUT "require Data::GUID::Any failed";
-my @modules = (Data::GUID::Any::_preferred_modules(), $binary);
+for my $style ( qw/any v1 v4/ ) {
-while ( my $mod = shift @modules ) {
- SKIP: {
- if ( $mod eq $binary ) {
- skip( "$mod not executable", 1) unless -x $mod;
- }
- else {
- eval "require $mod; 1" or skip( "$mod not available", 1);
- }
- # reload Data::GUID::Any
- delete $INC{'Data/GUID/Any.pm'};
- {
- local $SIG{__WARN__} = sub {};
- eval { require Data::GUID::Any;1 };
- is( $@ , "",
- "reloaded Data::GUID::Any"
+ my @providers = map { $_->[0] } @{Data::GUID::Any::_generator_set($style)};
+ undef $Data::GUID::Any::NO_BINARY;
+ undef %hidden;
+
+ while ( my $mod = shift @providers ) {
+ SKIP: {
+ my $available;
+ {
+ local $SIG{__WARN__} = sub {};
+ $available = Data::GUID::Any::_is_available($mod);
+ }
+ skip( "$mod not available", 1) unless $available;
+ # reload Data::GUID::Any
+ delete $INC{'Data/GUID/Any.pm'};
+ {
+ local $SIG{__WARN__} = sub {};
+ eval { require Data::GUID::Any;1 };
+ is( $@ , "",
+ "reloaded Data::GUID::Any"
+ );
+ }
+ is( $using{$style}->(), $mod,
+ "$style: Data::GUID::Any set to use '$mod'"
);
- }
- is( $Data::GUID::Any::Using, ($mod eq $binary ? 'uuid' : $mod),
- "Data::GUID::Any set to use '$mod'"
- );
- # test getting a guid
- can_ok( 'Data::GUID::Any', $_ ) for qw/ guid_as_string /;
- my $guid = Data::GUID::Any::guid_as_string();
- ok( t::Util::looks_like_guid( $guid ),
- "guid_as_string() looks like guid"
- ) or diag $guid;
- # hide module before next loop
- if ( $mod ne $binary) {
- my $mod_path = $mod;
- $mod_path =~ s{::}{/}g;
- $mod_path .= ".pm";
- $hidden{$mod_path} = delete $INC{$mod_path};
- eval "require $mod; 1";
- ok( $@, "$mod hidden" )
- or diag "$mod_path";
- undef $Data::GUID::Any::Using;
+ my $guid = $fcn{$style}->();
+ ok( t::Util::looks_like_guid( $guid ),
+ "$style: got valid guid from '$mod'"
+ ) or diag $guid;
+ # hide binary or module before next loop
+ if ( $mod eq 'uuid') {
+ $Data::GUID::Any::NO_BINARY = 1;
+ pass 'uuid hidden';
+ }
+ else {
+ my $mod_path = $mod;
+ $mod_path =~ s{::}{/}g;
+ $mod_path .= ".pm";
+ $hidden{$mod_path} = delete $INC{$mod_path};
+ eval "require $mod; 1";
+ ok( $@, "$mod hidden" )
+ or diag "$mod_path";
+ }
}
}
}
-
+done_testing;
View
3  t/Util.pm
@@ -1,7 +1,8 @@
package t::Util;
use strict;
use warnings;
-use base 'Exporter';
+use Exporter;
+our @ISA = qw/Exporter/;
our @EXPORT = qw/looks_like_guid/;
my $hex = "A-Z0-9";
View
15 xt/critic.t
@@ -1,15 +0,0 @@
-# Copyright (c) 2009 by David Golden. All rights reserved.
-# Licensed under Apache License, Version 2.0 (the "License").
-# You may not use this file except in compliance with the License.
-# A copy of the License was distributed with this file or you may obtain a
-# copy of the License from http://www.apache.org/licenses/LICENSE-2.0
-
-use strict;
-use warnings;
-use File::Spec;
-use Test::More;
-require Test::Perl::Critic;
-
-my $rcfile = File::Spec->catfile( 'xt', 'perlcriticrc' );
-Test::Perl::Critic->import( -profile => $rcfile );
-all_critic_ok( 'lib', 'examples' );
View
5 xt/kwalitee.t
@@ -1,5 +0,0 @@
-use strict;
-use Test::Kwalitee;
-# remove cruft
-unlink 'Debian_CPANTS.txt';
-unlink 'Makefile';
View
3  xt/metayml.t
@@ -1,3 +0,0 @@
-use Test::More;
-use Test::YAML::Meta;
-meta_yaml_ok();
View
29 xt/pod-coverage.t
@@ -1,29 +0,0 @@
-# Copyright (c) 2009 by David Golden. All rights reserved.
-# Licensed under Apache License, Version 2.0 (the "License").
-# You may not use this file except in compliance with the License.
-# A copy of the License was distributed with this file or you may obtain a
-# copy of the License from http://www.apache.org/licenses/LICENSE-2.0
-
-use Test::More;
-
-my $min_tpc = 1.08;
-eval "use Test::Pod::Coverage $min_tpc";
-plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
- if $@;
-
-my $min_pc = 0.17;
-eval "use Pod::Coverage $min_pc";
-plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
- if $@;
-
-my @modules = all_modules('lib');
-
-plan tests => scalar @modules;
-
-for my $mod ( @modules ) {
- my $doc = "lib/$mod";
- $doc =~ s{::}{/}g;
- $doc = -f "$doc\.pod" ? "$doc\.pod" : "$doc\.pm" ;
- pod_coverage_ok( $mod, { pod_from => $doc } );
-}
-
View
13 xt/pod-format.t
@@ -1,13 +0,0 @@
-# Copyright (c) 2009 by David Golden. All rights reserved.
-# Licensed under Apache License, Version 2.0 (the "License").
-# You may not use this file except in compliance with the License.
-# A copy of the License was distributed with this file or you may obtain a
-# copy of the License from http://www.apache.org/licenses/LICENSE-2.0
-
-use Test::More;
-
-my $min_tp = 1.22;
-eval "use Test::Pod $min_tp";
-plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
-
-all_pod_files_ok();
View
21 xt/spelling.t
@@ -1,21 +0,0 @@
-# Copyright (c) 2009 by David Golden. All rights reserved.
-# Licensed under Apache License, Version 2.0 (the "License").
-# You may not use this file except in compliance with the License.
-# A copy of the License was distributed with this file or you may obtain a
-# copy of the License from http://www.apache.org/licenses/LICENSE-2.0
-
-use Test::More;
-use IO::File;
-
-my $min_tps = 0.11;
-eval "use Test::Spelling $min_tps";
-plan skip_all => "Test::Spelling $min_tps required for testing POD" if $@;
-system( "ispell -v" ) and plan skip_all => "No ispell";
-
-set_spell_cmd( "ispell -l" );
-
-my $swf = IO::File->new('xt/stopwords.txt');
-my @stopwords = grep { length } map { chomp; $_ } <$swf>;
-add_stopwords( @stopwords );
-
-all_pod_files_spelling_ok();
View
10 xt/stopwords.txt
@@ -1,10 +0,0 @@
-CPAN
-CTRL
-DAGOLDEN
-Foo
-MSWin
-README
-STDERR
-STDOUT
-XS
-html

No commit comments for this range

Something went wrong with that request. Please try again.