COPYRIGHT000644001750001750 374414550071117 15737 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: URI-NamespaceMap Upstream-Contact: Chris Prather (PERIGRIN) , Gregory Todd Williams , and Kjetil Kjernsmo Source: https://metacpan.org/module/URI::NamespaceMap Files: lib/Types/Namespace.pm lib/URI/NamespaceMap/ReservedLocalParts.pm t/justuri.t t/lib/CommonTest.pm t/types-attean.t t/types-trine.t t/types.t Copyright: Copyright 2019 Chris Prather, Gregory Todd Williams, and Kjetil Kjernsmo. License: GPL-1.0+ or Artistic-1.0 Files: Changes META.json META.yml doap.ttl lib/URI/Namespace.pm Copyright: Copyright 2024 Chris Prather, Gregory Todd Williams, and Kjetil Kjernsmo. License: GPL-1.0+ or Artistic-1.0 Files: t/namespacemap.t t/prefixguess-none.t t/reserved.t Copyright: Copyright 2017 Chris Prather, Gregory Todd Williams, and Kjetil Kjernsmo. License: GPL-1.0+ or Artistic-1.0 Files: INSTALL LICENSE README.md Copyright: Unknown License: Unknown Files: COPYRIGHT CREDITS SIGNATURE Copyright: None License: public-domain Files: README lib/URI/NamespaceMap.pm Copyright: Copyright 2012,2013,2014,2015,2016,2017,2018,2019 Gregory Todd Williams, Chris Prather and Kjetil Kjernsmo. License: GPL-1.0+ or Artistic-1.0 Files: dist.ini t/prefixguess.t Copyright: Copyright 2018 Chris Prather, Gregory Todd Williams, and Kjetil Kjernsmo. License: GPL-1.0+ or Artistic-1.0 Files: t/iri.t Copyright: Copyright 2014 Chris Prather, Gregory Todd Williams, and Kjetil Kjernsmo. License: GPL-1.0+ or Artistic-1.0 Files: Makefile.PL Copyright: Copyright 2020 Toby Inkster. License: GPL-1.0+ or Artistic-1.0 License: Artistic-1.0 This software is Copyright (c) 2024 by the copyright holder(s). This is free software, licensed under: The Artistic License 1.0 License: GPL-1.0 This software is Copyright (c) 2024 by the copyright holder(s). This is free software, licensed under: The GNU General Public License, Version 1, February 1989 CREDITS000644001750001750 47614550071117 15443 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12Maintainer: - Chris Prather (PERIGRIN) - Gregory Todd Williams - Kjetil Kjernsmo Contributor: - Dorian Taylor - KWAKWA - Toby Inkster (TOBYINK) Thanks: - Zakariyya Mughal (ZMUGHAL) Changes000644001750001750 713214550071117 15732 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12URI-NamespaceMap ================ Created: 2012-08-27 Home page: Bug tracker: Maintainer: Kjetil Kjernsmo Maintainer: Gregory Todd Williams Maintainer: Chris Prather (PERIGRIN) 1.12 2024-01-11 Add new automations and small fixes. - Added: Add explicit DESTROY. Zakariyya Mughal++ - Removed: Remove Travis CI. Zakariyya Mughal++ - Updated: Add new Github CI automations. 1.10 2019-11-20 Add more coercions. - Added: Add coercions for RDF::Trine and Attean classes. - Added: Bring Namespace.pm test coverage to 100%. 1.08 2019-04-15 Add local_part method. - Added: Add local_part method to URI::Namespace. 1.06 2018-01-27 Add each_map method. - Added: Add each_map method - Added: Check for Iri in scrubber 1.04 2017-07-08 Append a hash to only to XSD URIs. [ Bug Fixes ] - Partly revert fix in 1.02, now only append a hash to the XML Schema URI (closes issue #14). 1.02 2017-06-21 Append a hash to URIs needing it. [ Bug Fixes ] - When adding local names, check if namespace ends in hash or slash, and append hash if not. 1.00 2017-01-18 Check prefixes so they don't conflict with existing methods. - Added: Prefixes that will conflict with existing methods will throw an error. kwakwa++ - Improve the BUILDARGS code. Chris Prather++ - Minor cleanups. - Removed: Remove strict/warnings pragmas where Moo is used. kwakwa++ 0.32 2016-12-29 New guessing method and improved diagnostics. [ Bug Fixes ] - Rework some tests that fails in strange ways. [ Other ] - Added: Add method for adding guesses post-construction. - Use carp instead of warns. 0.30 2016-02-12 Test bugfix. [ Bug Fixes ] - Remove a test because toolchain makes it hard to get the correct version. 0.28 2015-09-23 Bugfix release. [ Bug Fixes ] - Had forgotten to update error messages. 0.26 2015-09-01 Support for RDF::NS::Curated. - Support for RDF::NS::Curated. 0.24 2014-12-10 Improve documentation. [ Bug Fixes ] - Use a string comparison in failing test. [ Other ] - Improve documentation, autoloader. - Reindent using Emacs smart-tabs. - Some code cleanup. 0.22 2014-10-15 Clean up source tree. - Clean up source tree. 0.21 2014-10-05 Fix missing Changes. [ Bug Fixes ] - Fix missing Changes. 0.20 2014-10-05 Moo refactoring. - Added: Warn the user when they have too old RDF::NS but not in automated tests. - Convert packaging to Dist::Inkt. Toby Inkster++ - Port to Moo. Toby Inkster++ 0.12 2014-09-29 Support IRI module. [ Bug Fixes ] - Silence warnings when URI doesn't have local part. [ Other ] - Added: Link Debian packages in metadata. - Added: Support the new IRI module. Gregory Todd Williams++ - Added: Use Types::URI. - Added: Warn the user in test when they have too old RDF::NS. 0.10 2014-05-21 Compatibility with RDF::Trine::NamespaceMap. - Added: Make it possible to send local part to the uri method of URI::Namespace. Chris Prather++ 0.08 2014-05-19 Prefix guessing. [ Bug Fixes ] - Fix breakage in terms with hyphens. Dorian Taylor++ [ Other ] - Added: Prefix guessing using RDF::NS, RDF::Prefixes or XML::CommonNS. 0.06 2012-11-28 Bugfix release. [ Bug Fixes ] - URI::Namespace must be used from URI::NamespaceMap. 0.04 2012-10-23 Reverse lookups. - Added: Adding reverse lookups, i.e. abbreviation and prefix_for. Dorian Taylor++ - Stop using blank node in makefile.ttl to fix version_from. 0.02 2012-08-30 Minor bugfixes. 0.01 2012-08-28 Initial release. INSTALL000644001750001750 171614550071117 15472 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12 Installing URI-NamespaceMap should be straightforward. INSTALLATION WITH CPANMINUS If you have cpanm, you only need one line: % cpanm URI::NamespaceMap If you are installing into a system-wide directory, you may need to pass the "-S" flag to cpanm, which uses sudo to install the module: % cpanm -S URI::NamespaceMap INSTALLATION WITH THE CPAN SHELL Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan URI::NamespaceMap MANUAL INSTALLATION As a last resort, you can manually install it. Download the tarball and unpack it. Consult the file META.json for a list of pre-requisites. Install these first. To build URI-NamespaceMap: % perl Makefile.PL % make && make test Then install it: % make install If you are installing into a system-wide directory, you may need to run: % sudo make install LICENSE000644001750001750 4405714550071117 15473 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12This software is copyright (c) 2024 by Chris Prather, Gregory Todd Williams, and Kjetil Kjernsmo. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2024 by Chris Prather, Gregory Todd Williams, and Kjetil Kjernsmo. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2024 by Chris Prather, Gregory Todd Williams, and Kjetil Kjernsmo. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End MANIFEST000644001750001750 60414550071117 15545 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12COPYRIGHT CREDITS Changes INSTALL LICENSE MANIFEST META.json META.yml Makefile.PL README README.md SIGNATURE dist.ini doap.ttl lib/Types/Namespace.pm lib/URI/Namespace.pm lib/URI/NamespaceMap.pm lib/URI/NamespaceMap/ReservedLocalParts.pm t/iri.t t/justuri.t t/lib/CommonTest.pm t/namespacemap.t t/prefixguess-none.t t/prefixguess.t t/reserved.t t/types-attean.t t/types-trine.t t/types.t META.json000644001750001750 604114550071117 16056 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12{ "abstract" : "Namespace manipulation and prefix mapping for XML, RDF, etc.", "author" : [ "Kjetil Kjernsmo ", "Gregory Todd Williams ", "Chris Prather (PERIGRIN) " ], "dynamic_config" : 0, "generated_by" : "Dist::Inkt::Profile::KJETILK version 0.101, CPAN::Meta::Converter version 2.150010", "keywords" : [], "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "URI-NamespaceMap", "no_index" : { "directory" : [ "eg", "examples", "inc", "t", "xt" ] }, "optional_features" : {}, "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.17" } }, "runtime" : { "recommends" : { "RDF::NS" : "20130802", "RDF::NS::Curated" : "0", "RDF::Prefixes" : "0", "XML::CommonNS" : "0" }, "requires" : { "Carp" : "0", "IRI" : "0.004", "Module::Load::Conditional" : "0", "Moo" : "1.006000", "Sub::Quote" : "0", "Try::Tiny" : "0", "Type::Library" : "1.000000", "Types::URI" : "0.004", "URI" : "1.52", "namespace::autoclean" : "0.20", "perl" : "5.008001" } }, "test" : { "recommends" : { "Attean" : "0.025" }, "requires" : { "Test::Deep" : "0", "Test::Exception" : "0", "Test::More" : "0.88", "Test::Requires" : "0" }, "suggests" : { "RDF::Trine" : "0" } } }, "provides" : { "Types::Namespace" : { "file" : "lib/Types/Namespace.pm", "version" : "1.10" }, "URI::Namespace" : { "file" : "lib/URI/Namespace.pm", "version" : "1.10" }, "URI::NamespaceMap" : { "file" : "lib/URI/NamespaceMap.pm", "version" : "1.12" }, "URI::NamespaceMap::ReservedLocalParts" : { "file" : "lib/URI/NamespaceMap/ReservedLocalParts.pm", "version" : "1.10" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/kjetilk/URI-NamespaceMap/issues" }, "homepage" : "https://metacpan.org/module/URI::NamespaceMap", "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "type" : "git", "web" : "https://github.com/kjetilk/URI-NamespaceMap/" }, "x_identifier" : "http://purl.org/NET/cpan-uri/dist/URI-NamespaceMap/project" }, "version" : "1.12", "x_contributors" : [ "Dorian Taylor ", "Toby Inkster (TOBYINK) ", "KWAKWA " ], "x_serialization_backend" : "JSON::PP version 4.07", "x_static_install" : 1 } META.yml000644001750001750 362614550071117 15714 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12--- abstract: 'Namespace manipulation and prefix mapping for XML, RDF, etc.' author: - 'Kjetil Kjernsmo ' - 'Gregory Todd Williams ' - 'Chris Prather (PERIGRIN) ' build_requires: Test::Deep: '0' Test::Exception: '0' Test::More: '0.88' Test::Requires: '0' configure_requires: ExtUtils::MakeMaker: '6.17' dynamic_config: 0 generated_by: 'Dist::Inkt::Profile::KJETILK version 0.101, CPAN::Meta::Converter version 2.150010' keywords: [] license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: URI-NamespaceMap no_index: directory: - eg - examples - inc - t - xt optional_features: {} provides: Types::Namespace: file: lib/Types/Namespace.pm version: '1.10' URI::Namespace: file: lib/URI/Namespace.pm version: '1.10' URI::NamespaceMap: file: lib/URI/NamespaceMap.pm version: '1.12' URI::NamespaceMap::ReservedLocalParts: file: lib/URI/NamespaceMap/ReservedLocalParts.pm version: '1.10' recommends: RDF::NS: '20130802' RDF::NS::Curated: '0' RDF::Prefixes: '0' XML::CommonNS: '0' requires: Carp: '0' IRI: '0.004' Module::Load::Conditional: '0' Moo: '1.006000' Sub::Quote: '0' Try::Tiny: '0' Type::Library: '1.000000' Types::URI: '0.004' URI: '1.52' namespace::autoclean: '0.20' perl: '5.008001' resources: Identifier: http://purl.org/NET/cpan-uri/dist/URI-NamespaceMap/project bugtracker: https://github.com/kjetilk/URI-NamespaceMap/issues homepage: https://metacpan.org/module/URI::NamespaceMap license: http://dev.perl.org/licenses/ repository: https://github.com/kjetilk/URI-NamespaceMap/ version: '1.12' x_contributors: - 'Dorian Taylor ' - 'Toby Inkster (TOBYINK) ' - 'KWAKWA ' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' x_static_install: 1 Makefile.PL000644001750001750 1457714550071117 16444 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12use strict; use ExtUtils::MakeMaker 6.17; my $EUMM = eval( $ExtUtils::MakeMaker::VERSION ); my $meta = { "abstract" => "Namespace manipulation and prefix mapping for XML, RDF, etc.", "author" => [ "Kjetil Kjernsmo ", "Gregory Todd Williams ", "Chris Prather (PERIGRIN) ", ], "dynamic_config" => 0, "generated_by" => "Dist::Inkt::Profile::KJETILK version 0.101, CPAN::Meta::Converter version 2.150010", "keywords" => [], "license" => ["perl_5"], "meta-spec" => { url => "http://search.cpan.org/perldoc?CPAN::Meta::Spec", version => 2, }, "name" => "URI-NamespaceMap", "no_index" => { directory => ["eg", "examples", "inc", "t", "xt"] }, "prereqs" => { configure => { requires => { "ExtUtils::MakeMaker" => 6.17 } }, runtime => { recommends => { "RDF::NS" => 20130802, "RDF::NS::Curated" => 0, "RDF::Prefixes" => 0, "XML::CommonNS" => 0, }, requires => { "Carp" => 0, "IRI" => 0.004, "Module::Load::Conditional" => 0, "Moo" => "1.006000", "namespace::autoclean" => "0.20", "perl" => 5.008001, "Sub::Quote" => 0, "Try::Tiny" => 0, "Type::Library" => "1.000000", "Types::URI" => 0.004, "URI" => 1.52, }, }, test => { recommends => { Attean => 0.025 }, requires => { "Test::Deep" => 0, "Test::Exception" => 0, "Test::More" => 0.88, "Test::Requires" => 0, }, suggests => { "RDF::Trine" => 0 }, }, }, "provides" => { "Types::Namespace" => { file => "lib/Types/Namespace.pm", version => "1.10" }, "URI::Namespace" => { file => "lib/URI/Namespace.pm", version => "1.10" }, "URI::NamespaceMap" => { file => "lib/URI/NamespaceMap.pm", version => 1.12 }, "URI::NamespaceMap::ReservedLocalParts" => { file => "lib/URI/NamespaceMap/ReservedLocalParts.pm", version => "1.10", }, }, "release_status" => "stable", "resources" => { bugtracker => { web => "https://github.com/kjetilk/URI-NamespaceMap/issues" }, homepage => "https://metacpan.org/module/URI::NamespaceMap", license => ["http://dev.perl.org/licenses/"], repository => { type => "git", web => "https://github.com/kjetilk/URI-NamespaceMap/", }, x_identifier => "http://purl.org/NET/cpan-uri/dist/URI-NamespaceMap/project", }, "version" => 1.12, "x_contributors" => [ "Dorian Taylor ", "Toby Inkster (TOBYINK) ", "KWAKWA ", ], "x_static_install" => 1, }; my %dynamic_config; my %WriteMakefileArgs = ( ABSTRACT => $meta->{abstract}, AUTHOR => ($EUMM >= 6.5702 ? $meta->{author} : $meta->{author}[0]), DISTNAME => $meta->{name}, VERSION => $meta->{version}, EXE_FILES => [ map $_->{file}, values %{ $meta->{x_provides_scripts} || {} } ], NAME => do { my $n = $meta->{name}; $n =~ s/-/::/g; $n }, test => { TESTS => "t/*.t" }, %dynamic_config, ); $WriteMakefileArgs{LICENSE} = $meta->{license}[0] if $EUMM >= 6.3001; sub deps { my %r; for my $stage (@_) { for my $dep (keys %{$meta->{prereqs}{$stage}{requires}}) { next if $dep eq 'perl'; my $ver = $meta->{prereqs}{$stage}{requires}{$dep}; $r{$dep} = $ver if !exists($r{$dep}) || $ver >= $r{$dep}; } } \%r; } my ($build_requires, $configure_requires, $runtime_requires, $test_requires); if ($EUMM >= 6.6303) { $WriteMakefileArgs{BUILD_REQUIRES} ||= deps('build'); $WriteMakefileArgs{CONFIGURE_REQUIRES} ||= deps('configure'); $WriteMakefileArgs{TEST_REQUIRES} ||= deps('test'); $WriteMakefileArgs{PREREQ_PM} ||= deps('runtime'); } elsif ($EUMM >= 6.5503) { $WriteMakefileArgs{BUILD_REQUIRES} ||= deps('build', 'test'); $WriteMakefileArgs{CONFIGURE_REQUIRES} ||= deps('configure'); $WriteMakefileArgs{PREREQ_PM} ||= deps('runtime'); } elsif ($EUMM >= 6.52) { $WriteMakefileArgs{CONFIGURE_REQUIRES} ||= deps('configure'); $WriteMakefileArgs{PREREQ_PM} ||= deps('runtime', 'build', 'test'); } else { $WriteMakefileArgs{PREREQ_PM} ||= deps('configure', 'build', 'test', 'runtime'); } { my ($minperl) = reverse sort( grep defined && /^[0-9]+(\.[0-9]+)?$/, map $meta->{prereqs}{$_}{requires}{perl}, qw( configure build runtime ) ); if (defined($minperl)) { die "Installing $meta->{name} requires Perl >= $minperl" unless $] >= $minperl; $WriteMakefileArgs{MIN_PERL_VERSION} ||= $minperl if $EUMM >= 6.48; } } my $mm = WriteMakefile(%WriteMakefileArgs); exit(0); README000644001750001750 1044714550071117 15342 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12NAME URI::NamespaceMap - Class holding a collection of namespaces VERSION Version 1.12 SYNOPSIS use URI::NamespaceMap; my $map = URI::NamespaceMap->new( { xsd => 'http://www.w3.org/2001/XMLSchema#' } ); $map->namespace_uri('xsd')->as_string; my $foaf = URI::Namespace->new( 'http://xmlns.com/foaf/0.1/' ); $map->add_mapping(foaf => $foaf); $map->add_mapping(rdf => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' ); $map->list_prefixes; # ( 'foaf', 'rdf', 'xsd' ) $map->foaf; # Returns URI::Namespace object while (my ($prefix, $nsURI) = $map->each_map) { $node->setNamespace($nsURI->as_string, $prefix); # For use with XML::LibXML } DESCRIPTION This module provides an object to manage multiple namespaces for creating URI::Namespace objects and for serializing. METHODS `new ( [ \%namespaces | @prefixes | @uris ] )` Returns a new namespace map object. You can pass a hash reference with mappings from local names to namespace URIs (given as string or RDF::Trine::Node::Resource) or namespaces_map with a hashref. You may also pass an arrayref containing just prefixes and/or namespace URIs, and the module will try to guess the missing part. To use this feature, you need RDF::NS::Curated, RDF::NS, XML::CommonNS or RDF::Prefixes, or preferably all of them. With that, you can do e.g. my $map = URI::NamespaceMap->new( 'rdf', 'xsd', 'foaf' ); and have the correct mappings added automatically. `add_mapping ( $name => $uri )` Adds a new namespace to the map. The namespace URI can be passed as string or a URI::Namespace object. `remove_mapping ( $name )` Removes a namespace from the map given a prefix. `namespace_uri ( $name )` Returns the URI::Namespace object (if any) associated with the given prefix. $name This module creates a method for all the prefixes, so you can say e.g. $map->foaf and get a URI::Namespace object for the FOAF namespace. Since URI::Namespace does the same for local names, you can then say e.g. $map->foaf->name to get a full URI. `list_namespaces` Returns an array of URI::Namespace objects with all the namespaces. `list_prefixes` Returns an array of prefixes. `each_map` Returns an 2-element list where the first element is a prefix and the second is the corresponding URI::Namespace object. `guess_and_add ( @string_or_uri )` Like in the constructor, an array of strings can be given, and the module will attempt to guess appropriate mappings, and add them to the map. `uri ( $prefixed_name )` Returns a URI for an abbreviated string such as 'foaf:Person'. prefix_for `uri ($uri)` Returns the associated prefix (or potentially multiple prefixes, when called in list context) for the given URI. abbreviate `uri ($uri)` Complement to "namespace_uri". Returns the given URI in `foo:bar` format or `undef` if it wasn't matched, therefore the idiom my $str = $nsmap->abbreviate($uri_node) || $uri->as_string; may be useful for certain serialization tasks. WARNING Avoid using the names 'can', 'isa', 'VERSION', and 'DOES' as namespace prefix, because these names are defined as method for every Perl object by default. The method names 'new' and 'uri' are also forbidden. Names of methods of Moose::Object must also be avoided. Using them will result in an error. AUTHORS Chris Prather, `` Kjetil Kjernsmo, `` Gregory Todd Williams, `` Toby Inkster, `` CONTRIBUTORS Dorian Taylor Paul Williams Zakariyya Mughal Chris Prather BUGS Please report any bugs using github SUPPORT You can find documentation for this module with the perldoc command. perldoc URI::NamespaceMap COPYRIGHT & LICENSE Copyright 2012,2013,2014,2015,2016,2017,2018,2019 Gregory Todd Williams, Chris Prather and Kjetil Kjernsmo This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. README.md000644001750001750 1124014550071117 15731 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12# NAME URI::NamespaceMap - Class holding a collection of namespaces # VERSION Version 1.09\_01 # SYNOPSIS use URI::NamespaceMap; my $map = URI::NamespaceMap->new( { xsd => 'http://www.w3.org/2001/XMLSchema#' } ); $map->namespace_uri('xsd')->as_string; my $foaf = URI::Namespace->new( 'http://xmlns.com/foaf/0.1/' ); $map->add_mapping(foaf => $foaf); $map->add_mapping(rdf => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' ); $map->list_prefixes; # ( 'foaf', 'rdf', 'xsd' ) $map->foaf; # Returns URI::Namespace object while (my ($prefix, $nsURI) = $map->each_map) { $node->setNamespace($nsURI->as_string, $prefix); # For use with XML::LibXML } # DESCRIPTION This module provides an object to manage multiple namespaces for creating [URI::Namespace](https://metacpan.org/pod/URI::Namespace) objects and for serializing. # METHODS - `new ( [ \%namespaces | @prefixes | @uris ] )` Returns a new namespace map object. You can pass a hash reference with mappings from local names to namespace URIs (given as string or [RDF::Trine::Node::Resource](https://metacpan.org/pod/RDF::Trine::Node::Resource)) or namespaces\_map with a hashref. You may also pass an arrayref containing just prefixes and/or namespace URIs, and the module will try to guess the missing part. To use this feature, you need [RDF::NS::Curated](https://metacpan.org/pod/RDF::NS::Curated), [RDF::NS](https://metacpan.org/pod/RDF::NS), [XML::CommonNS](https://metacpan.org/pod/XML::CommonNS) or [RDF::Prefixes](https://metacpan.org/pod/RDF::Prefixes), or preferably all of them. With that, you can do e.g. my $map = URI::NamespaceMap->new( 'rdf', 'xsd', 'foaf' ); and have the correct mappings added automatically. - `add_mapping ( $name => $uri )` Adds a new namespace to the map. The namespace URI can be passed as string or a [URI::Namespace](https://metacpan.org/pod/URI::Namespace) object. - `remove_mapping ( $name )` Removes a namespace from the map given a prefix. - `namespace_uri ( $name )` Returns the [URI::Namespace](https://metacpan.org/pod/URI::Namespace) object (if any) associated with the given prefix. - `$name` This module creates a method for all the prefixes, so you can say e.g. $map->foaf and get a [URI::Namespace](https://metacpan.org/pod/URI::Namespace) object for the FOAF namespace. Since [URI::Namespace](https://metacpan.org/pod/URI::Namespace) does the same for local names, you can then say e.g. $map->foaf->name to get a full [URI](https://metacpan.org/pod/URI). - `list_namespaces` Returns an array of [URI::Namespace](https://metacpan.org/pod/URI::Namespace) objects with all the namespaces. - `list_prefixes` Returns an array of prefixes. - `each_map` Returns an 2-element list where the first element is a prefix and the second is the corresponding [URI::Namespace](https://metacpan.org/pod/URI::Namespace) object. - `guess_and_add ( @string_or_uri )` Like in the constructor, an array of strings can be given, and the module will attempt to guess appropriate mappings, and add them to the map. - `uri ( $prefixed_name )` Returns a URI for an abbreviated string such as 'foaf:Person'. - prefix\_for `uri ($uri)` Returns the associated prefix (or potentially multiple prefixes, when called in list context) for the given URI. - abbreviate `uri ($uri)` Complement to ["namespace\_uri"](#namespace_uri). Returns the given URI in `foo:bar` format or `undef` if it wasn't matched, therefore the idiom my $str = $nsmap->abbreviate($uri_node) || $uri->as_string; may be useful for certain serialization tasks. # WARNING Avoid using the names 'can', 'isa', 'VERSION', and 'DOES' as namespace prefix, because these names are defined as method for every Perl object by default. The method names 'new' and 'uri' are also forbidden. Names of methods of [Moose::Object](https://metacpan.org/pod/Moose::Object) must also be avoided. Using them will result in an error. # AUTHORS Chris Prather, `` Kjetil Kjernsmo, `` Gregory Todd Williams, `` Toby Inkster, `` # CONTRIBUTORS Dorian Taylor Paul Williams # BUGS Please report any bugs using [github](https://github.com/kjetilk/URI-NamespaceMap/issues) # SUPPORT You can find documentation for this module with the perldoc command. perldoc URI::NamespaceMap # COPYRIGHT & LICENSE Copyright 2012,2013,2014,2015,2016,2017,2018,2019 Gregory Todd Williams, Chris Prather and Kjetil Kjernsmo This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SIGNATURE000644001750001750 715614550071117 15731 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.88. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: RIPEMD160 SHA256 14988c556c565bc09d19bbc58a4b55d53115a52a08e882804cdeff4737995703 COPYRIGHT SHA256 d8e350803b7158480d46e7b6e924d262333a744ed029fca7289eb94f4b5298e4 CREDITS SHA256 92737e449bf196f42f30e2c91769bfaef3a7964661023fdc4b379fb53c7c1d11 Changes SHA256 84a33dc0ac383e4701a603782484d12eb45941018b44a0bbf3021778ffc74275 INSTALL SHA256 a74fb7155973ccfe1ef2c24014143c3c76464aae9fc63d9f870ea024af38f504 LICENSE SHA256 1bef034e4a905852ddeb9c46539d7a29c9565649ddb4b44309fea66c7feff860 MANIFEST SHA256 f3bcdab8e0018d7960a98a165772507fe55a00d2c83c8fa463bd60bfc50c6425 META.json SHA256 09f0416bd7af90c3dd398dca6fd5722387fbb1fecb7d3be1f436b968d8246bd2 META.yml SHA256 bbe83b840062f362177d35ce70fbf064d38786191bea0ed8a868b9f4332f5789 Makefile.PL SHA256 8ba9bf375d8a972fe97b7c1f20340b8d53c680fa023d4fe6b54696a6e759c54e README SHA256 b467f4438bd59270a3cd99f4b09caf2c0cc163574e7e0e9409678202c8c6c63b README.md SHA256 fc0c44e7e8d29757350f1cc3bbebd51fb1b6b33dfc1b160bbef92073dd61719b dist.ini SHA256 d7e09c3f1632a46b25bd41177d60557d4d2baff0020c59982088d02341f37da9 doap.ttl SHA256 d0b23fe19acc61a7e226ab60db42052c4a3cffc722ac67c26decf69f2c937edb lib/Types/Namespace.pm SHA256 aee2e7073cb424f8d714669c8049eee7c12b6b38e48f068111c4b6f02edc4258 lib/URI/Namespace.pm SHA256 0cf74480522294c9c677bb036b8828604ea5d938ffb19e0f82415329052a5bfd lib/URI/NamespaceMap.pm SHA256 fa9717d1c8d5365943544e7d2dbf5826719fed43ed2885e96558e21c7cda267d lib/URI/NamespaceMap/ReservedLocalParts.pm SHA256 f86d370c56b648fe13e7adb4b96f0628d6b34aa94b990177247ad8a41103fd6b t/iri.t SHA256 e79254400436c6e12b453bb2cbd2e57fb502ec26e5c9f8959437ac4bfb8423b8 t/justuri.t SHA256 b68aba1dc82d2d988c7206331c00479b280d43a4ac056edebfdd38280eb626cb t/lib/CommonTest.pm SHA256 f220ff09828dab4698324a0e543b6dd88b5bd416eada60d6d656222af84430c6 t/namespacemap.t SHA256 3685693e54d63b31a1d071994381c6ac0afa33c53f43f09355b1ed5928fc1d90 t/prefixguess-none.t SHA256 08e339c711342e7c2ab5f314d68849d3812d5f5789d063b8b69531e5d97f227c t/prefixguess.t SHA256 71e8dd1c0493a24049fd032595311f8c61a9a1471ad9a5c290f46d8b6c295d84 t/reserved.t SHA256 3c892d5ff5395299826e9d0f1a18508c2d5ec3fec099bba1aaf6200fd2005563 t/types-attean.t SHA256 db752fc24635c7eda4a70a4c82b95dfdc551e423aa615948a234d4fdecc7d890 t/types-trine.t SHA256 c67f74c24e3363bf70e51f80e16ea3ea69d6927517d1e7fd842873e806b1c583 t/types.t -----BEGIN PGP SIGNATURE----- iQIzBAEBAwAdFiEEDsyLxtCi6bk7pBcmf77o3zqeSqUFAmWgck8ACgkQf77o3zqe SqVxMQ//fUtZi9ukaTXhcdNVq4iUsZwRpYyXSTzkFCq/635fevUSHv6od/G9hmvx Do1tReVgS/iK7GrOS/GMHOjJpUnhrGAljkrmtKlbC1LxDRrTCbOQx/9qOFcLx9E7 ugIsqyqlodURVtckw7VKYeHPmPsNIQCSyWqzN2919vBu5bAVylzvRobyv+yR92dI AGysCpUZf/xkX87DtPZgr7UsWSIj7RSnybvX5ZYmXZ8nLCYskP4DRczO0aezhCwL Kz+GHdtkdDxtlBW/jt6IkCy2gzvhN0KkVfPUwmbtEIHHOR2addpD9idJ1U9mCyVG VrYdZFz8G1bMxXTbSxgJL4aSZg6On1RIVDbuhsOFL0TPZZ7c0mpO1yUz7Bu6mQ4m AiePoulxXHqDsKMacITpv6sK1P5PjUBd+Un8ZHKY8so1wJCg3mEdSkJosymTTkKK LOaMRlFbEzC6BpSNdeaLkj8F7FJdT/h2upfizs/w6PdZ1v6pgqj6hwFXW/agMs7Z hY3F8BDdXJ2QXLt98kddFLakETvbvRVMX3mKVKPmY/q10UBEE1dq7LYyKFjOOLEN nYpu5Fm7hPO5KU1eBDtn3YbspFoTBHEbYEgEq1UV4LEWpQBX9T5QExas8/WQarOO km9y3exUqyJciG2Ct7vMcbLxrAmz2/zRQcZXAPh0CSE2qhq/aF8= =tckr -----END PGP SIGNATURE----- dist.ini000644001750001750 17014550071117 16056 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12;;class='Dist::Inkt::Profile::KJETILK' ;;name='URI-NamespaceMap' ;;skip_whitespace_test=1 ;;also_skip = [qr/README.pod/]doap.ttl000644001750001750 4674014550071117 16137 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12@prefix dc: . @prefix doap: . @prefix doap-changeset: . @prefix doap-deps: . @prefix foaf: . @prefix owl: . @prefix prov: . @prefix rdfs: . @prefix wot: . @prefix xsd: . dc:creator ; dc:subject ; dc:title "DOAP for URI-NamespaceMap"@en. rdfs:comment "the same terms as the Perl 5 programming language system itself"@en. a foaf:Person; foaf:mbox ; foaf:name "Dorian Taylor"; owl:sameAs , . a foaf:Person; foaf:mbox ; foaf:name "Gregory Todd Williams"; owl:sameAs , . a doap:Project; dc:identifier "URI::NamespaceMap"^^doap-deps:CpanId; dc:relation ; doap-deps:runtime-recommendation [ doap-deps:on "RDF::NS::Curated"^^doap-deps:CpanId ], [ doap-deps:on "RDF::NS 20130802"^^doap-deps:CpanId ], [ doap-deps:on "RDF::Prefixes"^^doap-deps:CpanId ], [ doap-deps:on "XML::CommonNS"^^doap-deps:CpanId ]; doap-deps:runtime-requirement [ doap-deps:on "perl 5.008001"^^doap-deps:CpanId ], [ doap-deps:on "Moo 1.006000"^^doap-deps:CpanId ], [ doap-deps:on "URI 1.52"^^doap-deps:CpanId ], [ doap-deps:on "IRI 0.004"^^doap-deps:CpanId ], [ doap-deps:on "Types::URI 0.004"^^doap-deps:CpanId ], [ doap-deps:on "Type::Library 1.000000"^^doap-deps:CpanId; ], [ doap-deps:on "Try::Tiny"^^doap-deps:CpanId ], [ doap-deps:on "Module::Load::Conditional"^^doap-deps:CpanId; ], [ doap-deps:on "Carp"^^doap-deps:CpanId ], [ doap-deps:on "Sub::Quote"^^doap-deps:CpanId ], [ doap-deps:on "namespace::autoclean 0.20"^^doap-deps:CpanId; ]; doap-deps:test-recommendation [ doap-deps:on "Attean 0.025"^^doap-deps:CpanId ]; doap-deps:test-requirement [ doap-deps:on "Test::More 0.88"^^doap-deps:CpanId ], [ doap-deps:on "Test::Exception"^^doap-deps:CpanId ], [ doap-deps:on "Test::Deep"^^doap-deps:CpanId ], [ doap-deps:on "Test::Requires"^^doap-deps:CpanId ]; doap-deps:test-suggestion [ doap-deps:on "RDF::Trine"^^doap-deps:CpanId ]; doap:bug-database ; doap:created "2012-08-27"^^xsd:date; doap:developer , , ; doap:homepage ; doap:license ; doap:maintainer , , ; doap:name "URI-NamespaceMap"; doap:programming-language "Perl"; doap:release , , , , , , , , , , , , , , , , , , , , , ; doap:repository [ a doap:GitRepository; doap:browse ; prov:has_provenance ; ]; doap:security-contact ; doap:shortdesc "Namespace manipulation and prefix mapping for XML, RDF, etc."@en; owl:sameAs ; rdfs:seeAlso . a doap:Version; rdfs:label "Initial release."@en; dc:issued "2012-08-28"^^xsd:date; doap:revision "0.01"^^xsd:string. a doap:Version; rdfs:label "Minor bugfixes."@en; dc:issued "2012-08-30"^^xsd:date; doap:revision "0.02"^^xsd:string. a doap:Version; rdfs:label "Reverse lookups."@en; dc:issued "2012-10-23"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Change; rdfs:label "Stop using blank node in makefile.ttl to fix version_from."@en; ], [ a doap-changeset:Addition; rdfs:label "Adding reverse lookups, i.e. abbreviation and prefix_for."@en; doap-changeset:blame ; ]; ]; doap:revision "0.04"^^xsd:string. a doap:Version; rdfs:label "Bugfix release."@en; dc:issued "2012-11-28"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "URI::Namespace must be used from URI::NamespaceMap."@en; ]; ]; doap:revision "0.06"^^xsd:string. a doap:Version; rdfs:label "Prefix guessing."@en; dc:issued "2014-05-19"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Addition; rdfs:label "Prefix guessing using RDF::NS, RDF::Prefixes or XML::CommonNS."@en; ], [ a doap-changeset:Bugfix; rdfs:label "Fix breakage in terms with hyphens."@en; doap-changeset:blame ; ]; ]; doap:revision "0.08"^^xsd:string. a doap:Version; rdfs:label "Compatibility with RDF::Trine::NamespaceMap."@en; dc:issued "2014-05-21"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Addition; rdfs:label "Make it possible to send local part to the uri method of URI::Namespace."@en; doap-changeset:thanks ; ]; ]; doap:revision "0.10"^^xsd:string. a doap:Version; rdfs:label "Support IRI module."@en; dc:issued "2014-09-29"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Addition; rdfs:label "Support the new IRI module."@en; doap-changeset:blame ; ], [ a doap-changeset:Bugfix; rdfs:label "Silence warnings when URI doesn't have local part."@en; ], [ a doap-changeset:Addition; rdfs:label "Warn the user in test when they have too old RDF::NS."@en; ], [ a doap-changeset:Addition; rdfs:label "Use Types::URI."@en; ], [ a doap-changeset:Addition; rdfs:label "Link Debian packages in metadata."@en; ]; ]; doap:revision "0.12"^^xsd:string; owl:sameAs . a doap:Version; rdfs:label "Moo refactoring."@en; dc:issued "2014-10-05"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Change; rdfs:label "Port to Moo."@en; doap-changeset:blame ; ], [ a doap-changeset:Change; rdfs:label "Convert packaging to Dist::Inkt."@en; doap-changeset:blame ; ], [ a doap-changeset:Addition; rdfs:label "Warn the user when they have too old RDF::NS but not in automated tests."@en; ]; ]; doap:revision "0.20"^^xsd:string. a doap:Version; rdfs:label "Fix missing Changes."@en; dc:issued "2014-10-05"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "Fix missing Changes."@en; ]; ]; doap:revision "0.21"^^xsd:string. a doap:Version; rdfs:label "Clean up source tree."@en; dc:issued "2014-10-15"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Change; rdfs:label "Clean up source tree."@en; ]; ]; doap:revision "0.22"^^xsd:string; owl:sameAs . a doap:Version; rdfs:label "Improve documentation."@en; dc:issued "2014-12-10"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Change; rdfs:label "Reindent using Emacs smart-tabs."@en; ], [ a doap-changeset:Change; rdfs:label "Improve documentation, autoloader."@en; ], [ a doap-changeset:Change; rdfs:label "Some code cleanup."@en; ], [ a doap-changeset:Bugfix; rdfs:label "Use a string comparison in failing test."@en; ]; ]; doap:revision "0.24"^^xsd:string; owl:sameAs . a doap:Version; rdfs:label "Support for RDF::NS::Curated."@en; dc:issued "2015-09-01"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Change; rdfs:label "Support for RDF::NS::Curated."@en; ]; ]; doap:revision "0.26"^^xsd:string; owl:sameAs . a doap:Version; rdfs:label "Bugfix release."@en; dc:issued "2015-09-23"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "Had forgotten to update error messages."@en; ]; ]; doap:revision "0.28"^^xsd:string; owl:sameAs . a doap:Version; rdfs:label "Test bugfix."@en; dc:issued "2016-02-12"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "Remove a test because toolchain makes it hard to get the correct version."@en; ]; ]; doap:revision "0.30"^^xsd:string; owl:sameAs . a doap:Version; rdfs:label "New guessing method and improved diagnostics."@en; dc:issued "2016-12-29"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "Rework some tests that fails in strange ways."@en; ], [ a doap-changeset:Addition; rdfs:label "Add method for adding guesses post-construction."@en; ], [ a doap-changeset:Change; rdfs:label "Use carp instead of warns."@en; ]; ]; doap:revision "0.32"^^xsd:string. a doap:Version; rdfs:label "Check prefixes so they don't conflict with existing methods."@en; dc:issued "2017-01-18"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Removal; rdfs:label "Remove strict/warnings pragmas where Moo is used."@en; doap-changeset:blame ; ], [ a doap-changeset:Addition; rdfs:label "Prefixes that will conflict with existing methods will throw an error."@en; doap-changeset:blame ; ], [ a doap-changeset:Change; rdfs:label "Minor cleanups."@en; ], [ a doap-changeset:Change; rdfs:label "Improve the BUILDARGS code."@en; doap-changeset:thanks ; ]; ]; doap:revision "1.00"^^xsd:string. a doap:Version; rdfs:label "Append a hash to URIs needing it."@en; dc:issued "2017-06-21"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "When adding local names, check if namespace ends in hash or slash, and append hash if not."@en; ]; ]; doap:revision "1.02"^^xsd:string. a doap:Version; rdfs:label "Append a hash to only to XSD URIs."@en; dc:issued "2017-07-08"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "Partly revert fix in 1.02, now only append a hash to the XML Schema URI (closes issue #14)."@en; ]; ]; doap:revision "1.04"^^xsd:string; owl:sameAs . a doap:Version; rdfs:label "Add each_map method."@en; dc:issued "2018-01-27"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Addition; rdfs:label "Add each_map method"@en; ], [ a doap-changeset:Addition; rdfs:label "Check for Iri in scrubber"@en; ]; ]; doap:revision "1.06"^^xsd:string; owl:sameAs . a doap:Version; rdfs:label "Add local_part method."@en; dc:issued "2019-04-15"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Addition; rdfs:label "Add local_part method to URI::Namespace."@en; ]; ]; doap:revision "1.08"^^xsd:string; owl:sameAs . a doap:Version; rdfs:label "Add more coercions."@en; dc:issued "2019-11-20"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Addition; rdfs:label "Add coercions for RDF::Trine and Attean classes."@en; ], [ a doap-changeset:Addition; rdfs:label "Bring Namespace.pm test coverage to 100%."@en; ]; ]; doap:revision "1.10"^^xsd:string; owl:sameAs . a doap:Version; rdfs:label "Add new automations and small fixes."@en; dc:issued "2024-01-11"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Update; rdfs:label "Add new Github CI automations."@en; ], [ a doap-changeset:Removal; rdfs:label "Remove Travis CI."@en; doap-changeset:thanks ; ], [ a doap-changeset:Addition; rdfs:label "Add explicit DESTROY."@en; doap-changeset:thanks ; ]; ]; doap:revision "1.12"^^xsd:string; owl:sameAs . a foaf:Person; foaf:mbox ; foaf:name "Kjetil Kjernsmo"; foaf:nick "KjetilK"; owl:sameAs , ; rdfs:seeAlso ; wot:hasKey _:B1. a foaf:Person; foaf:mbox ; foaf:name "Chris Prather"; owl:sameAs . a foaf:Person; doap:mbox ; doap:name "Toby Inkster"; doap:page ; foaf:mbox ; foaf:name "Toby Inkster"; owl:sameAs , . a foaf:Person; foaf:name "Zakariyya Mughal". a foaf:Person; foaf:homepage ; foaf:mbox ; foaf:name "Kjetil Kjernsmo"; foaf:nick "KjetilK"; owl:sameAs , , ; rdfs:seeAlso , ; wot:hasKey _:B1. _:B1 a wot:PubKey; wot:fingerprint "0ECC8BC6D0A2E9B93BA417267FBEE8DF3A9E4AA5". iri.t000644001750001750 200714550071117 15646 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12/tuse Test::More; use strict; use URI; use utf8; use_ok('URI::Namespace'); use_ok('URI::NamespaceMap'); my $ns = URI::Namespace->new( 'http://www.w3.org/2001/sw/DataAccess/tests/data/i18n/kanji.ttl#' ); isa_ok( $ns, 'URI::Namespace' ); my $uri = $ns->as_string; is( $uri, 'http://www.w3.org/2001/sw/DataAccess/tests/data/i18n/kanji.ttl#', 'expected IRI string for namespace' ); my $iri = $ns->iri("納豆"); is($iri->as_string, "http://www.w3.org/2001/sw/DataAccess/tests/data/i18n/kanji.ttl#納豆", 'expected IRI string'); my $uri = $ns->uri("納豆"); is($uri->as_string, "http://www.w3.org/2001/sw/DataAccess/tests/data/i18n/kanji.ttl#%E7%B4%8D%E8%B1%86", 'expected URI encoding of IRI string'); my $map = URI::NamespaceMap->new(); $map->add_mapping( "食" => $ns ); is_deeply([$map->list_prefixes], ["食"], 'expected unicode namespace prefix in map'); is($map->namespace_uri('食')->as_string, 'http://www.w3.org/2001/sw/DataAccess/tests/data/i18n/kanji.ttl#', 'expected namespacemap prefix URI string'); done_testing; justuri.t000644001750001750 1070514550071117 16614 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12/tuse Test::More; use strict; use URI; use_ok('URI::Namespace'); subtest 'Straightforward appends' => sub { my $foaf = URI::Namespace->new( 'http://xmlns.com/foaf/0.1/' ); isa_ok( $foaf, 'URI::Namespace' ); my $uri = $foaf->as_string; is( $uri, 'http://xmlns.com/foaf/0.1/', 'expected resource object namespace from FOAF namespace map' ); is($foaf->name->as_string, 'http://xmlns.com/foaf/0.1/name', 'expected resource object for FOAF namespace with name' ); is($foaf->uri('Person')->as_string, 'http://xmlns.com/foaf/0.1/Person', 'expected resource object for FOAF namespace with Person when set with uri method' ); is($foaf->uri('isa')->as_string, 'http://xmlns.com/foaf/0.1/isa', 'expected resource object for FOAF namespace with isa when set with uri method' ); }; subtest 'Missing hash on XSD' => sub { my $xsd = URI::Namespace->new( 'http://www.w3.org/2001/XMLSchema' ); isa_ok( $xsd, 'URI::Namespace' ); my $uri = $xsd->as_string; is( $uri, 'http://www.w3.org/2001/XMLSchema', 'expected resource object for namespace from XSD namespace map' ); is( $xsd->iri->as_string, 'http://www.w3.org/2001/XMLSchema', 'expected resource object for namespace from XSD namespace map through IRI' ); is($xsd->integer->as_string, 'http://www.w3.org/2001/XMLSchema#integer', 'expected resource object for XSD namespace with integer' ); is($xsd->uri('decimal')->as_string, 'http://www.w3.org/2001/XMLSchema#decimal', 'expected resource object for XSD namespace with decimal when set with uri method' ); is($xsd->iri('boolean')->as_string, 'http://www.w3.org/2001/XMLSchema#boolean', 'expected resource object for XSD namespace with boolean when set with iri method' ); }; subtest 'With hash on XSD' => sub { my $xsd = URI::Namespace->new( 'http://www.w3.org/2001/XMLSchema#' ); isa_ok( $xsd, 'URI::Namespace' ); my $uri = $xsd->as_string; is( $uri, 'http://www.w3.org/2001/XMLSchema#', 'expected resource object for namespace from XSD namespace map with hash' ); is( $xsd->iri->as_string, 'http://www.w3.org/2001/XMLSchema#', 'expected resource object for namespace from XSD namespace map with hash through IRI' ); is($xsd->byte->as_string, 'http://www.w3.org/2001/XMLSchema#byte', 'expected resource object for XSD namespace with byte' ); is($xsd->uri('long')->as_string, 'http://www.w3.org/2001/XMLSchema#long', 'expected resource object for XSD namespace with long when set with uri method' ); }; subtest 'Example without hash or slash' => sub { my $ex = URI::Namespace->new( 'http://www.example.org' ); isa_ok( $ex, 'URI::Namespace' ); my $uri = $ex->as_string; is( $uri, 'http://www.example.org', 'expected resource object for namespace from EX namespace map without hash or slash' ); is($ex->Order->as_string, 'http://www.example.orgOrder', 'expected resource object for EX namespace with Order' ); is($ex->uri('Order')->as_string, 'http://www.example.orgOrder', 'expected resource object for EX namespace with Order when set with uri method' ); }; subtest 'Get local part based on ns' => sub { my $exh = URI::Namespace->new( 'http://www.example.org/foo#'); my $exs = URI::Namespace->new( 'http://www.example.org/foo/'); isa_ok( $exh, 'URI::Namespace' ); isa_ok( $exs, 'URI::Namespace' ); is($exh->local_part('http://www.example.org/foo#bar'), 'bar', 'String input with hash is OK'); is($exs->local_part('http://www.example.org/foo/dahut'), 'dahut', 'String input with slash is OK'); is($exh->local_part(URI->new('http://www.example.org/foo#bar')), 'bar', 'URI input with hash is OK'); is($exs->local_part(URI->new('http://www.example.org/foo/dahut')), 'dahut', 'URI input with slash is OK'); is($exh->local_part(IRI->new('http://www.example.org/foo#bar')), 'bar', 'IRI input with hash is OK'); is($exs->local_part(IRI->new('http://www.example.org/foo/dahut')), 'dahut', 'IRI input with slash is OK'); is($exh->local_part('http://www.example.org/foo#'), undef, 'String input matches exactly hash is OK'); is($exs->local_part('http://www.example.com/foo/dahut'), undef, 'String input doesnt match with slash is OK'); is($exh->local_part(URI->new('http://www.example.com/foo#bar')), undef, 'URI input doesnt match with hash is OK'); is($exs->local_part(URI->new('http://www.example.org/foo/')), undef, 'URI input matches exactly with slash is OK'); is($exh->local_part(IRI->new('http://www.example.')), undef, 'IRI input substring with hash is OK'); is($exs->local_part(IRI->new('http://www.example')), undef, 'IRI input substring with slash is OK'); }; done_testing; namespacemap.t000644001750001750 733214550071117 17523 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12/tuse Test::More; use Test::Exception; use strict; use URI; use_ok('URI::NamespaceMap'); use_ok('URI::Namespace'); my $foaf = URI::Namespace->new( 'http://xmlns.com/foaf/0.1/' ); isa_ok($foaf, 'URI::Namespace'); is($foaf->as_string, 'http://xmlns.com/foaf/0.1/', 'FOAF URI string OK'); my $rdf = URI::Namespace->new( 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' ); { my $map = URI::NamespaceMap->new; isa_ok( $map, 'URI::NamespaceMap' ); } { my $map = URI::NamespaceMap->new( { foaf => $foaf, rdf => $rdf } ); isa_ok( $map, 'URI::NamespaceMap' ); } { my $map = URI::NamespaceMap->new( { xsd => 'http://www.w3.org/2001/XMLSchema#' } ); isa_ok( $map, 'URI::NamespaceMap' ); } { my $map = URI::NamespaceMap->new( namespace_map => { xsd => 'http://www.w3.org/2001/XMLSchema#' } ); isa_ok( $map, 'URI::NamespaceMap' ); } { my $map = URI::NamespaceMap->new( namespace_map => { foaf => $foaf, rdf => $rdf } ); isa_ok( $map, 'URI::NamespaceMap' ); } throws_ok { my $map = URI::NamespaceMap->new( { isa => 'http://example.org/ns/isa#' } ); } qr/prohibited as local part/, "Throws if isa is used as local part."; my $map = URI::NamespaceMap->new( { foaf => $foaf, rdf => $rdf, xsd => 'http://www.w3.org/2001/XMLSchema#' } ); isa_ok( $map, 'URI::NamespaceMap' ); is_deeply([sort $map->list_prefixes], ['foaf', 'rdf', 'xsd' ], 'Prefix listing OK'); is($map->namespace_uri('foaf')->as_string, 'http://xmlns.com/foaf/0.1/', 'FOAF URI string OK'); is($map->namespace_uri('xsd')->as_string, 'http://www.w3.org/2001/XMLSchema#', 'XSD URI string OK'); TODO: { local $TODO = 'need to stringify?'; is_deeply([$map->list_namespaces], [map { URI::Namespace->new($_) } 'http://xmlns.com/foaf/0.1/','http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'http://www.w3.org/2001/XMLSchema#' ]); } my $ns = $map->xsd; isa_ok( $ns, 'URI::Namespace' ); $map->remove_mapping( 'xsd' ); is( $map->xsd, undef, 'removed namespace' ); isa_ok($ns->uri, 'URI'); isa_ok($ns->iri, 'IRI'); # ensure that methods delegated to URI are working... is($ns->rel('http://www.w3.org/2001/'), 'XMLSchema#', 'namespace delegates rel method'); is($ns->abs('http://example.org/'), 'http://www.w3.org/2001/XMLSchema#', 'namespace delegates abs method'); ok($ns->eq(URI->new('http://www.w3.org/2001/XMLSchema#')), 'namespace delegates eq method'); is($map->foaf->canonical, 'http://xmlns.com/foaf/0.1/', 'namespace delegates canonical method'); $map = URI::NamespaceMap->new( { foaf => 'http://xmlns.com/foaf/0.1/', '' => 'http://example.org/' } ); isa_ok( $map, 'URI::NamespaceMap' ); is ( $map->uri(':foo')->as_string, 'http://example.org/foo', 'empty prefix' ); $map->add_mapping( rdf => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' ); my $type = $map->rdf('type'); isa_ok( $type, 'URI' ); is( $type->as_string, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'expected uri for namespace map qname' ); $ns = $map->foaf; isa_ok( $ns, 'URI::Namespace' ); my $uri = $ns->as_string; is( $uri, 'http://xmlns.com/foaf/0.1/', 'expected resource object for namespace from namespace map' ); $type = $map->uri('rdf:type'); isa_ok( $type, 'URI' ); is( $type->as_string, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'resolving via uri method' ); $uri = $map->uri('foaf:'); isa_ok( $uri, 'URI' ); is( $uri->as_string, 'http://xmlns.com/foaf/0.1/', 'resolving via uri method' ); # abbreviate implicitly checks prefix_for is($map->abbreviate($map->foaf('Person')), 'foaf:Person', 'abbrev with prefix'); is($map->abbreviate($map->uri(':foo')), ':foo', 'abbrev no prefix '); is($map->abbreviate('http://derp.net/foobar'), undef, 'abbrev no match'); throws_ok { $map->add_mapping( isa => 'http://example.org/ns/isa#' ); } qr/prohibited as local part/, "Throws if isa is used as local part."; done_testing; prefixguess-none.t000644001750001750 136214550071117 20367 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12/tuse Test::More; use Test::Exception; use strict; use Module::Load::Conditional qw[check_install]; my $xmlns = check_install( module => 'XML::CommonNS'); my $rdfns = check_install( module => 'RDF::NS', version => 20130802); my $rnscu = check_install( module => 'RDF::NS::Curated'); my $rdfpr = check_install( module => 'RDF::Prefixes'); if (defined $xmlns || defined $rdfns || defined $rnscu || defined $rdfpr) { plan skip_all => 'One of the namespace modules is installed' } use_ok('URI::NamespaceMap'); throws_ok { my $map = URI::NamespaceMap->new( [ 'foaf', 'rdf' ] ); } qr/To resolve an array, you need at least one of RDF::NS::Curated, XML::CommonNS, RDF::NS or RDF::Prefixes/, 'Throws OK if no prefix module is installed.'; done_testing; prefixguess.t000644001750001750 1262514550071117 17456 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12/tuse Test::More; use Test::Exception; use strict; use Module::Load::Conditional qw[check_install]; my $xmlns = check_install( module => 'XML::CommonNS'); my $rdfns = check_install( module => 'RDF::NS', version => 20130802); my $rnscu = check_install( module => 'RDF::NS::Curated'); my $rdfpr = check_install( module => 'RDF::Prefixes'); unless (defined $xmlns || defined $rdfns || defined $rnscu || defined $rdfpr) { plan skip_all => 'None of the namespace modules XML::CommonNS, RDF::NS::Curated, RDF::NS or RDF::Prefixes are installed' } if (defined $rdfns) { require RDF::NS; unless (defined($RDF::NS::VERSION)) { diag('RDF::NS appears to be installed, but no version was found. Not using'); $rdfns = undef; } elsif ($RDF::NS::VERSION < 20130802) { plan skip_all => 'RDF::NS is old, please upgrade. Skipping tests, other functionality is usually OK.'; } } my $diag = "Status for optional modules: "; $diag .= (defined $rnscu) ? " With " : " Without "; $diag .= "RDF::NS::Curated,"; $diag .= (defined $xmlns) ? " with " : " without "; $diag .= "XML::CommonNS,"; $diag .= (defined $rdfns) ? " with " : " without "; $diag .= "RDF::NS,"; $diag .= (defined $rdfpr) ? " with " : " without "; $diag .= "RDF::Prefixes."; note($diag); use_ok('URI::NamespaceMap') ; SKIP: { skip "XML::CommonNS, RDF::NS::Curated or RDF::NS needed", 7 unless(defined $xmlns || defined $rdfns || defined $rnscu); my $map = URI::NamespaceMap->new( [ 'foaf', 'rdf' ] ); isa_ok( $map, 'URI::NamespaceMap' ); ok($map->namespace_uri('foaf'), 'FOAF returns something'); ok($map->namespace_uri('rdf'), 'RDF returns something'); is($map->namespace_uri('foaf')->as_string, 'http://xmlns.com/foaf/0.1/', 'FOAF URI string OK'); is($map->namespace_uri('rdf')->as_string, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'RDF URI string OK'); $map->guess_and_add('dc'); ok($map->namespace_uri('dc'), 'DC returns something'); note('DC prefix differs between different modules'); is($map->namespace_uri('dc')->as_string, (defined $rnscu) ? 'http://purl.org/dc/terms/' : 'http://purl.org/dc/elements/1.1/', 'DC URI string OK'); } SKIP: { skip "RDF::NS or RDF::NS::Curated needed", 5 unless (defined $rdfns || defined $rnscu); my $map = URI::NamespaceMap->new( [ 'foaf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'xsd' ] ); isa_ok( $map, 'URI::NamespaceMap' ); is($map->namespace_uri('foaf')->as_string, 'http://xmlns.com/foaf/0.1/', 'FOAF URI string OK'); is($map->namespace_uri('rdf')->as_string, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'RDF URI string OK'); is_deeply([sort $map->list_prefixes], ['foaf', 'rdf', 'xsd' ], 'Prefix listing OK'); } SKIP: { skip "RDF::NS or RDF::NS::Curated needed", 5 unless(defined $rdfns || defined $rnscu); my $map = URI::NamespaceMap->new( [ 'foaf', 'rdfs' ] ); isa_ok( $map, 'URI::NamespaceMap' ); ok($map->namespace_uri('foaf'), 'FOAF returns something'); is($map->namespace_uri('foaf')->as_string, 'http://xmlns.com/foaf/0.1/', 'FOAF URI string OK'); ok($map->namespace_uri('rdfs'), 'RDFS returns something') || diag('RDF::NS is version ' . $RDF::NS::VERSION . ' and may need upgrading'); is($map->namespace_uri('rdfs')->as_string, 'http://www.w3.org/2000/01/rdf-schema#', 'RDFS URI string OK'); } SKIP: { skip "RDF::NS needed", 2 unless(defined $rdfns); my $map = URI::NamespaceMap->new( [ 'acl' ] ); isa_ok( $map, 'URI::NamespaceMap' ); ok($map->namespace_uri('acl'), 'acl returns something') || diag('RDF::NS is version ' . $RDF::NS::VERSION . ' and may need upgrading'); $map->guess_and_add('http://example.org/'); ok($map->namespace_uri('ex'), 'ex returns something'); is($map->namespace_uri('ex')->as_string, 'http://example.org/', 'ex URI string OK'); } SKIP: { skip "RDF::Prefixes and RDF::NS or RDF::NS::Curated needed", 5 unless((defined $rdfns || defined $rnscu) && defined $rdfpr); my $map = URI::NamespaceMap->new( [ 'http://example.org/ns/sdfhkd4f#', 'http://www.w3.org/2000/01/rdf-schema#' ] ); isa_ok( $map, 'URI::NamespaceMap' ); ok($map->namespace_uri('sdfhkd4f'), 'Keyboard cat returns something'); ok($map->namespace_uri('rdfs'), 'RDFS returns something'); is($map->namespace_uri('sdfhkd4f')->as_string, 'http://example.org/ns/sdfhkd4f#', 'Keyboard cat URI string OK'); is($map->namespace_uri('rdfs')->as_string, 'http://www.w3.org/2000/01/rdf-schema#', 'RDFS URI string OK'); } SKIP: { skip "RDF::Prefixes", 11 unless(defined $rdfpr); my $map = URI::NamespaceMap->new( [ 'http://www.w3.org/2000/01/rdf-schema#', 'http://usefulinc.com/ns/doap#' ] ); isa_ok( $map, 'URI::NamespaceMap' ); ok($map->namespace_uri('rdfs'), 'RDFS returns something'); ok($map->namespace_uri('doap'), 'DOAP returns something'); is($map->namespace_uri('rdfs')->as_string, 'http://www.w3.org/2000/01/rdf-schema#', 'RDFS URI string OK'); is($map->namespace_uri('doap')->as_string, 'http://usefulinc.com/ns/doap#', 'DOAP URI string OK'); $map->guess_and_add('http://www.w3.org/2002/07/owl#'); ok($map->namespace_uri('owl'), 'owl returns something'); is($map->namespace_uri('owl')->as_string, 'http://www.w3.org/2002/07/owl#', 'owl URI string OK'); $map->guess_and_add('http://example.org/isa#'); ok($map->namespace_uri('isax'), 'isax returns something'); is($map->namespace_uri('isax')->as_string, 'http://example.org/isa#', 'isax URI string OK'); my $map2 = URI::NamespaceMap->new( [ 'http://example.org/does#' ] ); isa_ok( $map2, 'URI::NamespaceMap' ); ok($map2->namespace_uri('doesx'), 'doesx returns something'); } done_testing; reserved.t000644001750001750 124714550071117 16707 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12/tuse strict; use warnings; use Test::More; use URI::NamespaceMap::ReservedLocalParts; subtest 'allowed/disallowed namespaces by default' => sub { my $r = URI::NamespaceMap::ReservedLocalParts->new(); for my $ns (qw/can DOES isa VERSION/) { is $r->is_reserved($ns) => 1, "namespace $ns is reserved"; } for my $ns (qw/allowed disallowed is_reserved uri/) { is $r->is_reserved($ns) => 0, "namespace $ns is *not* reserved"; } }; subtest 'extending disallowed namespaces' => sub { my $r = URI::NamespaceMap::ReservedLocalParts->new(disallowed => [qw/uri/]); is $r->is_reserved('uri') => 1, 'namespace uri is reserved'; }; done_testing; types-attean.t000644001750001750 133414550071117 17503 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12/t#!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Requires { 'Attean' => '0.024' }; use Test::Requires { 'Types::Attean' => '0.024' }; use Types::Namespace qw( to_NamespaceMap to_Namespace to_Uri to_Iri ); use lib 't/lib'; use CommonTest qw(test_to_ns); my $nsuri = URI::Namespace->new('http://www.example.net/'); isa_ok($nsuri, 'URI::Namespace'); is($nsuri->as_string, 'http://www.example.net/', "Correct string URI to Namespace"); use Attean; use Types::Attean qw( to_AtteanIRI ); my $airi = to_AtteanIRI($nsuri); isa_ok($airi, 'Attean::IRI'); is($airi->as_string, 'http://www.example.net/', "Correct string URI to AtteanIRI"); test_to_ns(Attean::IRI->new('http://www.example.net/')); done_testing; types-trine.t000644001750001750 161414550071117 17351 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12/t#!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Deep; use Test::Requires { 'RDF::Trine' => '0' }; use Types::Namespace qw( to_NamespaceMap to_Namespace to_Uri to_Iri ); use lib 't/lib'; use CommonTest qw(test_to_ns); use RDF::Trine qw(iri); use_ok('RDF::Trine::NamespaceMap'); test_to_ns(RDF::Trine::Namespace->new('http://www.example.net/')); test_to_ns(RDF::Trine::iri('http://www.example.net/')); my $data = { foo => 'http://example.org/foo#', bar => 'http://example.com/bar/' }; my $map = RDF::Trine::NamespaceMap->new( $data ); my $urimap = to_NamespaceMap($map); isa_ok($urimap, 'URI::NamespaceMap'); my $result; while (my ($prefix, $uri) = $urimap->each_map) { isa_ok($uri, 'URI::Namespace'); $result->{$prefix} = $uri->as_string; } is(scalar keys(%{$result}), 2, 'Two elements in the result hash'); cmp_deeply($result, $data, 'Roundtrips OK'); done_testing; types.t000644001750001750 136314550071117 16233 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12/t#!/usr/bin/env perl use strict; use warnings; use Test::More; use lib 't/lib'; use CommonTest qw(test_to_ns); use Types::Namespace qw( to_Uri to_Iri ); my $nsuri = URI::Namespace->new('http://www.example.net/'); { isa_ok($nsuri, 'URI::Namespace'); is($nsuri->as_string, 'http://www.example.net/', "Correct string URI to Namespace"); my $uri = to_Uri($nsuri); isa_ok($uri, 'URI'); is("$uri", 'http://www.example.net/', "Correct string URI to Uri"); my $iri = to_Iri($nsuri); isa_ok($iri, 'IRI'); is($iri->as_string, 'http://www.example.net/', "Correct string URI to Iri"); } test_to_ns(URI->new('http://www.example.net/')); test_to_ns(IRI->new('http://www.example.net/')); test_to_ns('http://www.example.net/'); done_testing; Namespace.pm000644001750001750 535514550071117 20550 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12/lib/Typespackage Types::Namespace; use strict; use warnings; use Type::Library -base, -declare => qw( Uri Iri Namespace NamespaceMap ); use Types::Standard qw( HashRef InstanceOf ); use Types::URI qw(); my $AtteanIRI = InstanceOf['Attean::IRI']; my $TrineNS = InstanceOf['RDF::Trine::Namespace']; my $TrineNSMap = InstanceOf['RDF::Trine::NamespaceMap']; my $TrineNode = InstanceOf['RDF::Trine::Node::Resource']; our $VERSION = '1.10'; =head1 NAME Types::Namespace - type constraints for dealing with namespaces =head1 SYNOPSIS package Namespace::Counter { use Moo; # or Moose use Types::Namespace qw( Namespace ); has ns => ( is => "ro", isa => Namespace, required => 1, ); sub count_uses_in_document { ... } } =head1 DESCRIPTION Types::Namespace is a type constraint library suitable for use with L/L attributes, L sub signatures, and so forth. It builds on L. =head1 TYPES =over =item C<< Namespace >> A class type for L. Can coerce from L, L, L, L, L, L and strings. =item C<< NamespaceMap >> A class type for L. Can coerce from a hashref of C<< prefix => URI >> pairs and from L. =item C<< Uri >>, C<< Iri >> These namespaces are re-exported from L, but with an additional coercion from the C<< Namespace >> type. =back =head1 FURTHER DETAILS See L for further details about authors, license, etc. =cut __PACKAGE__->add_type( name => Uri, parent => Types::URI::Uri, coercion => [ @{ Types::URI::Uri->coercion->type_coercion_map }, InstanceOf['URI::Namespace'] ,=> q{ $_->uri() }, ], ); __PACKAGE__->add_type( name => Iri, parent => Types::URI::Iri, coercion => [ @{ Types::URI::Iri->coercion->type_coercion_map }, InstanceOf['URI::Namespace'] ,=> q{ $_->iri() }, ], ); __PACKAGE__->add_type( name => Namespace, parent => InstanceOf['URI::Namespace'], coercion => [ Iri->coercibles ,=> q{ "URI::Namespace"->new($_) }, $AtteanIRI ,=> q{ "URI::Namespace"->new($_->as_string) }, $TrineNode ,=> q{ "URI::Namespace"->new($_->as_string) }, $TrineNS ,=> q{ "URI::Namespace"->new($_->as_string) }, ], ); __PACKAGE__->add_type( name => NamespaceMap, parent => InstanceOf['URI::NamespaceMap'], coercion => [ HashRef ,=> q{ "URI::NamespaceMap"->new(namespace_map => $_) }, $TrineNSMap ,=> q{ do { my $map = $_; my %hash = map { $_ => $map->namespace_uri($_)->uri_value } $map->list_prefixes ; "URI::NamespaceMap"->new(namespace_map => \%hash) } } ], ); require URI::Namespace; require URI::NamespaceMap; 1; Namespace.pm000644001750001750 656314550071117 20105 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12/lib/URIpackage URI::Namespace; use Moo 1.006000; use URI; use IRI 0.003; use Scalar::Util qw(blessed); use Types::Namespace 0.004 qw( Iri ); use namespace::autoclean; our $VERSION = '1.10'; =head1 NAME URI::Namespace - A namespace URI/IRI class with autoload methods =head1 SYNOPSIS use URI::Namespace; my $foaf = URI::Namespace->new( 'http://xmlns.com/foaf/0.1/' ); print $foaf->as_string; print $foaf->name; =head1 DESCRIPTION This module provides an object with a URI/IRI attribute, typically used prefix-namespace pairs, typically used in XML, RDF serializations, etc. The local part can be used as a method, these are autoloaded. =head1 METHODS =over =item C<< new ( $string | URI | IRI ) >> This is the constructor. You may pass a string with a URI or a URI object. =item C<< uri ( [ $local_part ] ) >> Returns a L object with the namespace IRI. Optionally, the method can take a local part as argument, in which case, it will return the namespace URI with the local part appended. =item C<< iri ( [ $local_part ] ) >> Returns a L object with the namespace IRI. Optionally, the method can take a local part as argument, in which case, it will return the namespace IRI with the local part appended. =item C<< local_part ( $uri ) >> Returns the local part string if the given argument URI (which may be a string, L or L object) matches the namespace URI, or C if not. =back The following methods from L can be used on an URI::Namespace object: C, C, C, C, C, C. One important usage for this module is to enable you to create Ls for full URIs, e.g.: print $foaf->Person->as_string; will return http://xmlns.com/foaf/0.1/Person =head1 FURTHER DETAILS See L for further details about authors, license, etc. =cut around BUILDARGS => sub { my ($next, $self, @parameters) = @_; return $self->$next(@_) if ((@parameters > 1) || (ref($parameters[0]) eq 'HASH')); return { _uri => $parameters[0] }; }; has _uri => ( is => "ro", isa => Iri, coerce => 1, required => 1, handles => { 'as_string' => 'as_string', 'as_iri' => 'as_string', } ); sub iri { my ($self, $name) = @_; if (defined($name)) { my $str = $self->_uri->as_string; # XSD is given without hash in XML world, but hash should be added anyway (see issue #14) $str .= '#' if ($str eq 'http://www.w3.org/2001/XMLSchema'); return IRI->new($str . "$name"); } else { return $self->_uri; } } sub uri { my ($self, $name) = @_; my $iri = $self->_uri->as_string; if (defined($name)) { $iri .= '#' if ($iri eq 'http://www.w3.org/2001/XMLSchema'); return URI->new($iri . "$name"); } else { return URI->new($iri); } } sub local_part { my ($self, $fulluri) = @_; my $local_part = undef; if (blessed($fulluri) && $fulluri->isa('IRI')) { $fulluri = $fulluri->as_string; } my $iri = $self->_uri->as_string; if ($fulluri =~ m/^$iri(.+)/) { $local_part = $1; } else { # TODO: throw error? } return $local_part; } for my $method (qw/ abs rel eq canonical /) { eval qq[ sub $method { shift->uri->${method}(\@_) } ]; } sub DESTROY { } our $AUTOLOAD; sub AUTOLOAD { my $self = shift; my ($name) = $AUTOLOAD =~ /::(\w+)$/; return $self->uri($name); } 1; __END__ NamespaceMap.pm000644001750001750 2541514550071117 20560 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12/lib/URI=pod =head1 NAME URI::NamespaceMap - Class holding a collection of namespaces =head1 VERSION Version 1.12 =cut package URI::NamespaceMap; use Moo 1.006000; use Module::Load::Conditional qw[can_load]; use URI::Namespace; use Carp; use Scalar::Util qw( blessed ); use Sub::Quote qw( quote_sub ); use Try::Tiny; use Types::Standard qw(HashRef); use Types::Namespace 0.004 qw(Namespace); use URI::NamespaceMap::ReservedLocalParts; use namespace::autoclean; our $VERSION = '1.12'; =head1 SYNOPSIS use URI::NamespaceMap; my $map = URI::NamespaceMap->new( { xsd => 'http://www.w3.org/2001/XMLSchema#' } ); $map->namespace_uri('xsd')->as_string; my $foaf = URI::Namespace->new( 'http://xmlns.com/foaf/0.1/' ); $map->add_mapping(foaf => $foaf); $map->add_mapping(rdf => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' ); $map->list_prefixes; # ( 'foaf', 'rdf', 'xsd' ) $map->foaf; # Returns URI::Namespace object while (my ($prefix, $nsURI) = $map->each_map) { $node->setNamespace($nsURI->as_string, $prefix); # For use with XML::LibXML } =head1 DESCRIPTION This module provides an object to manage multiple namespaces for creating L objects and for serializing. =head1 METHODS =over =item C<< new ( [ \%namespaces | @prefixes | @uris ] ) >> Returns a new namespace map object. You can pass a hash reference with mappings from local names to namespace URIs (given as string or L) or namespaces_map with a hashref. You may also pass an arrayref containing just prefixes and/or namespace URIs, and the module will try to guess the missing part. To use this feature, you need L, L, L or L, or preferably all of them. With that, you can do e.g. my $map = URI::NamespaceMap->new( 'rdf', 'xsd', 'foaf' ); and have the correct mappings added automatically. =item C<< add_mapping ( $name => $uri ) >> Adds a new namespace to the map. The namespace URI can be passed as string or a L object. =item C<< remove_mapping ( $name ) >> Removes a namespace from the map given a prefix. =item C<< namespace_uri ( $name ) >> Returns the L object (if any) associated with the given prefix. =item C<< $name >> This module creates a method for all the prefixes, so you can say e.g. $map->foaf and get a L object for the FOAF namespace. Since L does the same for local names, you can then say e.g. $map->foaf->name to get a full L. =item C<< list_namespaces >> Returns an array of L objects with all the namespaces. =item C<< list_prefixes >> Returns an array of prefixes. =item C<< each_map >> Returns an 2-element list where the first element is a prefix and the second is the corresponding L object. =cut around BUILDARGS => sub { my ($next, $self, @parameters) = @_; if (ref($parameters[0]) eq 'ARRAY') { return { namespace_map => $self->_guess(@{$parameters[0]}) }; } if (@parameters == 1 && (! exists $parameters[0]->{namespace_map})) { return { namespace_map => $parameters[0] } } else { $self->$next(@parameters) } }; sub BUILD { my ($self, $args) = @_; my $r = URI::NamespaceMap::ReservedLocalParts->new(disallowed => [qw/uri/]); for my $local_part (keys %{$args->{namespace_map}}) { Carp::croak("$_[1] prohibited as local part") if $r->is_reserved($local_part); } } has namespace_map => ( is => "ro", isa => HashRef[Namespace], coerce => 1, default => quote_sub q { {} }, ); sub add_mapping { my $r = URI::NamespaceMap::ReservedLocalParts->new(disallowed => [qw/uri/]); Carp::croak("$_[1] prohibited as local part") if $r->is_reserved($_[1]); $_[0]->namespace_map->{$_[1]} = Namespace->assert_coerce($_[2]) } sub remove_mapping { delete $_[0]->namespace_map->{$_[1]} } sub namespace_uri { $_[0]->namespace_map->{$_[1]} } sub list_namespaces { values %{ $_[0]->namespace_map } } sub list_prefixes { keys %{ $_[0]->namespace_map } } sub each_map { each %{ $_[0]->namespace_map } } =item C<< guess_and_add ( @string_or_uri ) >> Like in the constructor, an array of strings can be given, and the module will attempt to guess appropriate mappings, and add them to the map. =cut sub guess_and_add { my ($self, @data) = @_; my $guessed = $self->_guess(@data); while (my ($name, $uri) = each %{$guessed}) { $self->add_mapping($name => $uri); } } =item C<< uri ( $prefixed_name ) >> Returns a URI for an abbreviated string such as 'foaf:Person'. =cut sub uri { my $self = shift; my $abbr = shift; my $ns; my $local = ""; if ($abbr =~ m/^([^:]*):(.*)$/) { $ns = $self->namespace_uri( $1 ); $local = $2; } else { $ns = $self->{ $abbr }; } return unless (blessed($ns)); if ($local ne '') { return $ns->uri($local); } else { return URI->new($ns->as_string); } } =item prefix_for C<< uri ($uri) >> Returns the associated prefix (or potentially multiple prefixes, when called in list context) for the given URI. =cut # turn the URI back into a string to mitigate unexpected behaviour sub _scrub_uri { my $uri = shift; if (ref $uri) { if (blessed $uri) { if ($uri->isa('URI::Namespace')) { $uri = $uri->as_string; } elsif ($uri->isa('IRI')) { $uri = $uri->as_string; } elsif ($uri->isa('URI')) { # it's probably not necessary to do this, but whatever $uri = $uri->as_string; } elsif ($uri->isa('RDF::Trine::Node')) { # it is, on the other hand, necessary to do this. $uri = $uri->uri_value; } elsif ($uri->isa('RDF::Trine::Namespace')) { # and this $uri = $uri->uri->uri_value; } # elsif ($uri =~ m/^\<(.*?)\>$/) { # $uri = $1; # } else { # let's hope whatever was passed in has a string overload $uri = "$uri"; } } else { Carp::croak(sprintf "You probably didn't mean to pass this " . "an unblessed %s reference", ref $uri); } } return $uri; } sub prefix_for { my ($self, $uri) = @_; $uri = _scrub_uri($uri); my @candidates; for my $k ($self->list_prefixes) { my $v = $self->namespace_uri($k); my $nsuri = $v->as_string; # the input should always be longer than the namespace next if length $nsuri > length $uri; # candidate namespace must match exactly my $cns = substr($uri, 0, length $nsuri); push @candidates, $k if $cns eq $nsuri; } # make sure this behaves correctly when empty return unless @candidates; # if this returns more than one prefix, take the # shortest/lexically lowest one. @candidates = sort @candidates; return wantarray ? @candidates : $candidates[0]; } =item abbreviate C<< uri ($uri) >> Complement to L. Returns the given URI in C format or C if it wasn't matched, therefore the idiom my $str = $nsmap->abbreviate($uri_node) || $uri->as_string; may be useful for certain serialization tasks. =cut sub abbreviate { my ($self, $uri) = @_; $uri = _scrub_uri($uri); my $prefix = $self->prefix_for($uri); return unless defined $prefix; my $nsuri = _scrub_uri($self->namespace_uri($prefix)); return sprintf('%s:%s', $prefix, substr($uri, length $nsuri)); } our $AUTOLOAD; sub AUTOLOAD { my ($self, $arg) = @_; my ($name) = ($AUTOLOAD =~ /::(\w+)$/); my $ns = $self->namespace_uri($name); return unless $ns; return $ns->$arg if $arg; return $ns; } sub _guess { my ($self, @data) = @_; my $rnscu = can_load( modules => { 'RDF::NS::Curated' => 0 } ); my $xmlns = can_load( modules => { 'XML::CommonNS' => 0 } ); my $rdfns = can_load( modules => { 'RDF::NS' => 20130802 } ); my $rdfpr = can_load( modules => { 'RDF::Prefixes' => 0 } ); confess 'To resolve an array, you need at least one of RDF::NS::Curated, XML::CommonNS, RDF::NS or RDF::Prefixes' unless ($rnscu || $xmlns || $rdfns || $rdfpr); my %namespaces; my $r = URI::NamespaceMap::ReservedLocalParts->new(disallowed => [qw/uri/]); foreach my $entry (@data) { if ($entry =~ m/^[a-z]\w+$/i) { # This is a prefix carp "Cannot resolve '$entry' without RDF::NS::Curated, XML::CommonNS, RDF::NS" unless ($rnscu || $xmlns || $rdfns); my $i = 1; my $prefix = $entry; while ($r->is_reserved($prefix)) { $prefix .= 'x'; carp "Cannot resolve '$entry' as tried prefix '$prefix' conflicts with method names." if ($i > 5); $i++; } if ($rnscu) { my $ns = RDF::NS::Curated->new; $namespaces{$prefix} = $ns->uri($entry); } if ((! $namespaces{$prefix}) && $xmlns) { require XML::CommonNS; XML::CommonNS->import(':all'); try { $namespaces{$prefix} = XML::CommonNS->uri(uc($entry))->toString; }; # Then, XML::CommonNS doesn't have the prefix, which is OK, we just continue } if ((! $namespaces{$prefix}) && $rdfns) { my $ns = RDF::NS->new; $namespaces{$prefix} = $ns->SELECT($entry); } carp "Cannot resolve assumed prefix '$entry'" unless $namespaces{$prefix}; } else { # Lets assume a URI string carp "Cannot resolve '$entry' without RDF::NS::Curated, RDF::NS or RDF::Prefixes" unless ($rnscu || $rdfns || $rdfpr); my $prefix; if ($rnscu) { my $ns = RDF::NS::Curated->new; $prefix = $ns->prefix($entry); } if ((! $prefix) && ($rdfns)) { my $ns = RDF::NS->new; $prefix = $ns->PREFIX($entry); } if ((! $prefix) && ($rdfpr)) { my $context = RDF::Prefixes->new; $prefix = $context->get_prefix($entry); } unless ($prefix) { carp "Cannot resolve assumed URI string '$entry'"; } else { my $i = 1; while ($r->is_reserved($prefix)) { $prefix .= 'x'; carp "Cannot resolve '$entry' as tried prefix '$prefix' conflicts with method names." if ($i > 5); $i++; } $namespaces{$prefix} = $entry; } } } return \%namespaces; } =back =head1 WARNING Avoid using the names 'can', 'isa', 'VERSION', and 'DOES' as namespace prefix, because these names are defined as method for every Perl object by default. The method names 'new' and 'uri' are also forbidden. Names of methods of L must also be avoided. Using them will result in an error. =head1 AUTHORS Chris Prather, C<< >> Kjetil Kjernsmo, C<< >> Gregory Todd Williams, C<< >> Toby Inkster, C<< >> =head1 CONTRIBUTORS Dorian Taylor Paul Williams Zakariyya Mughal Chris Prather =head1 BUGS Please report any bugs using L =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc URI::NamespaceMap =head1 COPYRIGHT & LICENSE Copyright 2012,2013,2014,2015,2016,2017,2018,2019 Gregory Todd Williams, Chris Prather and Kjetil Kjernsmo This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; __END__ CommonTest.pm000644001750001750 66114550071117 20056 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12/t/libpackage CommonTest; use strict; use warnings; use Test::More; require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(test_to_ns); use Types::Namespace qw( to_Namespace ); sub test_to_ns { my $uri = shift; my $nsiri = to_Namespace($uri); isa_ok($nsiri, 'URI::Namespace'); is($nsiri->as_string, 'http://www.example.net/', 'Correct string URI from ' . ref($uri)); ok($nsiri->equals($uri), 'Is the same URI'); } 1; ReservedLocalParts.pm000644001750001750 452514550071117 24303 0ustar00kjetilkjetil000000000000URI-NamespaceMap-1.12/lib/URI/NamespaceMappackage URI::NamespaceMap::ReservedLocalParts; use Moo 1.006000; use Types::Standard qw/ArrayRef Str/; use List::Util qw/first/; has allowed => ( is => 'ro', isa => ArrayRef [Str], default => sub { [qw/allowed disallowed is_reserved/] } ); has disallowed => (is => 'ro', isa => ArrayRef [Str], default => sub { [] }); sub is_reserved { my ($self, $keyword) = @_; return 0 if first { $_ eq $keyword } @{$self->allowed}; return 1 if first { $_ eq $keyword } @{$self->disallowed}; return $self->can($keyword) ? 1 : 0; } =head1 NAME URI::NamespaceMap::ReservedLocalParts - Permissible local parts for NamespaceMap =head1 VERSION Version 1.10 =cut our $VERSION = '1.10'; =head1 SYNOPSIS my $r = URI::NamespaceMap::ReservedLocalParts->new(disallowed => [qw/uri/]); say $r->is_reserved('isa'); # 1 say $r->is_reserved('uri'); # 1 say $r->is_reserved('foo'); # 0 =head1 DESCRIPTION L is an accompanying distribution to L. It's goal is to check for forbidden names used for local parts. Rather than creating a blacklist that needs to be maintained, it instantiates a new L object, and calls C on the invocant. Using this technique, it means that every method on every Perl object (C), and Moo objects (C) will be automatically black listed. =head1 ATTRIBUTES L implements the following attributes. =head2 allowed A whitelist of local part names. Defaults to C, C and C so that when C is called on the instance, it doesn't return a false positive for other method names associated with this package. =head2 disallowed A blacklist of local part names. Does not have a default set, but usually defaults to C when called from L. =head1 METHODS L implements the following methods. =head2 is_reserved my $r = URI::NamespaceMap::ReservedLocalParts->new(disallowed => [qw/uri/]); say $r->is_reserved('isa'); # 1 say $r->is_reserved('uri'); # 1 say $r->is_reserved('foo'); # 0 Checks if the first argument passed is reserved or not. Returns a C. =head1 FURTHER DETAILS See L for further details about authors, license, etc. =cut 1;