incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [14/14] git commit: removing dot file stuff.. unnecessary abstraction.
Date Fri, 21 Sep 2012 21:44:36 GMT
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 <maj.fil@gmail.com>
Authored: Thu Sep 20 14:51:40 2012 -0700
Committer: Fil Maj <maj.fil@gmail.com>
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;


Mime
View raw message