File size: 1,746 Bytes
1abfaca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Generated by CoffeeScript 1.9.3
var ClientLoader, ClientOpts, ClientRenderer, Util, _,
  extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  hasProp = {}.hasOwnProperty;

_ = require('lodash')._;

Util = require('../utils');

ClientOpts = require('../config/ClientOptions');

ClientRenderer = (function(superClass) {
  extend(ClientRenderer, superClass);

  function ClientRenderer() {
    var e;
    try {
      (new ClientLoader).load((function(_this) {
        return function(e, __API) {
          _this.__API = __API;
          if (e != null) {
            throw new Error(e);
          }
        };
      })(this));
    } catch (_error) {
      e = _error;
      return console.log(e);
    }
    this.__template = "/*\n * client.js\n * API Client Generated by RikkiTikki\n */\n<%= core_api %>\n(function() {\n  var NS = RikkiTikki.createScope('<%=ns%>');\n  <% for (var key in opts) { %>\n  <% if (opts[key]) { %>NS.<%= key.toUpperCase() %> = <%= typeof opts[key] == 'string' ?  '\"'+opts[key]+'\"' : opts[key] %>;<% } %><% } %>\n}).call(this);";
  }

  ClientRenderer.prototype.toSource = function() {
    var client_opts, ns;
    client_opts = new ClientOpts;
    ns = !((ns = client_opts.get('api_namespace')) === void 0 || ns === '') ? ns : 'Client';
    return (_.template(this.__template))({
      core_api: this.__API,
      opts: client_opts.valueOf(),
      ns: ns
    });
  };

  return ClientRenderer;

})(Object);

module.exports = ClientRenderer;

ClientLoader = require('./ClientLoader');