Skip to content

Commit

Permalink
generate_bear_requirements.py: Add Perl Meta
Browse files Browse the repository at this point in the history
This enhances generate_bear_requirements.py to support
perl bears and generate Makefile.PL using jinja2
template.
closes coala#2483
  • Loading branch information
Ishaan29 committed Mar 22, 2019
1 parent e085b3f commit 7fcd7f5
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .ci/generate_bear_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
'ComposerRequirement',
'CabalRequirement',
'RscriptRequirement',
'PerlRequirement',
)

INSTANCE_NAMES = (
Expand All @@ -60,6 +61,7 @@
'composer_requirements',
'cabal_requirements',
'r_script_requirements',
'perl_requirements'
)


Expand Down Expand Up @@ -174,6 +176,8 @@ def get_pip_requirements(requirements):
def get_cabal_requirements(requirements):
return _get_requirements(requirements, '==')

def get_perl_requirements(requirements):
return _get_requirements(requirements, '==')

def _create_sorted_commented_map(input_dict):
return CommentedMap(sorted(input_dict.items(),
Expand Down Expand Up @@ -266,6 +270,8 @@ def sort_requirements(req_dict):
instance_dict['ComposerRequirement'])
requirements['cabal_requirements'] = get_cabal_requirements(
instance_dict['CabalRequirement'])
requirements['perl_requirements'] = get_perl_requirements(
instance_dict['PerlRequirement'])

if args.update or args.check:
input_file_path = os.path.join(PROJECT_DIR, BEAR_REQUIREMENTS_YAML)
Expand Down
6 changes: 6 additions & 0 deletions .moban.dt/Makefile.PL.jj2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Coala::Bears',
VERSION => '0.10',
PREREQ_PM => {Perl::Critic => 1.126},
);
1 change: 1 addition & 0 deletions .moban.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ targets:
- runtime.txt: runtime.txt
- netlify.toml: docs/netlify.toml
- coala-bears.cabal: coala-bears.cabal.jj2
- Makefile.PL: Makefile.PL.jj2
copy:
- .ci/check_moban.sh: ci/check_moban.sh
- .ci/check_setuptools.py: ci/check_setuptools.py
6 changes: 6 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Coala::Bears',
VERSION => '0.10',
PREREQ_PM => {Perl::Critic => 1.126},
);
1 change: 1 addition & 0 deletions bear-requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,4 @@ cabal_requirements:
version: ==5.6.0.0
hlint:
version: ==1.9.27
perl_requirements: {}
26 changes: 17 additions & 9 deletions bears/perl/PerlCriticBear.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from coalib.bearlib.abstractions.Linter import linter
from dependency_management.requirements.DistributionRequirement import (
DistributionRequirement)
from dependency_management.requirements.AnyOneOfRequirements import (
AnyOneOfRequirements)
from dependency_managment.requirements.PerlRequirement import (
PerlRequirement)
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY


Expand All @@ -24,15 +28,19 @@ class PerlCriticBear:

LANGUAGES = {'Perl'}
REQUIREMENTS = {
DistributionRequirement(
apt_get='libperl-critic-perl',
brew=None,
dnf='perl-Perl-Critic',
portage='dev-perl/Perl-Critic',
xbps=None,
yum='perl-Perl-Critic',
zypper='perl-Perl-Critic',
),
AnyOneOfRequirements(
[PerlRequirement(package='Critic', version='1.126'),
DistributionRequirement(
apt_get='libperl-critic-perl',
brew=None,
dnf='perl-Perl-Critic',
portage='dev-perl/Perl-Critic',
xbps=None,
yum='perl-Perl-Critic',
zypper='perl-Perl-Critic',
),
]
)
}
AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
Expand Down

0 comments on commit 7fcd7f5

Please sign in to comment.