You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by dp...@apache.org on 2018/11/01 14:58:32 UTC
[cordova-common] branch master updated: add method getPodSpecs and
add related tests
This is an automated email from the ASF dual-hosted git repository.
dpogue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-common.git
The following commit(s) were added to refs/heads/master by this push:
new be6c0ea add method getPodSpecs and add related tests
be6c0ea is described below
commit be6c0ea069556d2aba1f52273f5009278aad6821
Author: knaito <kn...@asial.co.jp>
AuthorDate: Wed Aug 29 15:51:25 2018 +0900
add method getPodSpecs and add related tests
---
spec/PluginInfo/PluginInfo.spec.js | 14 ++++++
.../org.test.plugins.withcocoapods/plugin.xml | 49 ++++++++++++++++++++
src/PluginInfo/PluginInfo.js | 54 ++++++++++++++++++++++
3 files changed, 117 insertions(+)
diff --git a/spec/PluginInfo/PluginInfo.spec.js b/spec/PluginInfo/PluginInfo.spec.js
index 5fdaf87..ba20526 100644
--- a/spec/PluginInfo/PluginInfo.spec.js
+++ b/spec/PluginInfo/PluginInfo.spec.js
@@ -70,4 +70,18 @@ describe('PluginInfo', function () {
var result = p.getFrameworks('android', {});
expect(result[2].src).toBe('com.google.firebase:firebase-messaging:11.0.1');
});
+
+ it('Test 005: read podspec', function () {
+ var p = new PluginInfo(path.join(pluginsDir, 'org.test.plugins.withcocoapods'));
+ var result = p.getPodSpecs('ios');
+ expect(result.length).toBe(1);
+ var podSpec = result[0];
+ expect(Object.keys(podSpec.declarations).length).toBe(2);
+ expect(Object.keys(podSpec.sources).length).toBe(1);
+ expect(Object.keys(podSpec.libraries).length).toBe(4);
+ expect(podSpec.declarations['use-frameworks']).toBe('true');
+ expect(podSpec.sources['https://github.com/CocoaPods/Specs.git'].source).toBe('https://github.com/CocoaPods/Specs.git');
+ expect(podSpec.libraries['AFNetworking'].spec).toBe('~> 3.2');
+ expect(podSpec.libraries['Eureka']['swift-version']).toBe('4.1');
+ });
});
diff --git a/spec/fixtures/plugins/org.test.plugins.withcocoapods/plugin.xml b/spec/fixtures/plugins/org.test.plugins.withcocoapods/plugin.xml
new file mode 100644
index 0000000..2f6b623
--- /dev/null
+++ b/spec/fixtures/plugins/org.test.plugins.withcocoapods/plugin.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.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.
+-->
+
+<plugin xmlns="http://cordova.apache.org/ns/plugins/1.0"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ id="org.test.plugins.withcocoapods"
+ version="0.6.0">
+
+ <!-- new requirement: NO SPACES -->
+ <name>withcocoapods</name>
+ <!-- These are going to be required by plugman-registry -->
+ <description>my description</description>
+ <author>Ken Naito</author>
+ <keywords>dummy,plugin,cocoapods</keywords>
+ <license>BSD</license>
+ <!-- end plugman-registry requirements -->
+
+ <!-- ios -->
+ <platform name="ios">
+ <podspec>
+ <config>
+ <source url="https://github.com/CocoaPods/Specs.git"/>
+ </config>
+ <pods use-frameworks="true" inhibit-all-warnings="true">
+ <pod name="AFNetworking" spec="~> 3.2" />
+ <pod name="SDWebImage" />
+ <pod name="Eureka" swift-version="4.1" />
+ <pod name="AcknowList" />
+ </pods>
+ </podspec>
+ </platform>
+</plugin>
diff --git a/src/PluginInfo/PluginInfo.js b/src/PluginInfo/PluginInfo.js
index 8355f10..0550cb1 100644
--- a/src/PluginInfo/PluginInfo.js
+++ b/src/PluginInfo/PluginInfo.js
@@ -246,6 +246,60 @@ function PluginInfo (dirname) {
return libFiles;
}
+ // <podspec>
+ // Example:
+ // <podspec>
+ // <config>
+ // <source url="https://github.com/brightcove/BrightcoveSpecs.git" />
+ // <source url="https://github.com/CocoaPods/Specs.git"/>
+ // </config>
+ // <pods>
+ // <pod name="PromiseKit" />
+ // <pod name="Foobar1" spec="~> 2.0.0" />
+ // <pod name="Foobar2" git="git@github.com:hoge/foobar1.git" />
+ // <pod name="Foobar3" git="git@github.com:hoge/foobar2.git" branch="next" />
+ // <pod name="Foobar4" swift-version="4.1" />
+ // <pod name="Foobar5" swift-version="3.0" />
+ // </pods>
+ // </podspec>
+ self.getPodSpecs = getPodSpecs;
+ function getPodSpecs (platform) {
+ var podSpecs = _getTagsInPlatform(self._et, 'podspec', platform, function (tag) {
+ var declarations = null;
+ var sources = null;
+ var libraries = null;
+ var config = tag.find('config');
+ var pods = tag.find('pods');
+ if (config != null) {
+ sources = config.findall('source').map(function (t) {
+ return {
+ url: t.attrib.url
+ };
+ }).reduce(function (acc, val) {
+ return Object.assign({}, acc, {[val.url]: { source: val.url }});
+ }, {});
+ }
+ if (pods != null) {
+ declarations = Object.keys(pods.attrib).reduce(function (acc, key) {
+ return pods.attrib[key] === undefined ? acc : Object.assign({}, acc, {[key]: pods.attrib[key]});
+ }, {});
+ libraries = pods.findall('pod').map(function (t) {
+ return Object.keys(t.attrib).reduce(function (acc, key) {
+ return t.attrib[key] === undefined ? acc : Object.assign({}, acc, {[key]: t.attrib[key]});
+ }, {});
+ }).reduce(function (acc, val) {
+ return Object.assign({}, acc, {[val.name]: val});
+ }, {});
+ }
+ return {
+ declarations: declarations,
+ sources: sources,
+ libraries: libraries
+ };
+ });
+ return podSpecs;
+ }
+
// <hook>
// Example:
// <hook type="before_build" src="scripts/beforeBuild.js" />
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org