Skip to content

Commit

Permalink
Returns the object and not its serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlitmark committed Feb 11, 2013
1 parent 5074ac8 commit 6d92d20
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 48 deletions.
45 changes: 22 additions & 23 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// sheet from his book Save The Cat!, but adjusted for novels based on my own
// preferences, and with additions from his latest book:
// * The length of act 1 is 1/5 instead of 1/4.
// * The statis=death beat is added. (1)
// * The stasis=death beat is added. (1)
// * The beats from the five-point finale are added. (1)
//
// (1) Mentioned in the book Save The Cat! Strikes Back.
Expand Down Expand Up @@ -43,102 +43,102 @@
populate : function ( position ) {
return [
{
"beat" : "The opening image",
"title" : "The opening image",
"begin" : position[0],
"end" : "NULL"
},
{
"beat" : "Theme Stated",
"title" : "Theme Stated",
"begin" : position[1],
"end" : "NULL"
},
{
"beat" : "Set-up",
"title" : "Set-up",
"begin" : position[0],
"end" : position[2]
},
{
"beat" : "Statis=Death",
"title" : "Stasis=Death",
"begin" : position[3],
"end" : "NULL"
},
{
"beat" : "Catalyst",
"title" : "Catalyst",
"begin" : position[4],
"end" : "NULL"
},
{
"beat" : "Debate",
"title" : "Debate",
"begin" : position[4],
"end" : position[5]
},
{
"beat" : "Break into two",
"title" : "Break into two",
"begin" : position[5],
"end" : "NULL"
},
{
"beat" : "B-story",
"title" : "B-story",
"begin" : position[6],
"end" : "NULL"
},
{
"beat" : "Fun and Games",
"title" : "Fun and Games",
"begin" : position[6],
"end" : position[7]
},
{
"beat" : "Midpoint",
"title" : "Midpoint",
"begin" : position[7],
"end" : "NULL"
},
{
"beat" : "Bad Guys close in",
"title" : "Bad Guys close in",
"begin" : position[7],
"end" : position[8]
},
{
"beat" : "All Is Lost",
"title" : "All Is Lost",
"begin" : position[8],
"end" : "NULL"
},
{
"beat" : "Dark Night of the Soul",
"title" : "Dark Night of the Soul",
"begin" : position[8],
"end" : position[9]
},
{
"beat" : "Break Into Three",
"title" : "Break Into Three",
"begin" : position[9],
"end" : "NULL"
},
{
"beat" : "Gathering the team",
"title" : "Gathering the team",
"begin" : position[10],
"end" : "NULL"
},
{
"beat" : "Executing the Plan",
"title" : "Executing the Plan",
"begin" : position[11],
"end" : "NULL"
},
{
"beat" : "The Height Tower Surprise",
"title" : "The Height Tower Surprise",
"begin" : position[12],
"end" : "NULL"
},
{
"beat" : "Dig, Deep Down",
"title" : "Dig, Deep Down",
"begin" : position[13],
"end" : "NULL"
},
{
"beat" : "The Execution of the New Plan",
"title" : "The Execution of the New Plan",
"begin" : position[14],
"end" : "NULL"
},
{
"beat" : "Final Image",
"title" : "Final Image",
"begin" : position[15],
"end" : "NULL"
}
Expand All @@ -149,8 +149,7 @@
// The beatsheet object returns the beat sheet as a JSON
var beatsheet = function ( size ) {
var distribution = helpers.findDistribution( size );
var result = helpers.populate( distribution );
return JSON.stringify( result );
return helpers.populate( distribution );
};

// Export the beatsheet object.
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Include beatsheet.min.js on your page, then use:
In this example, beatsheet takes one parameter: the projected number of pages (or words) in your novel (or short story). If you are writing a 100 page novel use 100, if you're writing 90000 words, use 90000.
The output is a JSON with all the beats and their page/word count:

"[{"beat":"The opening image","begin":1,"end":"NULL"},{"beat":"Theme Stated","begin":4,"end":"NULL"},{"beat":"Set-up","begin":1,"end":8},{"beat":"Statis=Death","begin":9,"end":"NULL"},{"beat":"Catalyst","begin":10,"end":"NULL"},{"beat":"Debate","begin":10,"end":20},{"beat":"Break into two","begin":20,"end":"NULL"},{"beat":"B-story","begin":24,"end":"NULL"},{"beat":"Fun and Games","begin":24,"end":50},{"beat":"Midpoint","begin":50,"end":"NULL"},{"beat":"Bad Guys close in","begin":50,"end":68},{"beat":"All Is Lost","begin":68,"end":"NULL"},{"beat":"Dark Night of the Soul","begin":68,"end":77},{"beat":"Break Into Three","begin":77,"end":"NULL"},{"beat":"Gathering the team","begin":81,"end":"NULL"},{"beat":"Executing the Plan","begin":85,"end":"NULL"},{"beat":"The Height Tower Surprise","begin":89,"end":"NULL"},{"beat":"Dig, Deep Down","begin":93,"end":"NULL"},{"beat":"The Execution of the New Plan","begin":97,"end":"NULL"},{"beat":"Final Image","begin":100,"end":"NULL"}]"
[{"title":"The opening image","begin":1,"end":"NULL"},{"title":"Theme Stated","begin":4,"end":"NULL"},{"title":"Set-up","begin":1,"end":8},{"title":"Statis=Death","begin":9,"end":"NULL"},{"title":"Catalyst","begin":10,"end":"NULL"},{"title":"Debate","begin":10,"end":20},{"title":"Break into two","begin":20,"end":"NULL"},{"title":"B-story","begin":24,"end":"NULL"},{"title":"Fun and Games","begin":24,"end":50},{"title":"Midpoint","begin":50,"end":"NULL"},{"title":"Bad Guys close in","begin":50,"end":68},{"title":"All Is Lost","begin":68,"end":"NULL"},{"title":"Dark Night of the Soul","begin":68,"end":77},{"title":"Break Into Three","begin":77,"end":"NULL"},{"title":"Gathering the team","begin":81,"end":"NULL"},{"title":"Executing the Plan","begin":85,"end":"NULL"},{"title":"The Height Tower Surprise","begin":89,"end":"NULL"},{"title":"Dig, Deep Down","begin":93,"end":"NULL"},{"title":"The Execution of the New Plan","begin":97,"end":"NULL"},{"title":"Final Image","begin":100,"end":"NULL"}]

## Browser compatibility
Modern browsers, and IE9+.
Expand Down
46 changes: 22 additions & 24 deletions test/spec/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,115 +5,113 @@

"use strict";

var result = [
var beats = [
{
"beat" :"The opening image",
"title" :"The opening image",
"begin":1,
"end" :"NULL"
},
{
"beat" :"Theme Stated",
"title" :"Theme Stated",
"begin":4,
"end" :"NULL"
},
{
"beat" :"Set-up",
"title" :"Set-up",
"begin":1,
"end" :8
},
{
"beat" :"Statis=Death",
"title" :"Stasis=Death",
"begin":9,
"end" :"NULL"
},
{
"beat" :"Catalyst",
"title" :"Catalyst",
"begin":10,
"end" :"NULL"
},
{
"beat" :"Debate",
"title" :"Debate",
"begin":10,
"end" :20
},
{
"beat" :"Break into two",
"title" :"Break into two",
"begin":20,
"end" :"NULL"
},
{
"beat" :"B-story",
"title" :"B-story",
"begin":24,
"end" :"NULL"
},
{
"beat" :"Fun and Games",
"title" :"Fun and Games",
"begin":24,
"end" :50
},
{
"beat" :"Midpoint",
"title" :"Midpoint",
"begin":50,
"end" :"NULL"
},
{
"beat" :"Bad Guys close in",
"title" :"Bad Guys close in",
"begin":50,
"end" :68
},
{
"beat" :"All Is Lost",
"title" :"All Is Lost",
"begin":68,
"end" :"NULL"
},
{
"beat" :"Dark Night of the Soul",
"title" :"Dark Night of the Soul",
"begin":68,
"end" :77
},
{
"beat" :"Break Into Three",
"title" :"Break Into Three",
"begin":77,
"end" :"NULL"
},
{
"beat" :"Gathering the team",
"title" :"Gathering the team",
"begin":81,
"end" :"NULL"
},
{
"beat" :"Executing the Plan",
"title" :"Executing the Plan",
"begin":85,
"end" :"NULL"
},
{
"beat" :"The Height Tower Surprise",
"title" :"The Height Tower Surprise",
"begin":89,
"end" :"NULL"
},
{
"beat" :"Dig, Deep Down",
"title" :"Dig, Deep Down",
"begin":93,
"end" :"NULL"
},
{
"beat" :"The Execution of the New Plan",
"title" :"The Execution of the New Plan",
"begin":97,
"end" :"NULL"
},
{
"beat" :"Final Image",
"title" :"Final Image",
"begin":100,
"end" :"NULL"
}
];

var serializedResult = JSON.stringify(result);

describe('Beatsheet', function () {
it('returns the beatsheet based on the given input', function () {
var output = beatsheet(100);
expect(output).to.eql(serializedResult);
expect(output).to.eql(beats);
});
});

Expand Down

0 comments on commit 6d92d20

Please sign in to comment.