diff --git a/setup.py b/setup.py index aa3b652381a..a64da581e99 100644 --- a/setup.py +++ b/setup.py @@ -188,6 +188,7 @@ def read(*names, **kwargs): 'xmltodict >= 0.11.0', 'javaproperties >= 0.5', 'toml >= 0.10.0', + 'gemfileparser >= 0.7.0', 'pkginfo >= 1.5.0.1', 'dparse >= 0.4.1', diff --git a/src/packagedcode/__init__.py b/src/packagedcode/__init__.py index 6e4c17be7be..8fa9c28aa2f 100644 --- a/src/packagedcode/__init__.py +++ b/src/packagedcode/__init__.py @@ -25,17 +25,18 @@ from __future__ import absolute_import from __future__ import unicode_literals -from packagedcode import build -from packagedcode import chef -from packagedcode import models from packagedcode import about from packagedcode import bower -from packagedcode import conda +from packagedcode import build from packagedcode import cargo +from packagedcode import chef +from packagedcode import conda +from packagedcode import cocoapods from packagedcode import freebsd from packagedcode import golang from packagedcode import haxe from packagedcode import maven +from packagedcode import models from packagedcode import npm from packagedcode import nuget from packagedcode import opam @@ -64,6 +65,7 @@ phpcomposer.PHPComposerPackage, haxe.HaxePackage, cargo.RustCargoCrate, + cocoapods.CocoapodsPackage, opam.OpamPackage, models.MeteorPackage, bower.BowerPackage, diff --git a/src/packagedcode/cocoapods.py b/src/packagedcode/cocoapods.py new file mode 100644 index 00000000000..587f0b831b1 --- /dev/null +++ b/src/packagedcode/cocoapods.py @@ -0,0 +1,190 @@ +# All rights reserved. +# http://nexb.com and https://github.com/nexB/scancode-toolkit/ +# The ScanCode software is licensed under the Apache License version 2.0. +# Data generated with ScanCode require an acknowledgment. +# ScanCode is a trademark of nexB Inc. +# +# You may not use this software except in compliance with the License. +# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# +# When you publish or redistribute any data created with ScanCode or any ScanCode +# derivative work, you must accompany this data with the following acknowledgment: +# +# Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES +# OR CONDITIONS OF ANY KIND, either express or implied. No content created from +# ScanCode should be considered or used as legal advice. Consult an Attorney +# for any legal advice. +# ScanCode is a free software code scanning tool from nexB Inc. and others. +# Visit https://github.com/nexB/scancode-toolkit/ for support and download. + +from __future__ import absolute_import +from __future__ import print_function +from __future__ import unicode_literals + +import logging +import re + +import attr +from packageurl import PackageURL + +from commoncode.fileutils import py2 +from commoncode import filetype +from commoncode import fileutils +from packagedcode import models +from packagedcode.spec import Spec + + +""" +Handle cocoapods packages manifests for macOS and iOS +including .podspec, Podfile and Podfile.lock files. +See https://cocoapods.org +""" + +# TODO: override the license detection to detect declared_license correctly. + + +TRACE = False + +logger = logging.getLogger(__name__) + +if TRACE: + import sys + logging.basicConfig(stream=sys.stdout) + logger.setLevel(logging.DEBUG) + + +@attr.s() +class CocoapodsPackage(models.Package): + metafiles = ('*.podspec',) + extensions = ('.podspec',) + default_type = 'pods' + default_primary_language = 'Objective-C' + default_web_baseurl = 'https://cocoapods.org' + default_download_baseurl = None + default_api_baseurl = None + + @classmethod + def recognize(cls, location): + yield parse(location) + + def repository_homepage_url(self, baseurl=default_web_baseurl): + return '{}/pods/{}'.format(baseurl, self.name) + + def repository_download_url(self): + return '{}/archive/{}.zip'.format(self.homepage_url, self.version) + + +def is_podspec(location): + """ + Checks if the file is actually a podspec file + """ + return (filetype.is_file(location) and location.endswith('.podspec')) + + +def parse(location): + """ + Return a Package object from a .podspec file or None. + """ + if not is_podspec(location): + return + + podspec_object = Spec() + podspec_data = podspec_object.parse_spec(location) + return build_package(podspec_data) + + +def build_package(podspec_data): + """ + Return a Package object from a package data mapping or None. + """ + name = podspec_data.get('name') + version = podspec_data.get('version') + declared_license = podspec_data.get('license') + summary = podspec_data.get('summary') + description = podspec_data.get('description') + homepage_url = podspec_data.get('homepage_url') + source = podspec_data.get('source') + authors = podspec_data.get('author') or [] + + author_names = [] + author_email = [] + if authors: + for split_author in authors: + split_author = split_author.strip() + author, email = parse_person(split_author) + author_names.append(author) + author_email.append(email) + + parties = list(party_mapper(author_names, author_email)) + + package = CocoapodsPackage( + name=name, + version=version, + vcs_url=source, + source_packages=list(source.split('\n')), + description=description, + declared_license=declared_license, + homepage_url=homepage_url, + parties=parties + ) + + return package + + +def party_mapper(author, email): + """ + Yields a Party object with author and email. + """ + for person in author: + yield models.Party( + type=models.party_person, + name=person, + role='author') + + for person in email: + yield models.Party( + type=models.party_person, + email=person, + role='email') + + +person_parser = re.compile( + r'^(?P[\w\s(),-_.,]+)' + r'=>' + r'(?P[\S+]+$)' +).match + +person_parser_only_name = re.compile( + r'^(?P[\w\s(),-_.,]+)' +).match + + +def parse_person(person): + """ + Return name and email from person string. + + https://guides.cocoapods.org/syntax/podspec.html#authors + Author can be in the form: + s.author = 'Rohit Potter' + or + s.author = 'Rohit Potter=>rohit@gmail.com' + Author check: + >>> p = parse_person('Rohit Potter=>rohit@gmail.com') + >>> assert p == ('Rohit Potter', 'rohit@gmail.com') + >>> p = parse_person('Rohit Potter') + >>> assert p == ('Rohit Potter', None) + """ + parsed = person_parser(person) + if not parsed: + parsed = person_parser_only_name(person) + name = parsed.group('name') + email = None + else: + name = parsed.group('name') + email = parsed.group('email') + + return name, email \ No newline at end of file diff --git a/src/packagedcode/rubygems.py b/src/packagedcode/rubygems.py index e513978f1e5..e6ba68a1afc 100644 --- a/src/packagedcode/rubygems.py +++ b/src/packagedcode/rubygems.py @@ -42,6 +42,7 @@ from extractcode.uncompress import get_gz_compressed_file_content from packagedcode import models from packagedcode.gemfile_lock import GemfileLockParser +from packagedcode.spec import Spec from packagedcode.utils import combine_expressions @@ -119,8 +120,7 @@ def recognize(cls, location): yield build_rubygem_package(metadata) if location.endswith('.gemspec'): - # TODO: implement me - pass + yield build_packages_from_gemspec(location) if location.endswith('Gemfile'): # TODO: implement me @@ -559,27 +559,6 @@ def get_dependencies(dependencies): ################################################################################ -def parse_gemspec(location): - raise NotImplementedError - - -def get_gemspec_data(location): - """ - Return a mapping of Gem data from parsing a .gemspec file. - """ - if not location.endswith('.gemspec'): - return - - spec = spec_defaults() - raw_spec = parse_gemspec(location) - if TRACE: - keys = raw_spec.keys() - logger.debug('\nRubygems spec keys for %(gemfile)r:\n%(keys)r' % locals()) - spec.update(raw_spec) - spec = normalize(spec) - return spec - - def spec_defaults(): """ Return a mapping with spec attribute defaults to ensure that the @@ -648,93 +627,74 @@ def normalize(gem_data, known_fields=known_fields): ) -def parse_spec(location): - pass +def build_packages_from_gemspec(location): + """ + Return RubyGem Package from gemspec file. + """ + gemspec_object = Spec() + gemspec_data = gemspec_object.parse_spec(location) + + name = gemspec_data.get('name') + version = gemspec_data.get('version') + homepage_url = gemspec_data.get('homepage_url') + summary = gemspec_data.get('summary') + description = gemspec_data.get('description') + if len(summary) > len(description): + description = summary + + declared_license = gemspec_data.get('license') + if declared_license: + declared_license = declared_license.split(',') + + author = gemspec_data.get('author') or [] + email = gemspec_data.get('email') or [] + parties = list(party_mapper(author, email)) + + package = RubyGem( + name=name, + version=version, + parties=parties, + homepage_url=homepage_url, + description=description, + declared_license=declared_license + ) + + dependencies = gemspec_data.get('dependencies', {}) or {} + package_dependencies = [] + for name, version in dependencies.items(): + package_dependencies.append( + models.DependentPackage( + purl=PackageURL( + type='gem', + name=name + ).to_string(), + requirement=', '.join(version), + scope='dependencies', + is_runtime=True, + is_optional=False, + is_resolved=False, + ) + ) + package.dependencies = package_dependencies + return package -class GemSpec(object): + +def party_mapper(author, email): """ - Represent a Gem specification. + Yields a Party object with author and email. """ - - # TODO: Check if we should use 'summary' instead of description - def __init__(self, location): - """ - Initialize from the gem spec or gem file at location. - """ - spec = parse_spec(location) - self.location = location - self.description = spec.get('description') - self.summary = spec.get('summary') - self.author = spec.get('author') - self.authors = spec.get('authors') - # can be a list - self.email = spec.get('email') - - - self.spec['licenses'] = self.map_licenses() - self.make_unique() - - def __str__(self): - return '<{}: {}>'.format(self.__class__.__name__, self.location) - - def make_unique(self): - """ - Ensure that lists in the spec only contain unique values. - """ - new_spec = {} - for key, value in self.spec.items: - if isinstance(value, list): - newlist = [] - for item in value: - if item not in newlist: - newlist.append(item) - new_spec[key] = newlist - else: - new_spec[key] = value - return new_spec - - def get_description(self): - """ - Using 'description' over 'summary' unless summary contains - more data. - See http://guides.rubygems.org/specification-reference/ - Note that it is common to see this is spec files: s.description = s.summary - """ - description = self.spec.get('description', '') - summary = self.spec.get('summary', '') - - content = description - # FIXME: we should join these. - if len(summary) > len(description): - content = summary - - content = ' '.join(content.split()) - return content.strip() - - def get_email(self): - """ - Join the list of emails as a comma-separated string. - """ - email = self.spec.get('email', u'') - if isinstance(email, list): - email = u', '.join(email) - return email - - def map_licenses(self): - licenses = self.spec.get('licenses', []) - if not isinstance(licenses, list): - licenses = [licenses] - - mapped_licenses = [] - for lic in licenses: - mapped_license = LICENSES_MAPPING.get(lic, None) - if mapped_license: - mapped_licenses.append(mapped_license) - else: - if TRACE: - logger.warning('WARNING: {}: no license mapping for: "{}"'.format(self.filename, lic)) - return mapped_licenses + for person in author: + yield models.Party( + type=models.party_person, + name=person, + role='author') + + for person in email: + yield models.Party( + type=models.party_person, + email=person, + role='email') def build_packages_from_gemfile_lock(gemfile_lock): diff --git a/src/packagedcode/spec.py b/src/packagedcode/spec.py new file mode 100644 index 00000000000..b437d2eb291 --- /dev/null +++ b/src/packagedcode/spec.py @@ -0,0 +1,178 @@ +# All rights reserved. +# http://nexb.com and https://github.com/nexB/scancode-toolkit/ +# The ScanCode software is licensed under the Apache License version 2.0. +# Data generated with ScanCode require an acknowledgment. +# ScanCode is a trademark of nexB Inc. +# +# You may not use this software except in compliance with the License. +# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# +# When you publish or redistribute any data created with ScanCode or any ScanCode +# derivative work, you must accompany this data with the following acknowledgment: +# +# Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES +# OR CONDITIONS OF ANY KIND, either express or implied. No content created from +# ScanCode should be considered or used as legal advice. Consult an Attorney +# for any legal advice. +# ScanCode is a free software code scanning tool from nexB Inc. and others. +# Visit https://github.com/nexB/scancode-toolkit/ for support and download. + +from __future__ import absolute_import +from __future__ import print_function +from __future__ import unicode_literals + +from collections import OrderedDict +import csv +import glob +import io +import logging +import os +import re + +from gemfileparser import GemfileParser + +""" +Handle Cocoapods(.podspec) and Ruby(.gemspec) files. +""" + + +TRACE = False + +logger = logging.getLogger(__name__) + +if TRACE: + import sys + logging.basicConfig(stream=sys.stdout) + logger.setLevel(logging.DEBUG) + + +class Spec(): + parse_name = re.compile(r'.*\.name(\s*)=(?P.*)') + parse_version = re.compile(r'.*\.version(\s*)=(?P.*)') + parse_license = re.compile(r'.*\.license(\s*)=(?P.*)') + parse_summary = re.compile(r'.*\.summary(\s*)=(?P.*)') + parse_description = re.compile(r'.*\.description(\s*)=(?P.*)') + parse_homepage = re.compile(r'.*\.homepage(\s*)=(?P.*)') + parse_source = re.compile(r'.*\.source(\s*)=(?P.*)') + + def parse_spec(self, location): + """ + Return dictionary contains podspec or gemspec file data. + """ + with io.open(location, encoding='utf-8', closefd=True) as data: + lines = data.readlines() + + spec_data = {} + + for line in lines: + line = pre_process(line) + match = self.parse_name.match(line) + if match: + name = match.group('name') + spec_data['name'] = get_stripped_data(name) + match = self.parse_version.match(line) + if match: + version = match.group('version') + spec_data['version'] = get_stripped_data(version) + match = self.parse_license.match(line) + if match: + license_value = match.group('license') + spec_data['license'] = get_stripped_data(license_value) + match = self.parse_summary.match(line) + if match: + summary = match.group('summary') + spec_data['summary'] = get_stripped_data(summary) + match = self.parse_homepage.match(line) + if match: + homepage = match.group('homepage') + spec_data['homepage_url'] = get_stripped_data(homepage) + match = self.parse_source.match(line) + if match: + source = re.sub(r'/*.*source.*?>', '', line) + stripped_source = re.sub(r',.*', '', source) + spec_data['source'] = get_stripped_data(stripped_source) + match = self.parse_description.match(line) + if match: + if location.endswith('.gemspec'): + # FIXME: description can be in single or multi-lines + # There are many different ways to write description. + description = match.group('description') + spec_data['description'] = get_stripped_data(description) + else: + spec_data['description'] = get_description(location) + if '.email' in line: + _key, _sep, value = line.rpartition('=') + stripped_emails = get_stripped_data(value) + stripped_emails = stripped_emails.strip() + stripped_emails = stripped_emails.split(',') + spec_data['email'] = stripped_emails + elif '.author' in line: + authors = re.sub(r'/*.*author.*?=', '', line) + stripped_authors = get_stripped_data(authors) + stripped_authors = re.sub(r'(\s*=>\s*)', '=>', stripped_authors) + stripped_authors = stripped_authors.strip() + stripped_authors = stripped_authors.split(',') + spec_data['author'] = stripped_authors + + parser = GemfileParser(location) + deps = parser.parse() + dependencies = OrderedDict() + for key in deps: + depends = deps.get(key, []) or [] + for dep in depends: + dependencies[dep.name] = dep.requirement + spec_data['dependencies'] = dependencies + + return spec_data + + +def pre_process(line): + """ + Return line after comments and space. + """ + if '#' in line: + line = line[:line.index('#')] + stripped_data = line.strip() + + return stripped_data + +def get_stripped_data(data): + """ + Return data after removing unnecessary special character + """ + for strippable in ("'",'"', '{', '}', '[', ']', '%q',): + data = data.replace(strippable, '') + + return data.strip() + + +def get_description(location): + """ + Return description from podspec. + + https://guides.cocoapods.org/syntax/podspec.html#description + description is in the form: + spec.description = <<-DESC + Computes the meaning of life. + Features: + 1. Is self aware + ... + 42. Likes candies. + DESC + """ + with io.open(location, encoding='utf-8', closefd=True) as data: + lines = data.readlines() + description = '' + for i, content in enumerate(lines): + if '.description' in content: + for cont in lines[i+1:]: + if 'DESC' in cont: + break + description += ' '.join([description, cont.strip()]) + break + description.strip() + return description \ No newline at end of file diff --git a/tests/packagedcode/data/cocoapods/podspec/BadgeHub.podspec b/tests/packagedcode/data/cocoapods/podspec/BadgeHub.podspec new file mode 100644 index 00000000000..8cc0b829fc7 --- /dev/null +++ b/tests/packagedcode/data/cocoapods/podspec/BadgeHub.podspec @@ -0,0 +1,43 @@ +# +# Be sure to run `pod lib lint BadgeHub.podspec' to ensure this is a +# valid spec before submitting. +# +# Any lines starting with a # are optional, but their use is encouraged +# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html +# + +Pod::Spec.new do |s| + s.name = 'BadgeHub' + s.version = '0.1.1' + s.summary = 'A way to quickly add a notification bedge icon to any view.' + +# This description is used to generate tags and improve search results. +# * Think: What does it do? Why did you write it? What is the focus? +# * Try to keep it short, snappy and to the point. +# * Write the description between the DESC delimiters below. +# * Finally, don't worry about the indent, CocoaPods strips it! + + s.description = <<-DESC +Make any UIView a full fledged animated notification center. It is a way to quickly add a notification badge icon to a UIView. It make very easy to add badge to any view. + DESC + + s.homepage = 'https://github.com/jogendra/BadgeHub' + # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' + s.license = { :type => 'MIT', :file => 'LICENSE' } + s.author = { 'jogendra' => 'imjog24@gmail.com' } + s.source = { :git => 'https://github.com/jogendra/BadgeHub.git', :tag => s.version.to_s } + s.social_media_url = 'https://twitter.com/jogendrafx' + + s.ios.deployment_target = '10.0' + s.swift_version = '5.0' + + s.source_files = 'BadgeHub/Classes/**/*' + + # s.resource_bundles = { + # 'BadgeHub' => ['BadgeHub/Assets/*.png'] + # } + + # s.public_header_files = 'Pod/Classes/**/*.h' + s.frameworks = 'UIKit', 'QuartzCore' + # s.dependency 'AFNetworking', '~> 2.3' +end diff --git a/tests/packagedcode/data/cocoapods/podspec/BadgeHub.podspec.expected.json b/tests/packagedcode/data/cocoapods/podspec/BadgeHub.podspec.expected.json new file mode 100644 index 00000000000..4554a8b2312 --- /dev/null +++ b/tests/packagedcode/data/cocoapods/podspec/BadgeHub.podspec.expected.json @@ -0,0 +1,52 @@ +{ + "type": "pods", + "namespace": null, + "name": "BadgeHub", + "version": "0.1.1", + "qualifiers": {}, + "subpath": null, + "primary_language": "Objective-C", + "description": " Make any UIView a full fledged animated notification center. It is a way to quickly add a notification badge icon to a UIView. It make very easy to add badge to any view.", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "jogendra", + "email": null, + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": "imjog24@gmail.com", + "url": null + } + ], + "keywords": [], + "homepage_url": "https://github.com/jogendra/BadgeHub", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": "https://github.com/jogendra/BadgeHub.git", + "copyright": null, + "license_expression": "mit AND unknown", + "declared_license": ":type => MIT, :file => LICENSE", + "notice_text": null, + "root_path": null, + "dependencies": [], + "contains_source_code": null, + "source_packages": [ + "https://github.com/jogendra/BadgeHub.git" + ], + "purl": "pkg:pods/BadgeHub@0.1.1", + "repository_homepage_url": "https://cocoapods.org/pods/BadgeHub", + "repository_download_url": "https://github.com/jogendra/BadgeHub/archive/0.1.1.zip", + "api_data_url": null +} \ No newline at end of file diff --git a/tests/packagedcode/data/cocoapods/podspec/LoadingShimmer.podspec b/tests/packagedcode/data/cocoapods/podspec/LoadingShimmer.podspec new file mode 100644 index 00000000000..47c6d0c4eee --- /dev/null +++ b/tests/packagedcode/data/cocoapods/podspec/LoadingShimmer.podspec @@ -0,0 +1,37 @@ +# +# Be sure to run `pod lib lint LoadingShimmer.podspec' to ensure this is a +# valid spec before submitting. +# +# Any lines starting with a # are optional, but their use is encouraged +# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html +# + +Pod::Spec.new do |s| + s.name = 'LoadingShimmer' + s.version = '1.0.3' + s.summary = 'An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.' + + s.description = <<-DESC + An easy way to add a shimmering effect to any view with just single line of code. It is useful as an unobtrusive loading indicator. This is a network request waiting for the framework, the framework to increase the dynamic effect, convenient and fast, a line of code can be used. + DESC + + s.homepage = 'https://github.com/jogendra/LoadingShimmer' + # s.screenshots = 'https://github.com/jogendra/LoadingShimmer/blob/master/Screenshots/demo.png', 'https://github.com/jogendra/LoadingShimmer/blob/master/Screenshots/shimmer.png' + s.license = { :type => 'MIT', :file => 'LICENSE' } + s.author = { 'jogendra' => 'jogendrafx@gmail.com' } + s.source = { :git => 'https://github.com/jogendra/LoadingShimmer.git', :tag => s.version.to_s } + s.social_media_url = 'https://twitter.com/jogendrafx' + + s.ios.deployment_target = '10.0' + s.swift_version = '5.0' + + s.source_files = 'LoadingShimmer/Classes/**/*' + + # s.resource_bundles = { + # 'LoadingShimmer' => ['LoadingShimmer/Assets/*.png'] + # } + + # s.public_header_files = 'Pod/Classes/**/*.h' + # s.frameworks = 'UIKit', 'MapKit' + # s.dependency 'AFNetworking', '~> 2.3' +end diff --git a/tests/packagedcode/data/cocoapods/podspec/LoadingShimmer.podspec.expected.json b/tests/packagedcode/data/cocoapods/podspec/LoadingShimmer.podspec.expected.json new file mode 100644 index 00000000000..c797a4e40e6 --- /dev/null +++ b/tests/packagedcode/data/cocoapods/podspec/LoadingShimmer.podspec.expected.json @@ -0,0 +1,52 @@ +{ + "type": "pods", + "namespace": null, + "name": "LoadingShimmer", + "version": "1.0.3", + "qualifiers": {}, + "subpath": null, + "primary_language": "Objective-C", + "description": " An easy way to add a shimmering effect to any view with just single line of code. It is useful as an unobtrusive loading indicator. This is a network request waiting for the framework, the framework to increase the dynamic effect, convenient and fast, a line of code can be used.", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "jogendra", + "email": null, + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": "jogendrafx@gmail.com", + "url": null + } + ], + "keywords": [], + "homepage_url": "https://github.com/jogendra/LoadingShimmer", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": "https://github.com/jogendra/LoadingShimmer.git", + "copyright": null, + "license_expression": "mit AND unknown", + "declared_license": ":type => MIT, :file => LICENSE", + "notice_text": null, + "root_path": null, + "dependencies": [], + "contains_source_code": null, + "source_packages": [ + "https://github.com/jogendra/LoadingShimmer.git" + ], + "purl": "pkg:pods/LoadingShimmer@1.0.3", + "repository_homepage_url": "https://cocoapods.org/pods/LoadingShimmer", + "repository_download_url": "https://github.com/jogendra/LoadingShimmer/archive/1.0.3.zip", + "api_data_url": null +} \ No newline at end of file diff --git a/tests/packagedcode/data/cocoapods/podspec/Starscream.podspec b/tests/packagedcode/data/cocoapods/podspec/Starscream.podspec new file mode 100644 index 00000000000..c657d2617a1 --- /dev/null +++ b/tests/packagedcode/data/cocoapods/podspec/Starscream.podspec @@ -0,0 +1,16 @@ +Pod::Spec.new do |s| + s.name = "Starscream" + s.version = "4.0.3" + s.summary = "A conforming WebSocket RFC 6455 client library in Swift." + s.homepage = "https://github.com/daltoniam/Starscream" + s.license = 'Apache License, Version 2.0' + s.author = {'Dalton Cherry' => 'http://daltoniam.com', 'Austin Cherry' => 'http://austincherry.me'} + s.source = { :git => 'https://github.com/daltoniam/Starscream.git', :tag => "#{s.version}"} + s.social_media_url = 'http://twitter.com/daltoniam' + s.ios.deployment_target = '8.0' + s.osx.deployment_target = '10.10' + s.tvos.deployment_target = '9.0' + s.watchos.deployment_target = '2.0' + s.source_files = 'Sources/**/*.swift' + s.swift_version = '5.0' +end diff --git a/tests/packagedcode/data/cocoapods/podspec/Starscream.podspec.expected.json b/tests/packagedcode/data/cocoapods/podspec/Starscream.podspec.expected.json new file mode 100644 index 00000000000..45368686efb --- /dev/null +++ b/tests/packagedcode/data/cocoapods/podspec/Starscream.podspec.expected.json @@ -0,0 +1,66 @@ +{ + "type": "pods", + "namespace": null, + "name": "Starscream", + "version": "4.0.3", + "qualifiers": {}, + "subpath": null, + "primary_language": "Objective-C", + "description": null, + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Dalton Cherry", + "email": null, + "url": null + }, + { + "type": "person", + "role": "author", + "name": "Austin Cherry", + "email": null, + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": "http://daltoniam.com", + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": "http://austincherry.me", + "url": null + } + ], + "keywords": [], + "homepage_url": "https://github.com/daltoniam/Starscream", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": "https://github.com/daltoniam/Starscream.git", + "copyright": null, + "license_expression": "apache-2.0", + "declared_license": "Apache License, Version 2.0", + "notice_text": null, + "root_path": null, + "dependencies": [], + "contains_source_code": null, + "source_packages": [ + "https://github.com/daltoniam/Starscream.git" + ], + "purl": "pkg:pods/Starscream@4.0.3", + "repository_homepage_url": "https://cocoapods.org/pods/Starscream", + "repository_download_url": "https://github.com/daltoniam/Starscream/archive/4.0.3.zip", + "api_data_url": null +} \ No newline at end of file diff --git a/tests/packagedcode/data/cocoapods/podspec/SwiftLib.podspec b/tests/packagedcode/data/cocoapods/podspec/SwiftLib.podspec new file mode 100644 index 00000000000..e18f147facc --- /dev/null +++ b/tests/packagedcode/data/cocoapods/podspec/SwiftLib.podspec @@ -0,0 +1,140 @@ +# +# Be sure to run `pod spec lint SwiftLib.podspec' to ensure this is a +# valid spec and to remove all comments including this before submitting the spec. +# +# To learn more about Podspec attributes see https://docs.cocoapods.org/specification.html +# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ +# + +Pod::Spec.new do |spec| + + # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # These will help people to find your library, and whilst it + # can feel like a chore to fill in it's definitely to your advantage. The + # summary should be tweet-length, and the description more in depth. + # + + spec.name = "SwiftLib" + spec.version = "0.0.1" + spec.summary = "A CocoaPods library written in Swift" + + # This description is used to generate tags and improve search results. + # * Think: What does it do? Why did you write it? What is the focus? + # * Try to keep it short, snappy and to the point. + # * Write the description between the DESC delimiters below. + # * Finally, don't worry about the indent, CocoaPods strips it! + spec.description = <<-DESC +This CocoaPods library helps you perform calculation. + DESC + + spec.homepage = "https://github.com/alizainprasla/swiftlib" + # spec.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" + + + # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Licensing your code is important. See https://choosealicense.com for more info. + # CocoaPods will detect a license file if there is a named LICENSE* + # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. + # + + # spec.license = "MIT (example)" + spec.license = { :type => "MIT", :file => "LICENSE" } + + + # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Specify the authors of the library, with email addresses. Email addresses + # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also + # accepts just a name if you'd rather not provide an email address. + # + # Specify a social_media_url where others can refer to, for example a twitter + # profile URL. + # + + spec.author = { "alizainprasla" => "alizainprasla@gmail.com" } + # Or just: spec.author = "jeantimex" + # spec.authors = { "jeantimex" => "jean.timex@gmail.com" } + # spec.social_media_url = "https://twitter.com/jeantimex" + + # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # If this Pod runs only on iOS or OS X, then specify the platform and + # the deployment target. You can optionally include the target after the platform. + # + + # spec.platform = :ios + # spec.platform = :ios, "5.0" + + # When using multiple platforms + spec.ios.deployment_target = "12.1" + # spec.osx.deployment_target = "10.7" + # spec.watchos.deployment_target = "2.0" + # spec.tvos.deployment_target = "9.0" + + spec.swift_version = "4.2" + + + # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Specify the location from where the source should be retrieved. + # Supports git, hg, bzr, svn and HTTP. + # + + spec.source = { :git => "https://github.com/alizainprasla/swiftlib.git", :tag => "#{spec.version}" } + + + # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # CocoaPods is smart about how it includes source code. For source files + # giving a folder will include any swift, h, m, mm, c & cpp files. + # For header files it will include any header in the folder. + # Not including the public_header_files will make all headers public. + # + + spec.source_files = "SwiftLib/**/*.{h,m,swift}" + # spec.exclude_files = "Classes/Exclude" + + # spec.public_header_files = "Classes/**/*.h" + + + # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # A list of resources included with the Pod. These are copied into the + # target bundle with a build phase script. Anything else will be cleaned. + # You can preserve files from being cleaned, please don't preserve + # non-essential files like tests, examples and documentation. + # + + # spec.resource = "icon.png" + # spec.resources = "Resources/*.png" + + # spec.preserve_paths = "FilesToSave", "MoreFilesToSave" + + + # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Link your library with frameworks, or libraries. Libraries do not include + # the lib prefix of their name. + # + + # spec.framework = "SomeFramework" + # spec.frameworks = "SomeFramework", "AnotherFramework" + + # spec.library = "iconv" + # spec.libraries = "iconv", "xml2" + + + # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # If your library depends on compiler flags you can set them in the xcconfig hash + # where they will only apply to your library. If you depend on other Podspecs + # you can include multiple dependencies to ensure it works. + + # spec.requires_arc = true + + # spec.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } + # spec.dependency "JSONKit", "~> 1.4" + +end \ No newline at end of file diff --git a/tests/packagedcode/data/cocoapods/podspec/SwiftLib.podspec.expected.json b/tests/packagedcode/data/cocoapods/podspec/SwiftLib.podspec.expected.json new file mode 100644 index 00000000000..2985d494aaa --- /dev/null +++ b/tests/packagedcode/data/cocoapods/podspec/SwiftLib.podspec.expected.json @@ -0,0 +1,52 @@ +{ + "type": "pods", + "namespace": null, + "name": "SwiftLib", + "version": "0.0.1", + "qualifiers": {}, + "subpath": null, + "primary_language": "Objective-C", + "description": " This CocoaPods library helps you perform calculation.", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "alizainprasla", + "email": null, + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": "alizainprasla@gmail.com", + "url": null + } + ], + "keywords": [], + "homepage_url": "https://github.com/alizainprasla/swiftlib", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": "https://github.com/alizainprasla/swiftlib.git", + "copyright": null, + "license_expression": "mit AND unknown", + "declared_license": ":type => MIT, :file => LICENSE", + "notice_text": null, + "root_path": null, + "dependencies": [], + "contains_source_code": null, + "source_packages": [ + "https://github.com/alizainprasla/swiftlib.git" + ], + "purl": "pkg:pods/SwiftLib@0.0.1", + "repository_homepage_url": "https://cocoapods.org/pods/SwiftLib", + "repository_download_url": "https://github.com/alizainprasla/swiftlib/archive/0.0.1.zip", + "api_data_url": null +} \ No newline at end of file diff --git a/tests/packagedcode/data/cocoapods/podspec/nanopb.podspec b/tests/packagedcode/data/cocoapods/podspec/nanopb.podspec new file mode 100644 index 00000000000..40264b2d353 --- /dev/null +++ b/tests/packagedcode/data/cocoapods/podspec/nanopb.podspec @@ -0,0 +1,33 @@ +Pod::Spec.new do |s| + s.name = "nanopb" + # CocoaPods minor version is minor * 10,000 + patch * 100 + fourth + s.version = "1.30905.0" + s.summary = "Protocol buffers with small code size." + + s.description = <<-DESC + Nanopb is a small code-size Protocol Buffers implementation + in ansi C. It is especially suitable for use in + microcontrollers, but fits any memory restricted system. + DESC + + s.homepage = "https://github.com/nanopb/nanopb" + s.license = { :type => 'zlib', :file => 'LICENSE.txt' } + s.author = { "Petteri Aimonen" => "jpa@nanopb.mail.kapsi.fi" } + s.source = { :git => "https://github.com/nanopb/nanopb.git", :tag => "0.3.9.5" } + + s.requires_arc = false + s.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) PB_FIELD_32BIT=1 PB_NO_PACKED_STRUCTS=1 PB_ENABLE_MALLOC=1' } + + s.source_files = '*.{h,c}' + s.public_header_files = '*.h' + + s.subspec 'encode' do |e| + e.public_header_files = ['pb.h', 'pb_encode.h', 'pb_common.h'] + e.source_files = ['pb.h', 'pb_common.h', 'pb_common.c', 'pb_encode.h', 'pb_encode.c'] + end + + s.subspec 'decode' do |d| + d.public_header_files = ['pb.h', 'pb_decode.h', 'pb_common.h'] + d.source_files = ['pb.h', 'pb_common.h', 'pb_common.c', 'pb_decode.h', 'pb_decode.c'] + end +end diff --git a/tests/packagedcode/data/cocoapods/podspec/nanopb.podspec.expected.json b/tests/packagedcode/data/cocoapods/podspec/nanopb.podspec.expected.json new file mode 100644 index 00000000000..f301d43621a --- /dev/null +++ b/tests/packagedcode/data/cocoapods/podspec/nanopb.podspec.expected.json @@ -0,0 +1,52 @@ +{ + "type": "pods", + "namespace": null, + "name": "nanopb", + "version": "1.30905.0", + "qualifiers": {}, + "subpath": null, + "primary_language": "Objective-C", + "description": " Nanopb is a small code-size Protocol Buffers implementation Nanopb is a small code-size Protocol Buffers implementation in ansi C. It is especially suitable for use in Nanopb is a small code-size Protocol Buffers implementation Nanopb is a small code-size Protocol Buffers implementation in ansi C. It is especially suitable for use in microcontrollers, but fits any memory restricted system.", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Petteri Aimonen", + "email": null, + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": "jpa@nanopb.mail.kapsi.fi", + "url": null + } + ], + "keywords": [], + "homepage_url": "https://github.com/nanopb/nanopb", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": "https://github.com/nanopb/nanopb.git", + "copyright": null, + "license_expression": "unknown", + "declared_license": ":type => zlib, :file => LICENSE.txt", + "notice_text": null, + "root_path": null, + "dependencies": [], + "contains_source_code": null, + "source_packages": [ + "https://github.com/nanopb/nanopb.git" + ], + "purl": "pkg:pods/nanopb@1.30905.0", + "repository_homepage_url": "https://cocoapods.org/pods/nanopb", + "repository_download_url": "https://github.com/nanopb/nanopb/archive/1.30905.0.zip", + "api_data_url": null +} \ No newline at end of file diff --git a/tests/packagedcode/data/plugin/help.txt b/tests/packagedcode/data/plugin/help.txt index 92d0fea1fce..5577a5a270a 100644 --- a/tests/packagedcode/data/plugin/help.txt +++ b/tests/packagedcode/data/plugin/help.txt @@ -211,6 +211,12 @@ Package: opam metafiles: *opam extensions: .opam +-------------------------------------------- +Package: pods + class: packagedcode.cocoapods:CocoapodsPackage + metafiles: *.podspec + extensions: .podspec + -------------------------------------------- Package: pypi class: packagedcode.pypi:PythonPackage diff --git a/tests/packagedcode/data/rubygems/gemspec/address_standardization.gemspec.expected.json b/tests/packagedcode/data/rubygems/gemspec/address_standardization.gemspec.expected.json index 097986ebb46..d3320b4ae69 100644 --- a/tests/packagedcode/data/rubygems/gemspec/address_standardization.gemspec.expected.json +++ b/tests/packagedcode/data/rubygems/gemspec/address_standardization.gemspec.expected.json @@ -1,54 +1,77 @@ -{ - "platform": "ruby", - "name": "mysmallidea-address_standardization", - "version": "0.4.1", - "homepage": "http://github.com/mcmire/address_standardization", - "summary": "A tiny Ruby library to quickly standardize a postal address", - "description": "A tiny Ruby library to quickly standardize a postal address", - "licenses": null, - "email": "elliot.winkler@gmail.com", - "authors": [ - "Elliot Winkler" - ], - "date": "2010-02-01 00:00:00 UTC", - "requirements": null, - "dependencies": [ - "mechanize (>= 0)", - "mcmire-context (>= 0, development)", - "mcmire-matchy (>= 0, development)" - ], - "files": [ - ".gitignore", - "README.md", - "Rakefile", - "TODO", - "address_standardization.gemspec", - "lib/address_standardization.rb", - "lib/address_standardization/abstract_service.rb", - "lib/address_standardization/address.rb", - "lib/address_standardization/class_level_inheritable_attributes.rb", - "lib/address_standardization/google_maps.rb", - "lib/address_standardization/melissa_data.rb", - "lib/address_standardization/ruby_ext.rb", - "lib/address_standardization/version.rb", - "test/google_maps_test.rb", - "test/melissa_data_test.rb", - "test/test_helper.rb" - ], - "test_files": [ - "test/google_maps_test.rb", - "test/melissa_data_test.rb", - "test/test_helper.rb" - ], - "extra_rdoc_files": [ - "README.md", - "TODO" - ], - "rubygems_version": "1.3.5", - "required_ruby_version": ">= 0", - "rubyforge_project": null, - "loaded_from": "rubygems/address_standardization.gemspec", - "original_platform": null, - "new_platform": "ruby", - "specification_version": 3 -} \ No newline at end of file +[ + { + "type": "gem", + "namespace": null, + "name": "mysmallidea-address_standardization", + "version": "0.4.1", + "qualifiers": {}, + "subpath": null, + "primary_language": "Ruby", + "description": "A tiny Ruby library to quickly standardize a postal address", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Elliot Winkler", + "email": null, + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": "elliot.winkler@gmail.com", + "url": null + } + ], + "keywords": [], + "homepage_url": "http://github.com/mcmire/address_standardization", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": null, + "notice_text": null, + "root_path": null, + "dependencies": [ + { + "purl": "pkg:gem/mcmire-context", + "requirement": ">= 0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/mcmire-matchy", + "requirement": ">= 0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/mechanize", + "requirement": ">= 0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + } + ], + "contains_source_code": null, + "source_packages": [], + "purl": "pkg:gem/mysmallidea-address_standardization@0.4.1", + "repository_homepage_url": "https://rubygems.org/gems/mysmallidea-address_standardization/versions/0.4.1", + "repository_download_url": "https://rubygems.org/downloads/mysmallidea-address_standardization-0.4.1.gem", + "api_data_url": "https://rubygems.org/api/v2/rubygems/mysmallidea-address_standardization/versions/0.4.1.json" + } +] \ No newline at end of file diff --git a/tests/packagedcode/data/rubygems/gemspec/arel.gemspec.expected.json b/tests/packagedcode/data/rubygems/gemspec/arel.gemspec.expected.json index 32bcc7da9ce..adec2fe27c7 100644 --- a/tests/packagedcode/data/rubygems/gemspec/arel.gemspec.expected.json +++ b/tests/packagedcode/data/rubygems/gemspec/arel.gemspec.expected.json @@ -1,187 +1,111 @@ -{ - "platform": "ruby", - "name": "arel", - "version": "2.0.7.beta.20110429111451", - "homepage": "http://github.com/rails/arel", - "summary": "Arel is a SQL AST manager for Ruby", - "description": "Arel is a SQL AST manager for Ruby. It\n\n1. Simplifies the generation complex of SQL queries\n2. Adapts to various RDBMS systems\n\nIt is intended to be a framework framework; that is, you can build your own ORM\nwith it, focusing on innovative object and collection modeling as opposed to\ndatabase compatibility and query generation.", - "licenses": null, - "email": [ - "aaron@tenderlovemaking.com", - "bryan@brynary.com", - "miloops@gmail.com", - "nick@example.org" - ], - "authors": [ - "Aaron Patterson", - "Bryan Halmkamp", - "Emilio Tagua", - "Nick Kallen" - ], - "date": "2011-04-29 00:00:00 UTC", - "requirements": null, - "dependencies": [ - "minitest (>= 2.0.2, development)", - "hoe (>= 2.9.1, development)" - ], - "files": [ - ".autotest", - ".gemtest", - "History.txt", - "MIT-LICENSE.txt", - "Manifest.txt", - "README.markdown", - "Rakefile", - "arel.gemspec", - "lib/arel.rb", - "lib/arel/alias_predication.rb", - "lib/arel/attributes.rb", - "lib/arel/attributes/attribute.rb", - "lib/arel/compatibility/wheres.rb", - "lib/arel/crud.rb", - "lib/arel/delete_manager.rb", - "lib/arel/deprecated.rb", - "lib/arel/expression.rb", - "lib/arel/expressions.rb", - "lib/arel/factory_methods.rb", - "lib/arel/insert_manager.rb", - "lib/arel/math.rb", - "lib/arel/nodes.rb", - "lib/arel/nodes/and.rb", - "lib/arel/nodes/binary.rb", - "lib/arel/nodes/count.rb", - "lib/arel/nodes/delete_statement.rb", - "lib/arel/nodes/equality.rb", - "lib/arel/nodes/function.rb", - "lib/arel/nodes/in.rb", - "lib/arel/nodes/infix_operation.rb", - "lib/arel/nodes/inner_join.rb", - "lib/arel/nodes/insert_statement.rb", - "lib/arel/nodes/join_source.rb", - "lib/arel/nodes/named_function.rb", - "lib/arel/nodes/node.rb", - "lib/arel/nodes/ordering.rb", - "lib/arel/nodes/outer_join.rb", - "lib/arel/nodes/select_core.rb", - "lib/arel/nodes/select_statement.rb", - "lib/arel/nodes/sql_literal.rb", - "lib/arel/nodes/string_join.rb", - "lib/arel/nodes/table_alias.rb", - "lib/arel/nodes/terminal.rb", - "lib/arel/nodes/unary.rb", - "lib/arel/nodes/unqualified_column.rb", - "lib/arel/nodes/update_statement.rb", - "lib/arel/nodes/values.rb", - "lib/arel/nodes/with.rb", - "lib/arel/order_predications.rb", - "lib/arel/predications.rb", - "lib/arel/relation.rb", - "lib/arel/select_manager.rb", - "lib/arel/sql/engine.rb", - "lib/arel/sql_literal.rb", - "lib/arel/table.rb", - "lib/arel/tree_manager.rb", - "lib/arel/update_manager.rb", - "lib/arel/visitors.rb", - "lib/arel/visitors/depth_first.rb", - "lib/arel/visitors/dot.rb", - "lib/arel/visitors/ibm_db.rb", - "lib/arel/visitors/join_sql.rb", - "lib/arel/visitors/mssql.rb", - "lib/arel/visitors/mysql.rb", - "lib/arel/visitors/oracle.rb", - "lib/arel/visitors/order_clauses.rb", - "lib/arel/visitors/postgresql.rb", - "lib/arel/visitors/sqlite.rb", - "lib/arel/visitors/to_sql.rb", - "lib/arel/visitors/visitor.rb", - "lib/arel/visitors/where_sql.rb", - "test/attributes/test_attribute.rb", - "test/helper.rb", - "test/nodes/test_as.rb", - "test/nodes/test_bin.rb", - "test/nodes/test_count.rb", - "test/nodes/test_delete_statement.rb", - "test/nodes/test_equality.rb", - "test/nodes/test_insert_statement.rb", - "test/nodes/test_named_function.rb", - "test/nodes/test_node.rb", - "test/nodes/test_not.rb", - "test/nodes/test_or.rb", - "test/nodes/test_select_core.rb", - "test/nodes/test_select_statement.rb", - "test/nodes/test_sql_literal.rb", - "test/nodes/test_sum.rb", - "test/nodes/test_update_statement.rb", - "test/support/fake_record.rb", - "test/test_activerecord_compat.rb", - "test/test_attributes.rb", - "test/test_crud.rb", - "test/test_delete_manager.rb", - "test/test_factory_methods.rb", - "test/test_insert_manager.rb", - "test/test_select_manager.rb", - "test/test_table.rb", - "test/test_update_manager.rb", - "test/visitors/test_depth_first.rb", - "test/visitors/test_dot.rb", - "test/visitors/test_ibm_db.rb", - "test/visitors/test_join_sql.rb", - "test/visitors/test_mssql.rb", - "test/visitors/test_mysql.rb", - "test/visitors/test_oracle.rb", - "test/visitors/test_postgres.rb", - "test/visitors/test_sqlite.rb", - "test/visitors/test_to_sql.rb" - ], - "test_files": [ - "test/attributes/test_attribute.rb", - "test/nodes/test_as.rb", - "test/nodes/test_bin.rb", - "test/nodes/test_count.rb", - "test/nodes/test_delete_statement.rb", - "test/nodes/test_equality.rb", - "test/nodes/test_insert_statement.rb", - "test/nodes/test_named_function.rb", - "test/nodes/test_node.rb", - "test/nodes/test_not.rb", - "test/nodes/test_or.rb", - "test/nodes/test_select_core.rb", - "test/nodes/test_select_statement.rb", - "test/nodes/test_sql_literal.rb", - "test/nodes/test_sum.rb", - "test/nodes/test_update_statement.rb", - "test/test_activerecord_compat.rb", - "test/test_attributes.rb", - "test/test_crud.rb", - "test/test_delete_manager.rb", - "test/test_factory_methods.rb", - "test/test_insert_manager.rb", - "test/test_select_manager.rb", - "test/test_table.rb", - "test/test_update_manager.rb", - "test/visitors/test_depth_first.rb", - "test/visitors/test_dot.rb", - "test/visitors/test_ibm_db.rb", - "test/visitors/test_join_sql.rb", - "test/visitors/test_mssql.rb", - "test/visitors/test_mysql.rb", - "test/visitors/test_oracle.rb", - "test/visitors/test_postgres.rb", - "test/visitors/test_sqlite.rb", - "test/visitors/test_to_sql.rb" - ], - "extra_rdoc_files": [ - "History.txt", - "MIT-LICENSE.txt", - "Manifest.txt", - "README.markdown" - ], - "rubygems_version": "1.6.1", - "required_ruby_version": ">= 0", - "rubyforge_project": "arel", - "loaded_from": "rubygems/arel.gemspec", - "original_platform": null, - "new_platform": "ruby", - "specification_version": 3 -} \ No newline at end of file +[ + { + "type": "gem", + "namespace": null, + "name": "arel", + "version": "2.0.7.beta.20110429111451", + "qualifiers": {}, + "subpath": null, + "primary_language": "Ruby", + "description": "Arel is a SQL AST manager for Ruby. It", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Aaron Patterson", + "email": null, + "url": null + }, + { + "type": "person", + "role": "author", + "name": " Bryan Halmkamp", + "email": null, + "url": null + }, + { + "type": "person", + "role": "author", + "name": " Emilio Tagua", + "email": null, + "url": null + }, + { + "type": "person", + "role": "author", + "name": " Nick Kallen", + "email": null, + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": "aaron@tenderlovemaking.com", + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": " bryan@brynary.com", + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": " miloops@gmail.com", + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": " nick@example.org", + "url": null + } + ], + "keywords": [], + "homepage_url": "http://github.com/rails/arel", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": null, + "notice_text": null, + "root_path": null, + "dependencies": [ + { + "purl": "pkg:gem/minitest", + "requirement": ">= 2.0.2", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/hoe", + "requirement": ">= 2.9.1", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + } + ], + "contains_source_code": null, + "source_packages": [], + "purl": "pkg:gem/arel@2.0.7.beta.20110429111451", + "repository_homepage_url": "https://rubygems.org/gems/arel/versions/2.0.7.beta.20110429111451", + "repository_download_url": "https://rubygems.org/downloads/arel-2.0.7.beta.20110429111451.gem", + "api_data_url": "https://rubygems.org/api/v2/rubygems/arel/versions/2.0.7.beta.20110429111451.json" + } +] \ No newline at end of file diff --git a/tests/packagedcode/data/rubygems/gemspec/cat.gemspec.expected.json b/tests/packagedcode/data/rubygems/gemspec/cat.gemspec.expected.json index 8c284842871..4e4d6f54d43 100644 --- a/tests/packagedcode/data/rubygems/gemspec/cat.gemspec.expected.json +++ b/tests/packagedcode/data/rubygems/gemspec/cat.gemspec.expected.json @@ -1,35 +1,101 @@ -{ - "platform": "ruby", - "name": "cat_", - "version": "12", - "homepage": "https://github.com/elct9620/.cat", - "summary": "The loading cat generator.", - "description": "The loading cat generator.", - "licenses": null, - "email": [ - "elct9620@frost.tw" - ], - "authors": [ - "\u84bc\u6642\u5f26\u4e5f" - ], - "date": "2019-01-07 00:00:00 UTC", - "requirements": null, - "dependencies": [ - "rack (>= 0)", - "sassc (>= 0)", - "slim (>= 0)", - "bundler (~> 1.13, development)", - "rake (~> 10.0, development)", - "rspec (~> 3.0, development)" - ], - "files": [], - "test_files": null, - "extra_rdoc_files": null, - "rubygems_version": "2.5.2.1", - "required_ruby_version": ">= 0", - "rubyforge_project": null, - "loaded_from": "rubygems/cat.gemspec", - "original_platform": null, - "new_platform": "ruby", - "specification_version": 4 -} +[ + { + "type": "gem", + "namespace": null, + "name": "cat_", + "version": "12", + "qualifiers": {}, + "subpath": null, + "primary_language": "Ruby", + "description": "The loading cat generator.", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "\u84bc\u6642\u5f26\u4e5f", + "email": null, + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": "elct9620@frost.tw", + "url": null + } + ], + "keywords": [], + "homepage_url": "https://github.com/elct9620/.cat", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": null, + "notice_text": null, + "root_path": null, + "dependencies": [ + { + "purl": "pkg:gem/bundler", + "requirement": "~> 1.13", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/rake", + "requirement": "~> 10.0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/rspec", + "requirement": "~> 3.0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/rack", + "requirement": "", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/sassc", + "requirement": "", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/slim", + "requirement": "", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + } + ], + "contains_source_code": null, + "source_packages": [], + "purl": "pkg:gem/cat_@12", + "repository_homepage_url": "https://rubygems.org/gems/cat_/versions/12", + "repository_download_url": "https://rubygems.org/downloads/cat_-12.gem", + "api_data_url": "https://rubygems.org/api/v2/rubygems/cat_/versions/12.json" + } +] \ No newline at end of file diff --git a/tests/packagedcode/data/rubygems/gemspec/github.gemspec b/tests/packagedcode/data/rubygems/gemspec/github.gemspec new file mode 100644 index 00000000000..38a12dd4088 --- /dev/null +++ b/tests/packagedcode/data/rubygems/gemspec/github.gemspec @@ -0,0 +1,31 @@ +# -*- encoding: utf-8 -*- +$:.push File.expand_path("../lib", __FILE__) +require "github/version" + +Gem::Specification.new do |s| + s.name = "github" + s.version = GitHub::VERSION + s.platform = Gem::Platform::RUBY + s.authors = ['Chris Wanstrath', 'Kevin Ballard', 'Scott Chacon', 'Dr Nic Williams'] + s.email = ["drnicwilliams@gmail.com"] + s.homepage = "https://github.com/defunkt/github-gem" + s.summary = "The official `github` command line helper for simplifying your GitHub experience." + s.description = "The official `github` command line helper for simplifying your GitHub experience." + + s.rubyforge_project = "github" + + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.require_paths = ["lib"] + + s.add_dependency "text-hyphen", "1.0.0" + s.add_dependency "text-format", "1.0.0" + s.add_dependency "highline", "~> 1.6" + s.add_dependency "json_pure", "~> 1.5.1" + s.add_dependency "launchy", "~> 2.0.2" + + s.add_development_dependency "rake" + s.add_development_dependency "rspec", "~>1.3.1" + s.add_development_dependency "activerecord", "~>3.0.0" +end diff --git a/tests/packagedcode/data/rubygems/gemspec/github.gemspec.expected.json b/tests/packagedcode/data/rubygems/gemspec/github.gemspec.expected.json new file mode 100644 index 00000000000..b2ec1e617b2 --- /dev/null +++ b/tests/packagedcode/data/rubygems/gemspec/github.gemspec.expected.json @@ -0,0 +1,138 @@ +[ + { + "type": "gem", + "namespace": null, + "name": "github", + "version": "GitHub::VERSION", + "qualifiers": {}, + "subpath": null, + "primary_language": "Ruby", + "description": "The official `github` command line helper for simplifying your GitHub experience.", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Chris Wanstrath", + "email": null, + "url": null + }, + { + "type": "person", + "role": "author", + "name": " Kevin Ballard", + "email": null, + "url": null + }, + { + "type": "person", + "role": "author", + "name": " Scott Chacon", + "email": null, + "url": null + }, + { + "type": "person", + "role": "author", + "name": " Dr Nic Williams", + "email": null, + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": "drnicwilliams@gmail.com", + "url": null + } + ], + "keywords": [], + "homepage_url": "https://github.com/defunkt/github-gem", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": null, + "notice_text": null, + "root_path": null, + "dependencies": [ + { + "purl": "pkg:gem/rake", + "requirement": "", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/rspec", + "requirement": "~>1.3.1", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/activerecord", + "requirement": "~>3.0.0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/text-hyphen", + "requirement": "1.0.0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/text-format", + "requirement": "1.0.0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/highline", + "requirement": "~> 1.6", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/json_pure", + "requirement": "~> 1.5.1", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/launchy", + "requirement": "~> 2.0.2", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + } + ], + "contains_source_code": null, + "source_packages": [], + "purl": "pkg:gem/github@GitHub::VERSION", + "repository_homepage_url": "https://rubygems.org/gems/github/versions/GitHub::VERSION", + "repository_download_url": "https://rubygems.org/downloads/github-GitHub::VERSION.gem", + "api_data_url": "https://rubygems.org/api/v2/rubygems/github/versions/GitHub::VERSION.json" + } +] \ No newline at end of file diff --git a/tests/packagedcode/data/rubygems/gemspec/mecab-ruby.gemspec b/tests/packagedcode/data/rubygems/gemspec/mecab-ruby.gemspec new file mode 100644 index 00000000000..f49f356b937 --- /dev/null +++ b/tests/packagedcode/data/rubygems/gemspec/mecab-ruby.gemspec @@ -0,0 +1,16 @@ +Gem::Specification.new do |s| + s.name = %q{mecab-ruby} + s.version = '0.99' + s.author = 'Taku Kudo' + s.date = '2011-12-24' + s.description = "Ruby bindings for MeCab, a morphological analyzer." + s.email = 'taku@chasen.org' + s.extensions = [ 'extconf.rb' ] + s.files = [ 'AUTHORS', 'BSD', 'COPYING', 'GPL', 'LGPL', + 'MeCab_wrap.cpp', 'README', 'bindings.html', + 'extconf.rb', 'mecab-ruby.gemspec', 'test.rb' ] + s.has_rdoc = false + s.homepage = 'http://mecab.sourceforge.net/' + s.summary = 'Ruby bindings for MeCab.' +end + diff --git a/tests/packagedcode/data/rubygems/gemspec/mecab-ruby.gemspec.expected.json b/tests/packagedcode/data/rubygems/gemspec/mecab-ruby.gemspec.expected.json new file mode 100644 index 00000000000..9efe0a01382 --- /dev/null +++ b/tests/packagedcode/data/rubygems/gemspec/mecab-ruby.gemspec.expected.json @@ -0,0 +1,52 @@ +[ + { + "type": "gem", + "namespace": null, + "name": "mecab-ruby", + "version": "0.99", + "qualifiers": {}, + "subpath": null, + "primary_language": "Ruby", + "description": "Ruby bindings for MeCab, a morphological analyzer.", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Taku Kudo", + "email": null, + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": "taku@chasen.org", + "url": null + } + ], + "keywords": [], + "homepage_url": "http://mecab.sourceforge.net/", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": null, + "notice_text": null, + "root_path": null, + "dependencies": [], + "contains_source_code": null, + "source_packages": [], + "purl": "pkg:gem/mecab-ruby@0.99", + "repository_homepage_url": "https://rubygems.org/gems/mecab-ruby/versions/0.99", + "repository_download_url": "https://rubygems.org/downloads/mecab-ruby-0.99.gem", + "api_data_url": "https://rubygems.org/api/v2/rubygems/mecab-ruby/versions/0.99.json" + } +] \ No newline at end of file diff --git a/tests/packagedcode/data/rubygems/gemspec/oj.gemspec.expected.json b/tests/packagedcode/data/rubygems/gemspec/oj.gemspec.expected.json index e69de29bb2d..138456eba1d 100644 --- a/tests/packagedcode/data/rubygems/gemspec/oj.gemspec.expected.json +++ b/tests/packagedcode/data/rubygems/gemspec/oj.gemspec.expected.json @@ -0,0 +1,85 @@ +[ + { + "type": "gem", + "namespace": null, + "name": "oj", + "version": "::Oj::VERSION", + "qualifiers": {}, + "subpath": null, + "primary_language": "Ruby", + "description": "The fastest JSON parser and object serializer.", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Peter Ohler", + "email": null, + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": "peter@ohler.com", + "url": null + } + ], + "keywords": [], + "homepage_url": "http://www.ohler.com/oj", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": null, + "notice_text": null, + "root_path": null, + "dependencies": [ + { + "purl": "pkg:gem/rake-compiler", + "requirement": ">= 0.9, < 2.0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/minitest", + "requirement": "~> 5", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/test-unit", + "requirement": "~> 3.0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/wwtd", + "requirement": "~> 0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + } + ], + "contains_source_code": null, + "source_packages": [], + "purl": "pkg:gem/oj@::Oj::VERSION", + "repository_homepage_url": "https://rubygems.org/gems/oj/versions/::Oj::VERSION", + "repository_download_url": "https://rubygems.org/downloads/oj-::Oj::VERSION.gem", + "api_data_url": "https://rubygems.org/api/v2/rubygems/oj/versions/::Oj::VERSION.json" + } +] \ No newline at end of file diff --git a/tests/packagedcode/data/rubygems/gemspec/rubocop.gemspec b/tests/packagedcode/data/rubygems/gemspec/rubocop.gemspec index 6c9fbeeb54a..8087e2de78d 100644 --- a/tests/packagedcode/data/rubygems/gemspec/rubocop.gemspec +++ b/tests/packagedcode/data/rubygems/gemspec/rubocop.gemspec @@ -11,10 +11,7 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.required_ruby_version = '>= 2.2.0' s.authors = ['Bozhidar Batsov', 'Jonas Arvidsson', 'Yuji Nakayama'] - s.description = <<-DESCRIPTION - Automatic Ruby code style checking tool. - Aims to enforce the community-driven Ruby Style Guide. - DESCRIPTION + s.description = "Automatic Ruby code style checking tool. Aims to enforce the community-driven Ruby Style Guide." s.email = 'rubocop@googlegroups.com' s.files = `git ls-files assets bin config lib LICENSE.txt README.md` diff --git a/tests/packagedcode/data/rubygems/gemspec/rubocop.gemspec.expected.json b/tests/packagedcode/data/rubygems/gemspec/rubocop.gemspec.expected.json index e69de29bb2d..6af1b30844e 100644 --- a/tests/packagedcode/data/rubygems/gemspec/rubocop.gemspec.expected.json +++ b/tests/packagedcode/data/rubygems/gemspec/rubocop.gemspec.expected.json @@ -0,0 +1,139 @@ +[ + { + "type": "gem", + "namespace": null, + "name": "rubocop", + "version": "RuboCop::Version::STRING", + "qualifiers": {}, + "subpath": null, + "primary_language": "Ruby", + "description": "Automatic Ruby code style checking tool. Aims to enforce the community-driven Ruby Style Guide.", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Bozhidar Batsov", + "email": null, + "url": null + }, + { + "type": "person", + "role": "author", + "name": " Jonas Arvidsson", + "email": null, + "url": null + }, + { + "type": "person", + "role": "author", + "name": " Yuji Nakayama", + "email": null, + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": "rubocop@googlegroups.com", + "url": null + } + ], + "keywords": [], + "homepage_url": "https://github.com/rubocop-hq/rubocop", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": null, + "notice_text": null, + "root_path": null, + "dependencies": [ + { + "purl": "pkg:gem/bundler", + "requirement": ">= 1.3.0, < 3.0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/rack", + "requirement": ">= 2.0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/jaro_winkler", + "requirement": "~> 1.5.1", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/parallel", + "requirement": "~> 1.10", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/parser", + "requirement": ">= 2.5", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/powerpack", + "requirement": "~> 0.1", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/rainbow", + "requirement": ">= 2.2.2, < 4.0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/ruby-progressbar", + "requirement": "~> 1.7", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/unicode-display_width", + "requirement": "~> 1.4.0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + } + ], + "contains_source_code": null, + "source_packages": [], + "purl": "pkg:gem/rubocop@RuboCop::Version::STRING", + "repository_homepage_url": "https://rubygems.org/gems/rubocop/versions/RuboCop::Version::STRING", + "repository_download_url": "https://rubygems.org/downloads/rubocop-RuboCop::Version::STRING.gem", + "api_data_url": "https://rubygems.org/api/v2/rubygems/rubocop/versions/RuboCop::Version::STRING.json" + } +] \ No newline at end of file diff --git a/tests/packagedcode/data/rubygems/gemspec/with_variables.gemspec.expected.json b/tests/packagedcode/data/rubygems/gemspec/with_variables.gemspec.expected.json index e69de29bb2d..036d15f6daa 100644 --- a/tests/packagedcode/data/rubygems/gemspec/with_variables.gemspec.expected.json +++ b/tests/packagedcode/data/rubygems/gemspec/with_variables.gemspec.expected.json @@ -0,0 +1,125 @@ +[ + { + "type": "gem", + "namespace": null, + "name": "ProviderDSL::GemDescription::NAME", + "version": "ProviderDSL::GemDescription::VERSION", + "qualifiers": {}, + "subpath": null, + "primary_language": "Ruby", + "description": "See the project home page for more information", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "ProviderDSL::GemDescription::AUTHORS", + "email": null, + "url": null + }, + { + "type": "person", + "role": "email", + "name": null, + "email": "ProviderDSL::GemDescription::EMAIL", + "url": null + } + ], + "keywords": [], + "homepage_url": "ProviderDSL::GemDescription::PAGE", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": null, + "notice_text": null, + "root_path": null, + "dependencies": [ + { + "purl": "pkg:gem/rake", + "requirement": "~> 11.3", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/rubocop", + "requirement": "~> 0.44.1", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/rspec", + "requirement": "~> 3.5", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/rspec-mocks", + "requirement": "~> 3.5", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/ipaddress", + "requirement": "~> 0.8.3", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/gandi", + "requirement": "~> 3.3, >= 3.3.27", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/gcloud", + "requirement": "~> 0.21.0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/google-cloud-error_reporting", + "requirement": "~> 0.21.0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + }, + { + "purl": "pkg:gem/map", + "requirement": "~> 6.6", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false + } + ], + "contains_source_code": null, + "source_packages": [], + "purl": "pkg:gem/ProviderDSL::GemDescription::NAME@ProviderDSL::GemDescription::VERSION", + "repository_homepage_url": "https://rubygems.org/gems/ProviderDSL::GemDescription::NAME/versions/ProviderDSL::GemDescription::VERSION", + "repository_download_url": "https://rubygems.org/downloads/ProviderDSL::GemDescription::NAME-ProviderDSL::GemDescription::VERSION.gem", + "api_data_url": "https://rubygems.org/api/v2/rubygems/ProviderDSL::GemDescription::NAME/versions/ProviderDSL::GemDescription::VERSION.json" + } +] \ No newline at end of file diff --git a/tests/packagedcode/test_cocoapods.py b/tests/packagedcode/test_cocoapods.py new file mode 100644 index 00000000000..a5d061bf08f --- /dev/null +++ b/tests/packagedcode/test_cocoapods.py @@ -0,0 +1,69 @@ +# +# Copyright (c) nexB Inc. and others. All rights reserved. +# http://nexb.com and https://github.com/nexB/scancode-toolkit/ +# The ScanCode software is licensed under the Apache License version 2.0. +# Data generated with ScanCode require an acknowledgment. +# ScanCode is a trademark of nexB Inc. +# +# You may not use this software except in compliance with the License. +# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# +# When you publish or redistribute any data created with ScanCode or any ScanCode +# derivative work, you must accompany this data with the following acknowledgment: +# +# Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES +# OR CONDITIONS OF ANY KIND, either express or implied. No content created from +# ScanCode should be considered or used as legal advice. Consult an Attorney +# for any legal advice. +# ScanCode is a free software code scanning tool from nexB Inc. and others. +# Visit https://github.com/nexB/scancode-toolkit/ for support and download. + +from __future__ import absolute_import +from __future__ import print_function +from __future__ import unicode_literals + +import os +import pytest + +from commoncode.system import py2 +from packagedcode import cocoapods +from packages_test_utils import PackageTester + + +@pytest.mark.skipif(py2, reason='Does not pass on Python2') +class TestRubyGemspec(PackageTester): + test_data_dir = os.path.join(os.path.dirname(__file__), 'data') + + def test_rubygems_can_parse_BadgeHub(self): + test_file = self.get_test_loc('cocoapods/podspec/BadgeHub.podspec') + expected_loc = self.get_test_loc('cocoapods/podspec/BadgeHub.podspec.expected.json') + packages = cocoapods.parse(test_file) + self.check_package(packages, expected_loc, regen=False) + + def test_rubygems_can_parse_LoadingShimmer(self): + test_file = self.get_test_loc('cocoapods/podspec/LoadingShimmer.podspec') + expected_loc = self.get_test_loc('cocoapods/podspec/LoadingShimmer.podspec.expected.json') + packages = cocoapods.parse(test_file) + self.check_package(packages, expected_loc, regen=False) + + def test_rubygems_can_parse_nanopb(self): + test_file = self.get_test_loc('cocoapods/podspec/nanopb.podspec') + expected_loc = self.get_test_loc('cocoapods/podspec/nanopb.podspec.expected.json') + packages = cocoapods.parse(test_file) + self.check_package(packages, expected_loc, regen=False) + + def test_rubygems_can_parse_Starscream(self): + test_file = self.get_test_loc('cocoapods/podspec/Starscream.podspec') + expected_loc = self.get_test_loc('cocoapods/podspec/Starscream.podspec.expected.json') + packages = cocoapods.parse(test_file) + self.check_package(packages, expected_loc, regen=False) + + def test_rubygems_can_parse_SwiftLib(self): + test_file = self.get_test_loc('cocoapods/podspec/SwiftLib.podspec') + expected_loc = self.get_test_loc('cocoapods/podspec/SwiftLib.podspec.expected.json') + packages = cocoapods.parse(test_file) + self.check_package(packages, expected_loc, regen=False) \ No newline at end of file diff --git a/tests/packagedcode/test_rubygems.py b/tests/packagedcode/test_rubygems.py index 28337475ee9..e7c6a8689e8 100644 --- a/tests/packagedcode/test_rubygems.py +++ b/tests/packagedcode/test_rubygems.py @@ -30,6 +30,7 @@ import io import json import os +import pytest from unittest.case import expectedFailure import saneyaml @@ -47,66 +48,57 @@ # this is a multiple personality package (Java and Ruby) # see also https://rubygems.org/downloads/jaro_winkler-1.5.1-java.gem -# NOTE: this needs to be implemented first -@expectedFailure -class TestRubyGemspec(FileBasedTesting): +@pytest.mark.skipif(py2, reason='Does not pass on Python2') +class TestRubyGemspec(PackageTester): test_data_dir = os.path.join(os.path.dirname(__file__), 'data') - def check_gemspec(self, test_loc, expected_loc, regen=False): - test_loc = self.get_test_loc(test_loc) - expected_loc = self.get_test_loc(expected_loc) - results = rubygems.get_gemspec_data(test_loc) - - try: - # fix absolute paths for testing - rel_path = results['loaded_from'] - rel_path = [p for p in rel_path.split('/') if p] - rel_path = '/'.join(rel_path[-2:]) - results['loaded_from'] = rel_path - except: - pass - - if regen: - if py2: - mode = 'wb' - if py3: - mode = 'w' - with open(expected_loc, mode) as ex: - json.dump(results, ex, indent=2) - with io.open(expected_loc, encoding='UTF-8') as ex: - expected = json.load(ex) - - assert sorted(expected.items()) == sorted(results.items()) - def test_rubygems_can_parse_gemspec_address_standardization_gemspec(self): - self.check_gemspec( - 'rubygems/gemspec/address_standardization.gemspec', - 'rubygems/gemspec/address_standardization.gemspec.expected.json') + test_file = self.get_test_loc('rubygems/gemspec/address_standardization.gemspec') + expected_loc = self.get_test_loc('rubygems/gemspec/address_standardization.gemspec.expected.json') + packages = rubygems.RubyGem.recognize(test_file) + self.check_packages(packages, expected_loc, regen=False) def test_rubygems_can_parse_gemspec_arel_gemspec(self): - self.check_gemspec( - 'rubygems/gemspec/arel.gemspec', - 'rubygems/gemspec/arel.gemspec.expected.json') + test_file = self.get_test_loc('rubygems/gemspec/arel.gemspec') + expected_loc = self.get_test_loc('rubygems/gemspec/arel.gemspec.expected.json') + packages = rubygems.RubyGem.recognize(test_file) + self.check_packages(packages, expected_loc, regen=False) + + def test_rubygems_cat_gemspec(self): + test_file = self.get_test_loc('rubygems/gemspec/cat.gemspec') + expected_loc = self.get_test_loc('rubygems/gemspec/cat.gemspec.expected.json') + packages = rubygems.RubyGem.recognize(test_file) + self.check_packages(packages, expected_loc, regen=False) - def test_rubygems_modern_gemspec(self): - self.check_gemspec( - 'rubygems/gemspec/cat.gemspec', - 'rubygems/gemspec/cat.gemspec.expected.json') + def test_rubygems_github_gemspec(self): + test_file = self.get_test_loc('rubygems/gemspec/github.gemspec') + expected_loc = self.get_test_loc('rubygems/gemspec/github.gemspec.expected.json') + packages = rubygems.RubyGem.recognize(test_file) + self.check_packages(packages, expected_loc, regen=False) + + def test_rubygems_mecab_ruby_gemspec(self): + test_file = self.get_test_loc('rubygems/gemspec/mecab-ruby.gemspec') + expected_loc = self.get_test_loc('rubygems/gemspec/mecab-ruby.gemspec.expected.json') + packages = rubygems.RubyGem.recognize(test_file) + self.check_packages(packages, expected_loc, regen=False) def test_rubygems_oj_gemspec(self): - self.check_gemspec( - 'rubygems/gemspec/oj.gemspec', - 'rubygems/gemspec/oj.gemspec.expected.json') + test_file = self.get_test_loc('rubygems/gemspec/oj.gemspec') + expected_loc = self.get_test_loc('rubygems/gemspec/oj.gemspec.expected.json') + packages = rubygems.RubyGem.recognize(test_file) + self.check_packages(packages, expected_loc, regen=False) def test_rubygems_rubocop_gemspec(self): - self.check_gemspec( - 'rubygems/gemspec/rubocop.gemspec', - 'rubygems/gemspec/rubocop.gemspec.expected.json') - - def test_rubygems_gemspec_with_variables(self): - self.check_gemspec( - 'rubygems/gemspec/with_variables.gemspec', - 'rubygems/gemspec/with_variables.gemspec.expected.json') + test_file = self.get_test_loc('rubygems/gemspec/rubocop.gemspec') + expected_loc = self.get_test_loc('rubygems/gemspec/rubocop.gemspec.expected.json') + packages = rubygems.RubyGem.recognize(test_file) + self.check_packages(packages, expected_loc, regen=False) + + def test_rubygems_with_variables_gemspec(self): + test_file = self.get_test_loc('rubygems/gemspec/with_variables.gemspec') + expected_loc = self.get_test_loc('rubygems/gemspec/with_variables.gemspec.expected.json') + packages = rubygems.RubyGem.recognize(test_file) + self.check_packages(packages, expected_loc, regen=False) class TestRubyGemMetadata(FileBasedTesting): diff --git a/thirdparty/gemfileparser-0.8.0-py2.py3-none-any.whl b/thirdparty/gemfileparser-0.8.0-py2.py3-none-any.whl new file mode 100644 index 00000000000..207a08eeed9 Binary files /dev/null and b/thirdparty/gemfileparser-0.8.0-py2.py3-none-any.whl differ diff --git a/thirdparty/gemfileparser-0.8.0.tar.gz b/thirdparty/gemfileparser-0.8.0.tar.gz new file mode 100644 index 00000000000..28bb3fb21fd Binary files /dev/null and b/thirdparty/gemfileparser-0.8.0.tar.gz differ diff --git a/thirdparty/gemfileparser.ABOUT b/thirdparty/gemfileparser.ABOUT new file mode 100644 index 00000000000..bb9a4233831 --- /dev/null +++ b/thirdparty/gemfileparser.ABOUT @@ -0,0 +1,8 @@ +about_resource: gemfileparser-0.8.0-py2.py3-none-any.whl +name: gemfileparser +version: 0.8.0 +download_url: https://files.pythonhosted.org/packages/ed/b5/c3f4d21e121a65172f43b08b2699e469e3853455b5def48097f40164bb44/gemfileparser-0.8.0-py2.py3-none-any.whl +license_expression: mit +license_file: gemfileparser.LICENSE +owner: Balasankar "Balu" C +home_url: https://github.com/gemfileparser/gemfileparser diff --git a/thirdparty/gemfileparser.LICENSE b/thirdparty/gemfileparser.LICENSE new file mode 100644 index 00000000000..1b710007455 --- /dev/null +++ b/thirdparty/gemfileparser.LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2020 Gemfileparser authors (listed in AUTHORS file) + 2015-2018 Balasankar C + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.