_checkPlatforms refactor

This commit is contained in:
Adam Bradley
2014-02-24 22:05:00 -06:00
parent 3830653a09
commit 631208f1d8
2 changed files with 22 additions and 23 deletions

View File

@@ -33,6 +33,9 @@ describe('Ionic Platform Service', function() {
ionic.Platform.setVersion('1');
expect(ionic.Platform.version()).toEqual(1.0);
ionic.Platform.setVersion('0.1');
expect(ionic.Platform.version()).toEqual(0.1);
ionic.Platform.setVersion(' ');
expect(ionic.Platform.version()).toEqual(0);

View File

@@ -44,31 +44,27 @@
this.platforms = [];
this.grade = 'a';
var v = this.version().toString();
if(v.indexOf('.') > 0) {
v = v.replace('.', '_');
} else {
v += '_0';
}
if(this.isCordova()) this.platforms.push('cordova');
if(this.isIPad()) this.platforms.push('ipad');
if(this.isCordova()) {
this.platforms.push('cordova');
}
if(this.isIOS()) {
this.platforms.push('ios');
this.platforms.push('ios' + v.split('_')[0]);
this.platforms.push('ios' + v);
}
if(this.isIPad()) {
this.platforms.push('ipad');
}
if(this.isAndroid()) {
this.platforms.push('android');
this.platforms.push('android' + v.split('_')[0]);
this.platforms.push('android' + v);
var platform = this.platform();
if(platform) {
this.platforms.push(platform);
if(platformVersion > 0 && platformVersion < 4.4) {
this.grade = (platformVersion < 4 ? 'c' : 'b');
var version = this.version();
if(version) {
var v = version.toString();
if(v.indexOf('.') > 0) {
v = v.replace('.', '_');
} else {
v += '_0';
}
this.platforms.push(platform + v.split('_')[0]);
this.platforms.push(platform + v);
if(this.isAndroid() && version < 4.4) {
this.grade = (version < 4 ? 'c' : 'b');
}
}
}
},