Skip to content

Commit

Permalink
Added .editorconfig. Resolves issue #8
Browse files Browse the repository at this point in the history
Updated all source files to comply with the new config.
  • Loading branch information
young-steveo committed Oct 1, 2014
1 parent f6c0c2b commit 9f57071
Show file tree
Hide file tree
Showing 31 changed files with 295 additions and 276 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# editorconfig.org
root = true

[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
bower_components
node_modules
.DS_Store
.DS_Store
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ before_script:
- npm install grunt-cli -g
- npm install
script:
- grunt test;
- grunt test;
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ 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.
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 changes: 19 additions & 9 deletions dist/bottle.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @return Array
*/
var get = function get(collection, id, name) {
var group = collection[id];
var group = collection[id];
if (!group) {
group = collection[id] = {};
}
Expand All @@ -49,12 +49,13 @@
* @param Function func
*/
var set = function set(collection, id, name, func) {
if (typeof name === 'function') {
if (typeof name === 'function') {
func = name;
name = '__global__';
}
get(collection, id, name).push(func);
};

/**
* Register a constant
*
Expand All @@ -72,6 +73,7 @@

return this;
};

/**
* Map of decorator by index => name
*
Expand All @@ -88,8 +90,9 @@
*/
var decorator = function decorator(name, func) {
set(decorators, this.id, name, func);
return this;
return this;
};

/**
* Register a factory inside a generic provider.
*
Expand All @@ -102,6 +105,7 @@
this.$get = Factory;
});
};

/**
* Map of middleware by index => name
*
Expand Down Expand Up @@ -156,6 +160,7 @@
set(middles, this.id, name, func);
return this;
};

/**
* Map of provider constructors by index => name
*
Expand Down Expand Up @@ -239,6 +244,7 @@
Object.defineProperties(container, properties);
return this;
};

/**
* Map used to inject dependencies in the generic factory;
*
Expand Down Expand Up @@ -266,6 +272,7 @@
return new Service();
});
};

/**
* Register a value
*
Expand All @@ -284,15 +291,16 @@
return this;
};


/**
* Bottle constructor
*/
var Bottle = function Bottle() {
if (!(this instanceof Bottle)) {
return new Bottle();
}
this.id = id++;
this.container = {};
if (!(this instanceof Bottle)) {
return new Bottle();
}
this.id = id++;
this.container = {};
};

/**
Expand All @@ -312,8 +320,9 @@
* Bottle static
*/
Bottle.pop = function pop() {
return new Bottle();
return new Bottle();
};

/**
* Exports script adapted from lodash v2.4.1 Modern Build
*
Expand Down Expand Up @@ -379,4 +388,5 @@
root.Bottle = Bottle;
}
}((objectTypes[typeof window] && window) || this));

}.call(this));
2 changes: 1 addition & 1 deletion dist/bottle.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion grunt/config/grunt-contrib-clean.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"clean" : {
"dist" : ["dist/"]
}
}
}
2 changes: 1 addition & 1 deletion grunt/config/grunt-contrib-concat.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"concat" : {
"dist" : {
"options" : {
Expand Down
2 changes: 1 addition & 1 deletion grunt/config/grunt-contrib-jasmine.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion grunt/config/grunt-contrib-jshint.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
},
"source" : ["./gruntfile.js", "test/**/*.js", "dist/bottle.js"]
}
}
}
2 changes: 1 addition & 1 deletion grunt/config/grunt-contrib-uglify.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"files" : { "dist/bottle.min.js" : ["dist/bottle.js"] }
}
}
}
}
2 changes: 1 addition & 1 deletion grunt/config/grunt-wrap.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ module.exports = function(grunt) {

grunt.registerTask('default', ['clean', 'concat', 'wrap', 'jshint', 'uglify']);
grunt.registerTask('test', ['default', 'jasmine']);
};
};
2 changes: 1 addition & 1 deletion src/Bottle/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ var constant = function constant(name, value) {
});

return this;
};
};
4 changes: 2 additions & 2 deletions src/Bottle/decorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ var decorators = [];
*/
var decorator = function decorator(name, func) {
set(decorators, this.id, name, func);
return this;
};
return this;
};
2 changes: 1 addition & 1 deletion src/Bottle/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ var factory = function factory(name, Factory) {
return provider.call(this, name, function GenericProvider() {
this.$get = Factory;
});
};
};
2 changes: 1 addition & 1 deletion src/Bottle/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ var applyMiddleware = function(id, name, instance, container) {
var middleware = function middleware(name, func) {
set(middles, this.id, name, func);
return this;
};
};
2 changes: 1 addition & 1 deletion src/Bottle/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ var provider = function provider(name, Provider) {

Object.defineProperties(container, properties);
return this;
};
};
2 changes: 1 addition & 1 deletion src/Bottle/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ var service = function service(name, Service) {
}
return new Service();
});
};
};
2 changes: 1 addition & 1 deletion src/Bottle/value.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ var value = function value(name, val) {
});

return this;
};
};
14 changes: 7 additions & 7 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* Bottle constructor
*/
var Bottle = function Bottle() {
if (!(this instanceof Bottle)) {
return new Bottle();
}
this.id = id++;
this.container = {};
if (!(this instanceof Bottle)) {
return new Bottle();
}
this.id = id++;
this.container = {};
};

/**
Expand All @@ -27,5 +27,5 @@ Bottle.prototype = {
* Bottle static
*/
Bottle.pop = function pop() {
return new Bottle();
};
return new Bottle();
};
2 changes: 1 addition & 1 deletion src/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ var objectTypes = {
} else {
root.Bottle = Bottle;
}
}((objectTypes[typeof window] && window) || this));
}((objectTypes[typeof window] && window) || this));
6 changes: 3 additions & 3 deletions src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var slice = Array.prototype.slice;
* @return Array
*/
var get = function get(collection, id, name) {
var group = collection[id];
var group = collection[id];
if (!group) {
group = collection[id] = {};
}
Expand All @@ -40,9 +40,9 @@ var get = function get(collection, id, name) {
* @param Function func
*/
var set = function set(collection, id, name, func) {
if (typeof name === 'function') {
if (typeof name === 'function') {
func = name;
name = '__global__';
}
get(collection, id, name).push(func);
};
};
86 changes: 43 additions & 43 deletions test/spec/api.spec.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
/* globals Bottle */
;(function() {
"use strict";
"use strict";

/**
* Bottle API test suite
*/
describe("Bottle API", function() {
describe("Constructor", function() {
it("should allow the use of 'new'", function() {
expect(new Bottle() instanceof Bottle).toBe(true);
});
/**
* Bottle API test suite
*/
describe("Bottle API", function() {
describe("Constructor", function() {
it("should allow the use of 'new'", function() {
expect(new Bottle() instanceof Bottle).toBe(true);
});

it("creates a new instance if called like a function", function() {
/* jshint newcap: false */
expect(Bottle() instanceof Bottle).toBe(true);
/* jshint newcap: true */
});
it("creates a new instance if called like a function", function() {
/* jshint newcap: false */
expect(Bottle() instanceof Bottle).toBe(true);
/* jshint newcap: true */
});

it("creates a new instance via Bottle.pop", function() {
expect(Bottle.pop() instanceof Bottle).toBe(true);
});
});
describe("prototype", function() {
it("exposes constant", function() {
expect(Bottle.pop().constant).toBeDefined();
});
it("exposes factory", function() {
expect(Bottle.pop().factory).toBeDefined();
});
it("exposes decorator", function() {
expect(Bottle.pop().decorator).toBeDefined();
});
it("exposes provider", function() {
expect(Bottle.pop().provider).toBeDefined();
});
it("exposes service", function() {
expect(Bottle.pop().service).toBeDefined();
});
it("exposes value", function() {
expect(Bottle.pop().value).toBeDefined();
});
it("exposes container on the instance", function() {
expect(Bottle.pop().container).toBeDefined();
});
});
});
}());
it("creates a new instance via Bottle.pop", function() {
expect(Bottle.pop() instanceof Bottle).toBe(true);
});
});
describe("prototype", function() {
it("exposes constant", function() {
expect(Bottle.pop().constant).toBeDefined();
});
it("exposes factory", function() {
expect(Bottle.pop().factory).toBeDefined();
});
it("exposes decorator", function() {
expect(Bottle.pop().decorator).toBeDefined();
});
it("exposes provider", function() {
expect(Bottle.pop().provider).toBeDefined();
});
it("exposes service", function() {
expect(Bottle.pop().service).toBeDefined();
});
it("exposes value", function() {
expect(Bottle.pop().value).toBeDefined();
});
it("exposes container on the instance", function() {
expect(Bottle.pop().container).toBeDefined();
});
});
});
}());
Loading

0 comments on commit 9f57071

Please sign in to comment.