Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.

Commit 5017a85

Browse files
sergiopvilarKahlil Lechelt
authored andcommitted
Fixes some itens on #15
1 parent 9cea8c3 commit 5017a85

File tree

9 files changed

+71
-126
lines changed

9 files changed

+71
-126
lines changed

app/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ InitGenerator.prototype.askFor = function askFor() {
7979
}.bind(this));
8080
};
8181

82+
InitGenerator.prototype.date = function date() {
83+
var d = new Date();
84+
this.date = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
85+
};
86+
8287
InitGenerator.prototype.projectfiles = function projectfiles() {
8388
this.copy('editorconfig', '.editorconfig');
8489
this.copy('jshintrc', '.jshintrc');

app/templates/_AUTHORS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<%= name %> <% if (email) { %><<%= email %>><% } %> <% if (email) { %>(<%= url %>)<% } %>
1+
<%= name %> <% if (email) { %><<%= email %>><% } %> <% if (email) { %>(<%= url %>)<% } %>

app/templates/js/modules/module.js

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,18 @@
11
/**
2-
* An example module
2+
* Module module
33
*
4-
* @author Author name
5-
* @date 2013-08-18
4+
* @author <%= name %>
5+
* @date <%= date %>
66
*/
77

8-
define([
9-
// Dependencies of the module
10-
'jquery'
11-
], function ($) {
8+
define([], function () {
129

1310
// Strict mode to prevent sloppy JS
1411
'use strict';
1512

16-
// Private variables
17-
var _eventName = '_test';
18-
1913
// Public API
2014
return {
21-
22-
// Getter for private variable
23-
getEventName: function () {
24-
return _eventName;
25-
},
26-
27-
// File an event on initialisation
28-
init: function () {
29-
$(document).trigger(_eventName);
30-
}
15+
3116
};
3217

3318
});
Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,16 @@
11
/**
2-
* An example specification for the example module
3-
* Loads the module and runs the test suite
2+
* Module module
3+
*
4+
* @author <%= name %>
5+
* @date <%= date %>
46
*/
5-
define(['modules/module'], function (module) {
6-
'use strict';
7-
8-
// Test suite INIT
9-
describe('INIT', function () {
10-
11-
it('is available', function () {
12-
expect(module).not.toBe(null);
13-
});
147

15-
it('has getter for event name', function () {
16-
expect(module.getEventName()).toBe('_test');
17-
});
18-
19-
it('fires event on init', function () {
20-
var eventCalled;
8+
define(['modules/module'], function (module) {
9+
'use strict';
2110

22-
$(document).on(module.getEventName(), function () {
23-
eventCalled = true;
24-
});
11+
// Test suite module
12+
describe('module', function () {
2513

26-
module.init();
14+
});
2715

28-
expect(eventCalled).toBeTruthy();
29-
});
30-
});
3116
});

module/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ var ModuleGenerator = module.exports = function ModuleGenerator() {
88

99
util.inherits(ModuleGenerator, yeoman.generators.NamedBase);
1010

11+
ModuleGenerator.prototype.getAuthor = function getAuthor(){
12+
this.author = this.readFileAsString('AUTHORS');
13+
};
14+
15+
ModuleGenerator.prototype.date = function date(){
16+
var d = new Date();
17+
this.date = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
18+
}
19+
1120
ModuleGenerator.prototype.module = function module() {
1221
this.copy('module.js', 'js/modules/' + this.name + '.js');
1322
};

module/templates/example.spec.js

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,16 @@
11
/**
2-
* An example specification for the example module
3-
* Loads the module and runs the test suite
2+
* Module <%= name %>
3+
*
4+
* @author <%= author %>
5+
* @date <%= date %>
46
*/
5-
define(['modules/<%= name %>'], function (<%= name %>) {
6-
'use strict';
7-
8-
// Test suite INIT
9-
describe('INIT', function () {
10-
11-
it('is available', function () {
12-
expect(module).not.toBe(null);
13-
});
14-
15-
it('has getter for event name', function () {
16-
expect(module.getEventName()).toBe('_test');
17-
});
187

19-
it('fires event on init', function () {
20-
var eventCalled;
21-
22-
$(document).on(module.getEventName(), function () {
23-
eventCalled = true;
24-
});
8+
define(['modules/<%= name %>'], function (module) {
9+
'use strict';
2510

26-
module.init();
11+
// Test suite <%= name %>
12+
describe('<%= name %>', function () {
2713

28-
expect(eventCalled).toBeTruthy();
29-
});
3014
});
15+
3116
});

module/templates/example.spec.js.orig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Module <%= name %>
3+
*
4+
* @author <%= author %>
5+
* @date <%= date %>
6+
*/
7+
<<<<<<< HEAD
8+
define(['modules/<%= name %>'], function (<%= name %>) {
9+
=======
10+
11+
define(['modules/<%= name %>'], function (module) {
12+
>>>>>>> Fixes some itens on #15
13+
'use strict';
14+
15+
// Test suite <%= name %>
16+
describe('<%= name %>', function () {
17+
18+
});
19+
20+
});

module/templates/module.js

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,18 @@
11
/**
2-
* An example module
2+
* Module <%= name %>
33
*
4-
* @author Author name
5-
* @date 2013-08-18
4+
* @author <%= author %>
5+
* @date <%= date %>
66
*/
77

8-
define([
9-
// Dependencies of the module
10-
'jquery'
11-
], function ($) {
8+
define([], function () {
129

1310
// Strict mode to prevent sloppy JS
1411
'use strict';
1512

16-
// Private variables
17-
var _eventName = '_test';
18-
1913
// Public API
2014
return {
21-
22-
// Getter for private variable
23-
getEventName: function () {
24-
return _eventName;
25-
},
26-
27-
// File an event on initialisation
28-
init: function () {
29-
$(document).trigger(_eventName);
30-
}
15+
3116
};
3217

3318
});

test/test.js

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ describe('main generator', function () {
141141
it('creates expected files for LESS preprocessor', function (done) {
142142

143143
helpers.mockPrompt(this.app, {
144-
'cssPreprocessor': 'LESS'
144+
'cssPreprocessor': 'LESS',
145+
'name': 'John Doe'
145146
});
146147

147148
var expectedLESS = [
@@ -172,21 +173,11 @@ describe('main generator', function () {
172173
// ---- Page sub-generator
173174

174175
describe('page sub-generator', function () {
175-
beforeEach(function (done) {
176-
helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
177-
if (err) {
178-
return done(err);
179-
}
180-
181-
this.app = helpers.createGenerator('init:page', [
182-
'../../page'
183-
], ['test-page']);
184-
done();
185-
}.bind(this));
186-
});
187176

188177
it('creates expected files for the page sub-generator', function (done) {
189178

179+
this.app = helpers.createGenerator('init:page', ['../../page'], ['test-page']);
180+
190181
var expected = [
191182
'templates/test-page.html'
192183
];
@@ -204,21 +195,11 @@ describe('page sub-generator', function () {
204195
// ---- Module sub-generator
205196

206197
describe('module sub-generator', function () {
207-
beforeEach(function (done) {
208-
helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
209-
if (err) {
210-
return done(err);
211-
}
212-
213-
this.app = helpers.createGenerator('init:module', [
214-
'../../module'
215-
], ['test']);
216-
done();
217-
}.bind(this));
218-
});
219198

220199
it('creates expected files for the module sub-generator', function (done) {
221200

201+
this.app = helpers.createGenerator('init:module', ['../../module'], ['test']);
202+
222203
var expected = [
223204
'js/modules/test.js',
224205
'test/specs/test.spec.js'
@@ -237,21 +218,11 @@ describe('module sub-generator', function () {
237218
// ---- Jqueryplugin sub-generator
238219

239220
describe('jqueryplugin sub-generator', function () {
240-
beforeEach(function (done) {
241-
helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
242-
if (err) {
243-
return done(err);
244-
}
245-
246-
this.app = helpers.createGenerator('init:jqueryplugin', [
247-
'../../jqueryplugin'
248-
], ['test']);
249-
done();
250-
}.bind(this));
251-
});
252221

253222
it('creates expected files for the jqueryplugin sub-generator', function (done) {
254223

224+
this.app = helpers.createGenerator('init:jqueryplugin', ['../../jqueryplugin'], ['test']);
225+
255226
var expected = [
256227
'js/plugins/jquery.test.js'
257228
];

0 commit comments

Comments
 (0)