API Docs for: 0.9.0
Show:

File: lib/storageAdapter/storageAdapter.js

  1. // Copyright 2014, Yahoo! Inc.
  2. // Copyrights licensed under the Mit License. See the accompanying LICENSE file for terms.
  3.  
  4. var Base = require('preceptor-core').Base;
  5. var Promise = require('promise');
  6.  
  7. /**
  8. * Abstract storage adapter
  9. *
  10. * @class StorageAdapter
  11. * @property {object} _options
  12. * @property {string} _build
  13. * @property {Promise} _promise
  14. */
  15. var StorageAdapter = Base.extend(
  16.  
  17. /**
  18. * Storage adapter constructor
  19. *
  20. * @constructor
  21. * @param {string} build Identifier of build
  22. * @param {object} [options]
  23. */
  24. function (build, options) {
  25. this.__super();
  26.  
  27. this._build = build;
  28. this._options = options || {};
  29. this.setPromise(Promise.resolve());
  30.  
  31. this.initialize();
  32. },
  33.  
  34. /** @lends StorageAdapter.prototype */
  35. {
  36. /**
  37. * Initializes the source-adapter
  38. *
  39. * @method initialize
  40. */
  41. initialize: function () {
  42. // Nothing by default
  43. },
  44.  
  45. /**
  46. * Gets the source-adapter promise
  47. *
  48. * @method getPromise
  49. * @return {Promise}
  50. */
  51. getPromise: function () {
  52. return this._promise;
  53. },
  54.  
  55. /**
  56. * Sets the promise
  57. *
  58. * @method setPromise
  59. * @param {Promise} promise
  60. */
  61. setPromise: function (promise) {
  62. this._promise = promise;
  63. },
  64.  
  65.  
  66. /**
  67. * Gets the build information
  68. *
  69. * @returns {string}
  70. */
  71. getBuild: function () {
  72. return this._build;
  73. },
  74.  
  75. /**
  76. * Sets the build information
  77. *
  78. * @method setBuild
  79. * @param {string} build
  80. */
  81. setBuild: function (build) {
  82. this._build = build;
  83. },
  84.  
  85. /**
  86. * Gets a list of currently approve screen names
  87. *
  88. * @method getCurrentApprovedScreenNames
  89. * @return {Promise} With {string[]} List of approved screen names
  90. */
  91. getCurrentApprovedScreenNames: function () {
  92. throw new Error('Unimplemented adapter function "getCurrentApprovedScreenNames".');
  93. },
  94.  
  95. /**
  96. * Gets a specific currently approved screen
  97. *
  98. * @method getCurrentApprovedScreen
  99. * @param {string} name Name of approved screen
  100. * @return {Promise} With {PNGImage} Approved screen
  101. */
  102. getCurrentApprovedScreen: function (name) {
  103. throw new Error('Unimplemented adapter function "getCurrentApprovedScreen".');
  104. },
  105.  
  106. /**
  107. * Archives a specific currently approved screen
  108. *
  109. * @method archiveCurrentApprovedScreen
  110. * @param {string} name Name of approved screen
  111. * @param {PNGImage} image Screen to archive
  112. * @return {Promise}
  113. */
  114. archiveCurrentApprovedScreen: function (name, image) {
  115. throw new Error('Unimplemented adapter function "archiveCurrentApprovedScreen".');
  116. },
  117.  
  118.  
  119. /**
  120. * Gets a list of approve screen names
  121. *
  122. * @method getApprovedScreenNames
  123. * @return {Promise} With {string[]} List of approved screen names
  124. */
  125. getApprovedScreenNames: function () {
  126. throw new Error('Unimplemented adapter function "getApprovedScreenNames".');
  127. },
  128.  
  129. /**
  130. * Gets a specific approved screen
  131. *
  132. * @method getApprovedScreen
  133. * @param {string} name Name of approved screen
  134. * @return {Promise} With {PNGImage} Approved screen
  135. */
  136. getApprovedScreen: function (name) {
  137. throw new Error('Unimplemented adapter function "getApprovedScreen".');
  138. },
  139.  
  140. /**
  141. * Archives a specific approved screen
  142. *
  143. * @method archiveApprovedScreen
  144. * @param {string} name Name of approved screen
  145. * @param {PNGImage} image Screen to archive
  146. * @return {Promise}
  147. */
  148. archiveApprovedScreen: function (name, image) {
  149. throw new Error('Unimplemented adapter function "archiveApprovedScreen".');
  150. },
  151.  
  152.  
  153. /**
  154. * Gets a list of build screen names
  155. *
  156. * @method getBuildScreenNames
  157. * @return {Promise} With {string[]} List of build screen names
  158. */
  159. getBuildScreenNames: function () {
  160. throw new Error('Unimplemented adapter function "getBuildScreenNames".');
  161. },
  162.  
  163. /**
  164. * Gets a specific build screen
  165. *
  166. * @method getBuildScreen
  167. * @param {string} name Name of build screen
  168. * @return {Promise} With {PNGImage}
  169. */
  170. getBuildScreen: function (name) {
  171. throw new Error('Unimplemented adapter function "getBuildScreen".');
  172. },
  173.  
  174. /**
  175. * Archives a specific build screen
  176. *
  177. * @method archiveBuildScreen
  178. * @param {string} name Name of build screen
  179. * @param {PNGImage} image Screen to archive
  180. * @return {Promise}
  181. */
  182. archiveBuildScreen: function (name, image) {
  183. throw new Error('Unimplemented adapter function "archiveBuildScreen".');
  184. },
  185.  
  186.  
  187. /**
  188. * Gets a list of build highlight names
  189. *
  190. * @method getHighlightScreenNames
  191. * @return {Promise} With {string[]} List of build screen names
  192. */
  193. getHighlightScreenNames: function () {
  194. throw new Error('Unimplemented adapter function "getHighlightScreenNames".');
  195. },
  196.  
  197. /**
  198. * Gets a specific highlight screen
  199. *
  200. * @method getHighlightScreen
  201. * @param {string} name Name of build screen
  202. * @return {Promise} With {PNGImage} Build screen
  203. */
  204. getHighlightScreen: function (name) {
  205. throw new Error('Unimplemented adapter function "getHighlightScreen".');
  206. },
  207.  
  208. /**
  209. * Archives a specific highlight screen
  210. *
  211. * @method archiveHighlightScreen
  212. * @param {string} name Name of highlight screen
  213. * @param {PNGImage} image Screen to archive
  214. */
  215. archiveHighlightScreen: function (name, image) {
  216. throw new Error('Unimplemented adapter function "archiveHighlightScreen".');
  217. }
  218. },
  219.  
  220. {
  221. /**
  222. * Type of class
  223. *
  224. * @property TYPE
  225. * @type string
  226. */
  227. TYPE: 'StorageAdapter'
  228. });
  229.  
  230. module.exports = StorageAdapter;
  231.