From f1d3972c8a5cbc4bbc9995afa73caa7f07c94de4 Mon Sep 17 00:00:00 2001 From: Damian Mee Date: Wed, 16 Jul 2014 18:24:37 +0200 Subject: [PATCH] style(templates:coffee): cleanup & consistency fix of .coffee files --- templates/controller/name.controller.coffee | 3 +- .../controller/name.controller.spec.coffee | 9 +++--- templates/decorator/name.decorator.coffee | 5 ++-- .../directiveComplex/name.directive.coffee | 3 +- .../name.directive.spec.coffee | 16 +++++----- .../directiveSimple/name.directive.coffee | 3 +- .../name.directive.spec.coffee | 13 ++++---- templates/factory/name.service.coffee | 3 +- templates/factory/name.service.spec.coffee | 6 ++-- templates/filter/name.filter.coffee | 3 +- templates/filter/name.filter.spec.coffee | 10 +++---- templates/provider/name.service.coffee | 30 +++++++++---------- templates/provider/name.service.spec.coffee | 6 ++-- templates/route/name(ngroute).coffee | 3 +- templates/route/name(uirouter).coffee | 3 +- templates/route/name.controller.coffee | 3 +- templates/route/name.controller.spec.coffee | 9 +++--- templates/service/name.service.coffee | 3 +- templates/service/name.service.spec.coffee | 6 ++-- 19 files changed, 72 insertions(+), 65 deletions(-) diff --git a/templates/controller/name.controller.coffee b/templates/controller/name.controller.coffee index e1c1a8c..3dd9a83 100644 --- a/templates/controller/name.controller.coffee +++ b/templates/controller/name.controller.coffee @@ -1,4 +1,5 @@ 'use strict' -angular.module('<%= scriptAppName %>').controller '<%= classedName %>Ctrl', ($scope) -> +angular.module '<%= scriptAppName %>' +.controller '<%= classedName %>Ctrl', ($scope) -> $scope.message = 'Hello' \ No newline at end of file diff --git a/templates/controller/name.controller.spec.coffee b/templates/controller/name.controller.spec.coffee index 72897c1..7312d0d 100644 --- a/templates/controller/name.controller.spec.coffee +++ b/templates/controller/name.controller.spec.coffee @@ -3,16 +3,15 @@ describe 'Controller: <%= classedName %>Ctrl', -> # load the controller's module - beforeEach module('<%= scriptAppName %>') + beforeEach module '<%= scriptAppName %>' <%= classedName %>Ctrl = undefined scope = undefined # Initialize the controller and a mock scope - beforeEach inject(($controller, $rootScope) -> + beforeEach inject ($controller, $rootScope) -> scope = $rootScope.$new() - <%= classedName %>Ctrl = $controller('<%= classedName %>Ctrl', + <%= classedName %>Ctrl = $controller '<%= classedName %>Ctrl', $scope: scope - ) - ) + it 'should ...', -> expect(1).toEqual 1 diff --git a/templates/decorator/name.decorator.coffee b/templates/decorator/name.decorator.coffee index f7d025d..5a20b37 100644 --- a/templates/decorator/name.decorator.coffee +++ b/templates/decorator/name.decorator.coffee @@ -1,6 +1,7 @@ 'use strict' -angular.module("<%= scriptAppName %>").config ($provide) -> - $provide.decorator "<%= cameledName %>", ($delegate) -> +angular.module '<%= scriptAppName %>' +.config ($provide) -> + $provide.decorator '<%= cameledName %>', ($delegate) -> # decorate the $delegate $delegate \ No newline at end of file diff --git a/templates/directiveComplex/name.directive.coffee b/templates/directiveComplex/name.directive.coffee index 60ac239..09539a6 100644 --- a/templates/directiveComplex/name.directive.coffee +++ b/templates/directiveComplex/name.directive.coffee @@ -1,6 +1,7 @@ 'use strict' -angular.module('<%= scriptAppName %>').directive '<%= cameledName %>', -> +angular.module '<%= scriptAppName %>' +.directive '<%= cameledName %>', -> templateUrl: '<%= htmlUrl %>' restrict: 'EA' link: (scope, element, attrs) -> diff --git a/templates/directiveComplex/name.directive.spec.coffee b/templates/directiveComplex/name.directive.spec.coffee index c75a711..a119934 100644 --- a/templates/directiveComplex/name.directive.spec.coffee +++ b/templates/directiveComplex/name.directive.spec.coffee @@ -3,16 +3,16 @@ describe 'Directive: <%= cameledName %>', -> # load the directive's module and view - beforeEach module('<%= scriptAppName %>') - beforeEach module('<%= htmlUrl %>') + beforeEach module '<%= scriptAppName %>' + beforeEach module '<%= htmlUrl %>' element = undefined scope = undefined - beforeEach inject(($rootScope) -> + beforeEach inject ($rootScope) -> scope = $rootScope.$new() - ) - it 'should make hidden element visible', inject(($compile) -> - element = angular.element('<<%= _.dasherize(name) %>>>') - element = $compile(element)(scope) + + it 'should make hidden element visible', inject ($compile) -> + element = angular.element '<<%= _.dasherize(name) %>>>' + element = $compile(element) scope scope.$apply() expect(element.text()).toBe 'this is the <%= cameledName %> directive' - ) + diff --git a/templates/directiveSimple/name.directive.coffee b/templates/directiveSimple/name.directive.coffee index 77f78d1..38d7b90 100644 --- a/templates/directiveSimple/name.directive.coffee +++ b/templates/directiveSimple/name.directive.coffee @@ -1,6 +1,7 @@ 'use strict' -angular.module('<%= scriptAppName %>').directive '<%= cameledName %>', -> +angular.module '<%= scriptAppName %>' +.directive '<%= cameledName %>', -> template: '
' restrict: 'EA' link: (scope, element, attrs) -> diff --git a/templates/directiveSimple/name.directive.spec.coffee b/templates/directiveSimple/name.directive.spec.coffee index 806e9b1..927a9fc 100644 --- a/templates/directiveSimple/name.directive.spec.coffee +++ b/templates/directiveSimple/name.directive.spec.coffee @@ -3,14 +3,13 @@ describe 'Directive: <%= cameledName %>', -> # load the directive's module - beforeEach module('<%= scriptAppName %>') + beforeEach module '<%= scriptAppName %>' element = undefined scope = undefined - beforeEach inject(($rootScope) -> + beforeEach inject ($rootScope) -> scope = $rootScope.$new() - ) - it 'should make hidden element visible', inject(($compile) -> - element = angular.element('<<%= _.dasherize(name) %>>>') - element = $compile(element)(scope) + + it 'should make hidden element visible', inject ($compile) -> + element = angular.element '<<%= _.dasherize(name) %>>>' + element = $compile(element) scope expect(element.text()).toBe 'this is the <%= cameledName %> directive' - ) \ No newline at end of file diff --git a/templates/factory/name.service.coffee b/templates/factory/name.service.coffee index e1ab367..06fcb32 100644 --- a/templates/factory/name.service.coffee +++ b/templates/factory/name.service.coffee @@ -1,6 +1,7 @@ 'use strict' -angular.module('<%= scriptAppName %>').factory '<%= cameledName %>', -> +angular.module '<%= scriptAppName %>' +.factory '<%= cameledName %>', -> # Service logic # ... diff --git a/templates/factory/name.service.spec.coffee b/templates/factory/name.service.spec.coffee index 54f6ebc..83f9bce 100644 --- a/templates/factory/name.service.spec.coffee +++ b/templates/factory/name.service.spec.coffee @@ -3,12 +3,12 @@ describe 'Service: <%= cameledName %>', -> # load the service's module - beforeEach module('<%= scriptAppName %>') + beforeEach module '<%= scriptAppName %>' # instantiate service <%= cameledName %> = undefined - beforeEach inject((_<%= cameledName %>_) -> + beforeEach inject (_<%= cameledName %>_) -> <%= cameledName %> = _<%= cameledName %>_ - ) + it 'should do something', -> expect(!!<%= cameledName %>).toBe true \ No newline at end of file diff --git a/templates/filter/name.filter.coffee b/templates/filter/name.filter.coffee index 12c9f86..fae17e5 100644 --- a/templates/filter/name.filter.coffee +++ b/templates/filter/name.filter.coffee @@ -1,5 +1,6 @@ 'use strict' -angular.module('<%= scriptAppName %>').filter '<%= cameledName %>', -> +angular.module '<%= scriptAppName %>' +.filter '<%= cameledName %>', -> (input) -> '<%= cameledName %> filter: ' + input diff --git a/templates/filter/name.filter.spec.coffee b/templates/filter/name.filter.spec.coffee index 56c5b69..d25b21e 100644 --- a/templates/filter/name.filter.spec.coffee +++ b/templates/filter/name.filter.spec.coffee @@ -3,13 +3,13 @@ describe 'Filter: <%= cameledName %>', -> # load the filter's module - beforeEach module('<%= scriptAppName %>') + beforeEach module '<%= scriptAppName %>' # initialize a new instance of the filter before each test <%= cameledName %> = undefined - beforeEach inject(($filter) -> - <%= cameledName %> = $filter('<%= cameledName %>') - ) + beforeEach inject ($filter) -> + <%= cameledName %> = $filter '<%= cameledName %>' + it 'should return the input prefixed with \'<%= cameledName %> filter:\'', -> text = 'angularjs' - expect(<%= cameledName %>(text)).toBe '<%= cameledName %> filter: ' + text + expect(<%= cameledName %> text).toBe '<%= cameledName %> filter: ' + text diff --git a/templates/provider/name.service.coffee b/templates/provider/name.service.coffee index ed1354f..099730c 100644 --- a/templates/provider/name.service.coffee +++ b/templates/provider/name.service.coffee @@ -1,22 +1,22 @@ 'use strict' -angular.module('<%= scriptAppName %>') - .provider '<%= cameledName %>', -> +angular.module '<%= scriptAppName %>' +.provider '<%= cameledName %>', -> - # Private variables - salutation = 'Hello' + # Private variables + salutation = 'Hello' - # Private constructor - class Greeter - @greet = -> - salutation + # Private constructor + class Greeter + @greet = -> + salutation - # Public API for configuration - @setSalutation = (s) -> - salutation = s + # Public API for configuration + @setSalutation = (s) -> + salutation = s - # Method for instantiating - @$get = -> - new Greeter() + # Method for instantiating + @$get = -> + new Greeter() - return \ No newline at end of file + return \ No newline at end of file diff --git a/templates/provider/name.service.spec.coffee b/templates/provider/name.service.spec.coffee index 0e7acad..d54972f 100644 --- a/templates/provider/name.service.spec.coffee +++ b/templates/provider/name.service.spec.coffee @@ -3,12 +3,12 @@ describe 'Service: <%= cameledName %>', -> # load the service's module - beforeEach module('<%= scriptAppName %>') + beforeEach module '<%= scriptAppName %>' # instantiate service <%= cameledName %> = undefined - beforeEach inject((_<%= cameledName %>_) -> + beforeEach inject (_<%= cameledName %>_) -> <%= cameledName %> = _<%= cameledName %>_ - ) + it 'should do something', -> expect(!!<%= cameledName %>).toBe true diff --git a/templates/route/name(ngroute).coffee b/templates/route/name(ngroute).coffee index 76b4e69..8da9189 100644 --- a/templates/route/name(ngroute).coffee +++ b/templates/route/name(ngroute).coffee @@ -1,6 +1,7 @@ 'use strict' -angular.module('<%= scriptAppName %>').config ($routeProvider) -> +angular.module '<%= scriptAppName %>' +.config ($routeProvider) -> $routeProvider.when '<%= route %>', templateUrl: '<%= htmlUrl %>' controller: '<%= classedName %>Ctrl' diff --git a/templates/route/name(uirouter).coffee b/templates/route/name(uirouter).coffee index d04f7e8..94e08a6 100644 --- a/templates/route/name(uirouter).coffee +++ b/templates/route/name(uirouter).coffee @@ -1,6 +1,7 @@ 'use strict' -angular.module('<%= scriptAppName %>').config ($stateProvider) -> +angular.module '<%= scriptAppName %>' +.config ($stateProvider) -> $stateProvider.state '<%= name %>', url: '<%= route %>' templateUrl: '<%= htmlUrl %>' diff --git a/templates/route/name.controller.coffee b/templates/route/name.controller.coffee index e1c1a8c..3dd9a83 100644 --- a/templates/route/name.controller.coffee +++ b/templates/route/name.controller.coffee @@ -1,4 +1,5 @@ 'use strict' -angular.module('<%= scriptAppName %>').controller '<%= classedName %>Ctrl', ($scope) -> +angular.module '<%= scriptAppName %>' +.controller '<%= classedName %>Ctrl', ($scope) -> $scope.message = 'Hello' \ No newline at end of file diff --git a/templates/route/name.controller.spec.coffee b/templates/route/name.controller.spec.coffee index 72897c1..7312d0d 100644 --- a/templates/route/name.controller.spec.coffee +++ b/templates/route/name.controller.spec.coffee @@ -3,16 +3,15 @@ describe 'Controller: <%= classedName %>Ctrl', -> # load the controller's module - beforeEach module('<%= scriptAppName %>') + beforeEach module '<%= scriptAppName %>' <%= classedName %>Ctrl = undefined scope = undefined # Initialize the controller and a mock scope - beforeEach inject(($controller, $rootScope) -> + beforeEach inject ($controller, $rootScope) -> scope = $rootScope.$new() - <%= classedName %>Ctrl = $controller('<%= classedName %>Ctrl', + <%= classedName %>Ctrl = $controller '<%= classedName %>Ctrl', $scope: scope - ) - ) + it 'should ...', -> expect(1).toEqual 1 diff --git a/templates/service/name.service.coffee b/templates/service/name.service.coffee index 27d1af6..ad97ace 100644 --- a/templates/service/name.service.coffee +++ b/templates/service/name.service.coffee @@ -1,4 +1,5 @@ 'use strict' -angular.module('<%= scriptAppName %>').service '<%= classedName %>', <%= classedName %> = -> +angular.module '<%= scriptAppName %>' +.service '<%= classedName %>', <%= classedName %> = -> # AngularJS will instantiate a singleton by calling 'new' on this function \ No newline at end of file diff --git a/templates/service/name.service.spec.coffee b/templates/service/name.service.spec.coffee index 857e6e3..62295d5 100644 --- a/templates/service/name.service.spec.coffee +++ b/templates/service/name.service.spec.coffee @@ -3,12 +3,12 @@ describe 'Service: <%= classedName %>', -> # load the service's module - beforeEach module('<%= scriptAppName %>') + beforeEach module '<%= scriptAppName %>' # instantiate service <%= classedName %> = undefined - beforeEach inject((_<%= classedName %>_) -> + beforeEach inject (_<%= classedName %>_) -> <%= classedName %> = _<%= classedName %>_ - ) + it 'should do something', -> expect(!!<%= classedName %>).toBe true