Files
perl-WordList/perl-WordList.spec

110 lines
3.4 KiB
RPMSpec
Raw Normal View History

#
# spec file for package perl-WordList
#
# Copyright (c) 2018 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 http://bugs.opensuse.org/
#
Name: perl-WordList
Version: 0.1.3
Release: 0
%define cpan_name WordList
Summary: Word lists
License: Artistic-1.0 OR GPL-1.0-or-later
Group: Development/Libraries/Perl
Url: http://search.cpan.org/dist/WordList/
Source0: https://cpan.metacpan.org/authors/id/P/PE/PERLANCAR/%{cpan_name}-%{version}.tar.gz
Source1: cpanspec.yml
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: perl
BuildRequires: perl-macros
%{perl_requires}
%description
'WordList::*' modules are modules that contain, well, list of words. This
module, 'WordList', serves as a base class and establishes convention for
such modules.
'WordList' is an alternative interface for Games::Word::Wordlist and
'Games::Word::Wordlist::*'. Its main difference is: 'WordList::*' wordlists
are read-only/immutable and the modules are designed to have low startup
overhead. This makes them more suitable for use in CLI scripts which often
only want to pick a word from one or several lists.
Words (or phrases) must be put in '__DATA__' section, *sorted*
ascibetically (or by Unicode code point), one per line. Putting the
wordlist in the '__DATA__' section relieves perl from having to parse the
list during the loading of the module. To search for words or picking some
random words from the list, the module also need not slurp the whole list
into memory (and will not do so unless explicitly instructed). Sorting
makes it more convenient to diff different versions of the module, as well
as performing binary search.
Since this is a new and non-backward compatible interface from
Games::Word::Wordlist, I also make some other changes:
* * Namespace is put outside 'Games::'
Because obviously word lists are not only useful for games.
* * Interface is simpler
This is partly due to the list being read-only. The methods provided are
just:
- 'pick' (pick one or several random entries)
- 'word_exists' (check whether a word is in the list)
- 'each_word' (run code for each entry)
- 'all_words' (return all the words in a list)
A couple of other functions might be added, with careful consideration.
* * Namespace is more language-neutral and not English-centric
TODOS:
* * Interface for random pick from a subset
Pick $n words of length $L.
Pick $n words matching regex $re.
* * Interface to enable faster lookup/caching
%prep
%setup -q -n %{cpan_name}-%{version}
%build
%{__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
%license LICENSE
%changelog