Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0EB1FD4FF for ; Fri, 21 Sep 2012 21:44:38 +0000 (UTC) Received: (qmail 25241 invoked by uid 500); 21 Sep 2012 21:44:37 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 25169 invoked by uid 500); 21 Sep 2012 21:44:37 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 24752 invoked by uid 99); 21 Sep 2012 21:44:37 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Sep 2012 21:44:37 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 011E438D82; Fri, 21 Sep 2012 21:44:37 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: filmaj@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [14/14] git commit: removing dot file stuff.. unnecessary abstraction. Message-Id: <20120921214437.011E438D82@tyr.zones.apache.org> Date: Fri, 21 Sep 2012 21:44:36 +0000 (UTC) removing dot file stuff.. unnecessary abstraction. Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/commit/2f397c68 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/tree/2f397c68 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/diff/2f397c68 Branch: refs/heads/cordova-client Commit: 2f397c683e1959355075a75008c2cb336612850c Parents: 380c45e Author: Fil Maj Authored: Thu Sep 20 14:51:40 2012 -0700 Committer: Fil Maj Committed: Thu Sep 20 14:51:40 2012 -0700 ---------------------------------------------------------------------- spec/dot_parser.spec.js | 65 ------------------------------------------ src/dot_parser.js | 43 --------------------------- 2 files changed, 0 insertions(+), 108 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/2f397c68/spec/dot_parser.spec.js ---------------------------------------------------------------------- diff --git a/spec/dot_parser.spec.js b/spec/dot_parser.spec.js deleted file mode 100644 index 8543b60..0000000 --- a/spec/dot_parser.spec.js +++ /dev/null @@ -1,65 +0,0 @@ -var cordova = require('../cordova'), - path = require('path'), - fs = require('fs'), - dot_parser = require('../src/dot_parser'), - file = path.join(__dirname, 'fixtures', 'projects', 'test', '.cordova'); - -var original_dot = fs.readFileSync(file, 'utf-8'); - -describe('dot cordova file parser', function() { - afterEach(function() { - fs.writeFileSync(file, original_dot, 'utf-8'); - }); - - it("should read a .cordova file", function() { - var dot; - expect(function() { - dot = new dot_parser(file); - }).not.toThrow(); - expect(dot).toBeDefined(); - }); - - describe('get', function() { - var dot; - beforeEach(function() { - dot = new dot_parser(file); - }); - - it("should be able to return app name", function() { - expect(dot.name()).toBe("test"); - }); - it("should be able to return app id (or package)", function() { - expect(dot.packageName()).toBe("org.apache.cordova"); - }); - it("should be able to return app platforms", function() { - var ps = dot.ls_platforms(); - expect(ps[0]).toBe('android'); - expect(ps[1]).toBe('ios'); - }); - }); - describe('set', function() { - var dot; - beforeEach(function() { - dot = new dot_parser(file); - }); - - it("should be able to write app name", function() { - dot.name('new'); - expect(JSON.parse(fs.readFileSync(file, 'utf-8')).name).toBe('new'); - }); - it("should be able to write app id (or package)", function () { - dot.packageName('ca.filmaj.app'); - expect(JSON.parse(fs.readFileSync(file, 'utf-8')).id).toBe('ca.filmaj.app'); - }); - it("should be able to add platforms", function() { - dot.add_platform('blackberry'); - expect(JSON.parse(fs.readFileSync(file, 'utf-8')).platforms.length).toBe(3); - expect(JSON.parse(fs.readFileSync(file, 'utf-8')).platforms[2]).toBe('blackberry'); - }); - it("should be able to remove platforms", function() { - dot.remove_platform('ios'); - expect(JSON.parse(fs.readFileSync(file, 'utf-8')).platforms.length).toBe(1); - expect(JSON.parse(fs.readFileSync(file, 'utf-8')).platforms[0]).toBe('android'); - }); - }); -}); http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/2f397c68/src/dot_parser.js ---------------------------------------------------------------------- diff --git a/src/dot_parser.js b/src/dot_parser.js deleted file mode 100644 index f73fa7d..0000000 --- a/src/dot_parser.js +++ /dev/null @@ -1,43 +0,0 @@ -var fs = require('fs'); - -function dot_parser(path) { - this.path = path; - this.json = JSON.parse(fs.readFileSync(path, 'utf-8')); -} - -dot_parser.prototype = { - ls_platforms:function() { - return this.json.platforms; - }, - add_platform:function(platform) { - if (this.json.platforms.indexOf(platform) > -1) return; - else { - this.json.platforms.push(platform); - this.update(); - } - }, - remove_platform:function(platform) { - if (this.json.platforms.indexOf(platform) == -1) return; - else { - this.json.platforms.splice(this.json.platforms.indexOf(platform), 1); - this.update(); - } - }, - packageName:function(id) { - if (id) { - this.json.id = id; - this.update(); - } else return this.json.id; - }, - name:function(name) { - if (name) { - this.json.name = name; - this.update(); - } else return this.json.name; - }, - update:function() { - fs.writeFileSync(this.path, JSON.stringify(this.json), 'utf-8'); - } -}; - -module.exports = dot_parser;