Skip to content

Commit 273c23d

Browse files
author
Li
committed
#395, refine the code according to latest pull review comments, change the language, version mapping
1 parent 231e674 commit 273c23d

File tree

4 files changed

+7
-16
lines changed

4 files changed

+7
-16
lines changed

src/packagedcode/phpcomposer.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@
5555

5656

5757
class PHPComposerPackage(models.Package):
58-
metafiles = ('package.json')
58+
metafiles = ('composer.json')
5959
filetypes = ('.json',)
60-
mimetypes = ('application/x-tar',)
60+
mimetypes = ('text/xml',)
6161
repo_types = (models.repo_phpcomposer,)
6262

6363
type = models.StringType(default='phpcomposer')
64-
primary_language = models.StringType(default='JavaScript')
64+
primary_language = models.StringType(default='PHP')
6565

6666
@classmethod
6767
def recognize(cls, location):
@@ -84,6 +84,7 @@ def parse(location):
8484
('name', 'name'),
8585
('description', 'summary'),
8686
('keywords', 'keywords'),
87+
('version', 'version'),
8788
('homepage', 'homepage_url'),
8889
])
8990

@@ -109,7 +110,6 @@ def parse(location):
109110
# a composer.json is at the root of a PHP composer package
110111
base_dir = fileutils.parent_directory(location)
111112
package.location = base_dir
112-
# for now we only recognize a package.json, not a node_modules directory yet
113113
package.metafile_locations = [location]
114114
package.version = data.get('version')
115115
for source, target in plain_fields.items():
@@ -359,15 +359,6 @@ def deps_mapper(deps, package, field_name):
359359
dev_dependencies_mapper = partial(deps_mapper, field_name='devDependencies')
360360

361361

362-
person_parser = re.compile(
363-
r'^(?P<name>[^\(<]+)'
364-
r'\s?'
365-
r'(?P<email><([^>]+)>)?'
366-
r'\s?'
367-
r'(?P<url>\([^\)]+\))?$'
368-
).match
369-
370-
371362
def parse_person(persons):
372363
"""
373364
https://getcomposer.org/doc/04-schema.md#authors

tests/packagedcode/data/phpcomposer/a-timer/composer.json.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "phpcomposer",
33
"name": "jandreasn/a-timer",
44
"version": null,
5-
"primary_language": "JavaScript",
5+
"primary_language": "PHP",
66
"packaging": null,
77
"summary": "A simple timer.",
88
"description": null,

tests/packagedcode/data/phpcomposer/framework/composer.json.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "phpcomposer",
33
"name": "narrowspark/framework",
44
"version": null,
5-
"primary_language": "JavaScript",
5+
"primary_language": "PHP",
66
"packaging": null,
77
"summary": "Narrowspark Framework for Creative People.",
88
"description": null,

tests/packagedcode/data/phpcomposer/slim/composer.json.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "phpcomposer",
33
"name": "slim/slim",
44
"version": null,
5-
"primary_language": "JavaScript",
5+
"primary_language": "PHP",
66
"packaging": null,
77
"summary": "Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs",
88
"description": null,

0 commit comments

Comments
 (0)