diff --git a/src/baw.configuration.tpl.js b/src/baw.configuration.tpl.js index fb520e03..a8eca4af 100644 --- a/src/baw.configuration.tpl.js +++ b/src/baw.configuration.tpl.js @@ -243,5 +243,32 @@ angular.module('bawApp.configuration', ['url']) bookmark: { lastPlaybackPositionName: "Last playback position", appCategory: "<>" + }, + predictiveCache: { + + profiles: [ + { + name: "Media cache ahead", + match: "some url", + request: ["one url", "another url"], + progression: [ + function(data, previous) { + return previous + 30.0; + }, + function(data, previous) { + var next = previous + 30.0; + if (next >= data.max) { + return; + } + else { + return next; + } + } + ], + count: 10, + method: "HEAD" + + } + ] } }); \ No newline at end of file diff --git a/src/components/services/predictiveCache.js b/src/components/services/predictiveCache.js new file mode 100644 index 00000000..7afad2ab --- /dev/null +++ b/src/components/services/predictiveCache.js @@ -0,0 +1,22 @@ +angular + .module("bawApp.services.predictiveCache", []) + .factory( + "predictiveCache", + ["$http", function ($http) { + + var defaults = { + name: null, + match: null, + request: [], + progression: [], + count: 0, + method: "HEAD" + }; + + return { + addProfile: function predictiveCache(profile) { + + } + } + }] +); \ No newline at end of file diff --git a/src/components/services/predictiveCache.spec.js b/src/components/services/predictiveCache.spec.js new file mode 100644 index 00000000..5ce544c1 --- /dev/null +++ b/src/components/services/predictiveCache.spec.js @@ -0,0 +1,40 @@ +describe("The predictiveCache service", function () { + + var predictiveCache; + + beforeEach(module("bawApp.services")); + + beforeEach(inject(["predictiveCache", function (_predictiveCache) { + predictiveCache = _predictiveCache; + }])); + + var testProfile = { + name: "Media cache ahead", + match: /google\.com\?page=(.*)&skip=(.*)/, + request: ["one url", "another url"], + progression: [ + function(data, previous) { + return previous + 30.0; + }, + function(data, previous) { + var next = previous + 30.0; + if (next >= data.max) { + return; + } + else { + return next; + } + } + ], + count: 10, + method: "HEAD" + }; + + + it("requires an object to function", function() { + expect(function() { + predictiveCache(); + }).toThrowError(Error, "A profile is required"); + + }); +}); \ No newline at end of file