File perl-Config-Interactive.spec of Package perl-Config-Interactive

#
# spec file for package perl-Config-Interactive
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


Name:           perl-Config-Interactive
Version:        0.04
Release:        0
%define cpan_name Config-Interactive
Summary:        config module with support for interpolation, XML fragments and interactive UI
License:        CHECK(Artistic-1.0 OR GPL-1.0-or-later)
Group:          Development/Libraries/Perl
Url:            https://metacpan.org/release/%{cpan_name}
Source0:        https://cpan.metacpan.org/authors/id/M/MP/MPG/%{cpan_name}-%{version}.tgz
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  perl
BuildRequires:  perl-macros
BuildRequires:  perl(XML::Parser)
BuildRequires:  perl(XML::Simple)
Requires:       perl(XML::Parser)
Requires:       perl(XML::Simple)
%{perl_requires}

%description
This module opens a config file and parses it's contents for you. The
_new()_ method accepts several parameters. The method 'parse' returns a
hash reference which contains all options and it's associated values of
your config file as well as comments above. If the dialog mode is set then
at the moment of parsing user will be prompted to enter different value and
if validation pattern for this particular key was defined then it will be
validated and user could be asked to enter different value if it failed.
The format of config files supported by Config::Interactive is
'<name>=<value>' pairs or XML fragments (by XML::Simple, namespaces are not
supported) and comments are any line which starts with #. Comments inside
of XML fragments will pop-up on top of the related fragment. It will
interpolate any perl variable which looks as ' ${?[A-Za-z]\w+}? '. Please
not that interpolation works for XML fragments as well, BUT interpolated
varialbles MUST be defined by 'key=value' definition and NOT inside of
other XML fragment! The order of appearance of such variables in the config
file is not important, means you can use '$bar' variable anywhere in the
config file but set it to something on the last line (or even skip setting
it at all , then it will be undef). It stores internally config file
contents as hash ref where data structure is: Please note that array ref is
used to store XML text elements and scalar for attributes.

   ( 'key1' => {'comment' => "#some comment\n#more comments\n", 
                'value' => 'Value1',
                'order' => '1',
              },
   'key2' => {'comment' => "#some comment\n#more comments\n", 
              'value' =>  'Value2',
              'order' => '2'
             },
    
   'XMLRootKey' =>  {'comment' => "#some comment\n#more comments\n",
                     'order' => '3',
                     'value' =>  { 
                                   'xmlAttribute1' => 'attribute_value',
                                   'subXmlKey1' =>    ['sub_xml_value1'],
                                   'subXmlKey2' =>    ['sub_xml_value2'],
                                   'subXmlKey3'=>     ['sub_xml_value3'],	
                   }	      
     }
   )

The normalized ( flat hash with only key=value pairs ) view of the config
could be obtained by getNormalizedData() call. All tree- like options will
be flatted as key1_subkey1_subsubkey1. So the structure above will be
converted into:

  ('key1' => 'Value1', 
   'key2' =>   'Value2', 
   'XMLRootKey_xmlAttribute1' => 'attribute_value',
   'XMLRootKey_subXmlKey1' =>  'sub_xml_value1' ,
   'XMLRootKey_subXmlKey2' =>   'sub_xml_value2',
   'XMLRootKey_subXmlKey3'=>    'sub_xml_value3' , )

the case of the key will be preserved.

%prep
%setup -q -n %{cpan_name}-%{version}

%build
PERL_USE_UNSAFE_INC=1 perl Makefile.PL INSTALLDIRS=vendor
make %{?_smp_mflags}

%check
make test

%install
%perl_make_install
%perl_process_packlist
%perl_gen_filelist

%files -f %{name}.files
%defattr(-,root,root,755)
%doc Changes README

%changelog
openSUSE Build Service is sponsored by