Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 1900de4a87d761c291c89eaa7643d8d4 > files > 4

perl-Test-Mojibake-0.3-3.fc15.src.rpm

# We don't really need ExtUtils::MakeMaker ≥ 6.30
%global old_eumm %(perl -MExtUtils::MakeMaker -e 'printf "%d\\n", $ExtUtils::MakeMaker::VERSION < 6.30 ? 1 : 0;' 2>/dev/null || echo 0)

# We need to patch the test suite if we have an old version of Test::More
%global old_test_more %(perl -MTest::More -e 'printf "%d\\n", $Test::More::VERSION < 0.88 ? 1 : 0;' 2>/dev/null || echo 0)

# noarch, but to avoid debug* files interfering with manifest test:
%global debug_package %{nil}

# TODO:
#
# BuildRequires: perl(Test::Pod::LinkCheck) when available

Name:		perl-Test-Mojibake
Version:	0.3
Release:	3%{?dist}
Summary:	Check your source for encoding misbehavior
Group:		Development/Libraries
License:	GPL+ or Artistic
URL:		http://search.cpan.org/dist/Test-Mojibake/
Source0:	http://search.cpan.org/CPAN/authors/id/S/SY/SYP/Test-Mojibake-%{version}.tar.gz
Patch0:		Test-Mojibake-0.3-old-eu::mm.patch
Patch1:		Test-Mojibake-0.3-old-Test::More.patch
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(id -nu)
BuildArch:	noarch
# ===================================================================
# Module build requirements
# ===================================================================
BuildRequires:	perl(ExtUtils::MakeMaker)
# ===================================================================
# Module requirements
# ===================================================================
BuildRequires:	perl(File::Spec)
BuildRequires:	perl(Test::Builder)
# ===================================================================
# Optional module requirements
# ===================================================================
BuildRequires:	perl(Unicode::CheckUTF8)
# ===================================================================
# Regular test suite requirements
# ===================================================================
BuildRequires:	perl(Test::Builder::Tester)
BuildRequires:	perl(Test::More)
# ===================================================================
# Author/Release test requirements
#
# Don't run these tests or include their requirements if we're
# bootstrapping, as many of these modules require each other for
# their author/release tests.
# ===================================================================
%if 0%{!?perl_bootstrap:1}
BuildRequires:	perl(Pod::Coverage::TrustPod)
BuildRequires:	perl(Test::CPAN::Meta)
BuildRequires:	perl(Test::DistManifest)
BuildRequires:	perl(Test::HasVersion)
BuildRequires:	perl(Test::NoTabs)
BuildRequires:	perl(Test::Pod::Coverage)
BuildRequires:	perl(Test::Pod)
BuildRequires:	perl(Test::Portability::Files)
# Modules only available from EL-5
%if 0%{?fedora} || 0%{?rhel} > 4
BuildRequires:	perl(Test::Perl::Critic)
BuildRequires:	perl(Test::Synopsis)
%endif
# Modules only available from EL-6
%if 0%{?fedora} || 0%{?rhel} > 5
BuildRequires:	perl(Test::Kwalitee)
BuildRequires:	perl(Test::MinimumVersion)
BuildRequires:	perl(Test::Vars)
%endif
# Modules only available from EL-7
%if 0%{?fedora} || 0%{?rhel} > 6
BuildRequires:	perl(Test::CPAN::Changes)
%endif
%endif
# ===================================================================
# Runtime requirements
# ===================================================================
Requires:	perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
# Unicode::CheckUTF8 is an optional requirement that significantly speeds up
# this module
Requires:	perl(Unicode::CheckUTF8)

%description
Many modern text editors automatically save files using UTF-8 codification.
However, the perl interpreter does not expect it by default. Whilst this does
not represent a big deal on (most) backend-oriented programs, Web framework
(Catalyst, Mojolicious) based applications will suffer so-called Mojibake
(literally: "unintelligible sequence of characters"). Even worse: if an editor
saves BOM (Byte Order Mark, U+FEFF character in Unicode) at the start of a
script with the executable bit set (on Unix systems), it won't execute at all,
due to shebang corruption.

Avoiding codification problems is quite simple:

 * Always use utf8/use common::sense when saving source as UTF-8
 * Always specify =encoding utf8 when saving POD as UTF-8
 * Do neither of above when saving as ISO-8859-1
 * Never save BOM (not that it's wrong; just avoid it as you'll barely
   notice its presence when in trouble)

However, if you find yourself upgrading old code to use UTF-8 or trying to
standardize a big project with many developers, each one using a different
platform/editor, reviewing all files manually can be quite painful, especially
in cases where some files have multiple encodings (note: it all started when I
realized that gedit and derivatives are unable to open files with character
conversion tables).

Enter the Test::Mojibake ;)

%prep
%setup -q -n Test-Mojibake-%{version}

# We don't really need ExtUtils::MakeMaker ≥ 6.30
%if %{old_eumm}
%patch0 -p1
%endif

# We need to patch the test suite if we have an old version of Test::More
%if %{old_test_more}
%patch1 -p1
%endif

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

%install
rm -rf %{buildroot}
make pure_install PERL_INSTALL_ROOT=%{buildroot}
find %{buildroot} -type f -name .packlist -exec rm -f {} \;
find %{buildroot} -depth -type d -exec rmdir {} \; 2>/dev/null
%{_fixperms} %{buildroot}

%check
make test %{!?perl_bootstrap:AUTHOR_TESTING=1 RELEASE_TESTING=1}

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%doc Changes LICENSE README
%{perl_vendorlib}/Test/
%{_mandir}/man3/Test::Mojibake.3pm*

%changelog
* Tue Oct  4 2011 Paul Howarth <paul@city-fan.org> - 0.3-3
- BR/R: perl(Unicode::CheckUTF8) for improved performance

* Thu Aug 11 2011 Paul Howarth <paul@city-fan.org> - 0.3-2
- Sanitize for Fedora/EPEL submission

* Thu Aug 11 2011 Paul Howarth <paul@city-fan.org> - 0.3-1
- Initial RPM version