text:
require 'spec_helper'
include Rspec::Bash

describe 'StubServer' do
  let(:call_log_manager) { double(CallLogManager) }
  let(:call_conf_manager) { double(CallConfigurationManager) }
  let(:stub_marshaller) { double(RubyStubMarshaller) }
  let(:tcp_server) { double(TCPServer) }
  let(:accept_thread) { double(Thread) }

  subject { StubServer.new(call_log_manager, call_conf_manager, stub_marshaller) }

  context '#start' do
    before do
      allow(accept_thread).to receive(:kill)
      allow(subject).to receive(:accept_loop)
      allow(Thread).to receive(:new)
        .and_yield
        .and_return(accept_thread)
    end

    it 'returns the thread that the server is accepting connections on' do
      expect(subject.start(tcp_server)).to eql(accept_thread)
    end
    it 'enters the accept loop' do
      expect(subject).to receive(:accept_loop)
        .with(tcp_server)
      subject.start(tcp_server)
    end
  end
  context '#accept_loop' do
    let(:tcp_server) { double(TCPServer) }
    let(:tcp_socket) { double(TCPSocket) }

    before do
      allow(tcp_server).to receive(:accept)
        .and_return(tcp_socket)
      allow(tcp_socket).to receive(:read)
        .and_return('client_message')
      allow(subject).to receive(:process)
        .with('client_message')
        .and_return('server_message')
    end
    it 'accepts the connection and replies' do
      expect(tcp_socket).to receive(:write)
        .with('server_message')
      expect(tcp_socket).to receive(:close)

      subject.accept_loop(tcp_server, false)
    end
  end
  context '#process' do
    let(:client_message) do
      {
        command: 'first_command',
        stdin:   'stdin',
        args:    %w(first_argument second_argument)
      }
    end
    let(:server_message) do
      {
        args:     %w(first_argument second_argument),
        exitcode: 0,
        outputs:  []
      }
    end
    it 'calls its marshaller to serialize and deserialize messages' do
      expect(stub_marshaller).to receive(:unmarshal)
        .with('client_message')
        .and_return(client_message)

      expect(subject).to receive(:process_stub_call)
        .with(client_message)
        .and_return(server_message)

      expect(stub_marshaller).to receive(:marshal)
        .with(server_message)
        .and_return('server_message')

      expect(subject.process('client_message'))
        .to eql 'server_message'
    end
  end
  context '#process_stub_call' do
    before do
      allow(call_log_manager).to receive(:add_log)
      allow(call_conf_manager).to receive(:get_best_call_conf)
        .with('first_command', %w(first_argument second_argument))
        .and_return(
          args:     %w(first_argument second_argument),
          exitcode: 0,
          outputs:  []
        )
    end

    it 'logs the call for the command' do
      expect(call_log_manager).to receive(:add_log)
        .with('first_command', 'stdin', %w(first_argument second_argument))

      subject.process_stub_call(
        command: 'first_command',
        stdin:   'stdin',
        args:    %w(first_argument second_argument)
      )
    end

    it 'returns the best matching call configuration for the command' do
      expect(
        subject.process_stub_call(
          command: 'first_command',
          stdin:   'stdin',
          args:    %w(first_argument second_argument)
        )
      ).to eql(
        args:     %w(first_argument second_argument),
        exitcode: 0,
        outputs:  []
      )
    end
  end
end


text:
<?php

final class DifferentialInlineCommentEditController
  extends PhabricatorInlineCommentController {

  private $revisionID;

  public function willProcessRequest(array $data) {
    $this->revisionID = $data['id'];
  }

  protected function createComment() {

    // Verify revision and changeset correspond to actual objects.
    $revision_id = $this->revisionID;
    $changeset_id = $this->getChangesetID();

    $viewer = $this->getRequest()->getUser();
    $revision = id(new DifferentialRevisionQuery())
      ->setViewer($viewer)
      ->withIDs(array($revision_id))
      ->executeOne();

    if (!$revision) {
      throw new Exception("Invalid revision ID!");
    }

    if (!id(new DifferentialChangeset())->load($changeset_id)) {
      throw new Exception("Invalid changeset ID!");
    }

    return id(new DifferentialInlineComment())
      ->setRevision($revision)
      ->setChangesetID($changeset_id);
  }

  protected function loadComment($id) {
    return id(new DifferentialInlineCommentQuery())
      ->withIDs(array($id))
      ->executeOne();
  }

  protected function loadCommentForEdit($id) {
    $request = $this->getRequest();
    $user = $request->getUser();

    $inline = $this->loadComment($id);
    if (!$this->canEditInlineComment($user, $inline)) {
      throw new Exception("That comment is not editable!");
    }
    return $inline;
  }

  private function canEditInlineComment(
    PhabricatorUser $user,
    DifferentialInlineComment $inline) {

    // Only the author may edit a comment.
    if ($inline->getAuthorPHID() != $user->getPHID()) {
      return false;
    }

    // Saved comments may not be edited, for now, although the schema now
    // supports it.
    if (!$inline->isDraft()) {
      return false;
    }

    // Inline must be attached to the active revision.
    if ($inline->getRevisionID() != $this->revisionID) {
      return false;
    }

    return true;
  }

  protected function deleteComment(PhabricatorInlineCommentInterface $inline) {
    $inline->openTransaction();
      DifferentialDraft::deleteHasDraft(
        $inline->getAuthorPHID(),
        $inline->getRevisionPHID(),
        $inline->getPHID());
      $inline->delete();
    $inline->saveTransaction();
  }

  protected function saveComment(PhabricatorInlineCommentInterface $inline) {
    $inline->openTransaction();
      $inline->save();
      DifferentialDraft::markHasDraft(
        $inline->getAuthorPHID(),
        $inline->getRevisionPHID(),
        $inline->getPHID());
    $inline->saveTransaction();
  }
}

redpajama_set_name: RedPajamaGithub


text:
(function() {
  // Public sightglass interface.
  function sightglass(obj, keypath, callback, options) {
    return new Observer(obj, keypath, callback, options)
  }

  // Batteries not included.
  sightglass.adapters = {}

  // Constructs a new keypath observer and kicks things off.
  function Observer(obj, keypath, callback, options) {
    this.options = options || {}
    this.options.adapters = this.options.adapters || {}
    this.obj = obj
    this.keypath = keypath
    this.callback = callback
    this.objectPath = []
    this.parse()

    if (isObject(this.target = this.realize())) {
      this.set(true, this.key, this.target, this.callback)
    }
  }

  // Tokenizes the provided keypath string into interface + path tokens for the
  // observer to work with.
  Observer.tokenize = function(keypath, interfaces, root) {
    var tokens = []
    var current = {i: root, path: ''}
    var index, chr

    for (index = 0; index < keypath.length; index++) {
      chr = keypath.charAt(index)

      if (!!~interfaces.indexOf(chr)) {
        tokens.push(current)
        current = {i: chr, path: ''}
      } else {
        current.path += chr
      }
    }

    tokens.push(current)
    return tokens
  }

  // Parses the keypath using the interfaces defined on the view. Sets variables
  // for the tokenized keypath as well as the end key.
  Observer.prototype.parse = function() {
    var interfaces = this.interfaces()
    var root, path

    if (!interfaces.length) {
      error('Must define at least one adapter interface.')
    }

    if (!!~interfaces.indexOf(this.keypath[0])) {
      root = this.keypath[0]
      path = this.keypath.substr(1)
    } else {
      if (typeof (root = this.options.root || sightglass.root) === 'undefined') {
        error('Must define a default root adapter.')
      }

      path = this.keypath
    }

    this.tokens = Observer.tokenize(path, interfaces, root)
    this.key = this.tokens.pop()
  }

  // Realizes the full keypath, attaching observers for every key and correcting
  // old observers to any changed objects in the keypath.
  Observer.prototype.realize = function() {
    var current = this.obj
    var unreached = false
    var prev

    this.tokens.forEach(function(token, index) {
      if (isObject(current)) {
        if (typeof this.objectPath[index] !== 'undefined') {
          if (current !== (prev = this.objectPath[index])) {
            this.set(false, token, prev, this.update.bind(this))
            this.set(true, token, current, this.update.bind(this))
            this.objectPath[index] = current
          }
        } else {
          this.set(true, token, current, this.update.bind(this))
          this.objectPath[index] = current
        }

        current = this.get(token, current)
      } else {
        if (unreached === false) {
          unreached = index
        }

        if (prev = this.objectPath[index]) {
          this.set(false, token, prev, this.update.bind(this))
        }
      }
    }, this)

    if (unreached !== false) {
      this.objectPath.splice(unreached)
    }

    return current
  }

  // Updates the keypath. This is called when any intermediary key is changed.
  Observer.prototype.update = function() {
    var next, oldValue

    if ((next = this.realize()) !== this.target) {
      if (isObject(this.target)) {
        this.set(false, this.key, this.target, this.callback)
      }

      if (isObject(next)) {
        this.set(true, this.key, next, this.callback)
      }

      oldValue = this.value()
      this.target = next

      if (this.value() !== oldValue) this.callback()
    }
  }

  // Reads the current end value of the observed keypath. Returns undefined if
  // the full keypath is unreachable.
  Observer.prototype.value = function() {
    if (isObject(this.target)) {
      return this.get(this.key, this.target)
    }
  }

  // Sets the current end value of the observed keypath. Calling setValue when
  // the full keypath is unreachable is a no-op.
  Observer.prototype.setValue = function(value) {
    if (isObject(this.target)) {
      this.adapter(this.key).set(this.target, this.key.path, value)
    }
  }

  // Gets the provided key on an object.
  Observer.prototype.get = function(key, obj) {
    return this.adapter(key).get(obj, key.path)
  }

  // Observes or unobserves a callback on the object using the provided key.
  Observer.prototype.set = function(active, key, obj, callback) {
    var action = active ? 'observe' : 'unobserve'
    this.adapter(key)[action](obj, key.path, callback)
  }

  // Returns an array of all unique adapter interfaces available.
  Observer.prototype.interfaces = function() {
    var interfaces = Object.keys(this.options.adapters)

    Object.keys(sightglass.adapters).forEach(function(i) {
      if (!~interfaces.indexOf(i)) {
        interfaces.push(i)
      }
    })

    return interfaces
  }

  // Convenience function to grab the adapter for a specific key.
  Observer.prototype.adapter = function(key) {
    return this.options.adapters[key.i] ||
      sightglass.adapters[key.i]
  }

  // Unobserves the entire keypath.
  Observer.prototype.unobserve = function() {
    var obj

    this.tokens.forEach(function(token, index) {
      if (obj = this.objectPath[index]) {
        this.set(false, token, obj, this.update.bind(this))
      }
    }, this)

    if (isObject(this.target)) {
      this.set(false, this.key, this.target, this.callback)
    }
  }

  // Check if a value is an object than can be observed.
  function isObject(obj) {
    return typeof obj === 'object' && obj !== null
  }

  // Error thrower.
  function error(message) {
    throw new Error('[sightglass] ' + message)
  }

  // Export module for Node and the browser.
  if (typeof module !== 'undefined' && module.exports) {
    module.exports = sightglass
  } else if (typeof define === 'function' && define.amd) {
    define([], function() {
      return this.sightglass = sightglass
    })
  } else {
    this.sightglass = sightglass
  }
}).call(this);

// Rivets.js
// version: 0.8.1
// author: Michael Richards
// license: MIT
(function() {
  var Rivets, bindMethod, unbindMethod, _ref,
    __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __slice = [].slice,
    __hasProp = {}.hasOwnProperty,
    __extends = 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; },
    __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

  Rivets = {
    options: ['prefix', 'templateDelimiters', 'rootInterface', 'preloadData', 'handler'],
    extensions: ['binders', 'formatters', 'components', 'adapters'],
    "public": {
      binders: {},
      components: {},
      formatters: {},
      adapters: {},
      prefix: 'rv',
      templateDelimiters: ['{', '}'],
      rootInterface: '.',
      preloadData: true,
      handler: function(context, ev, binding) {
        return this.call(context, ev, binding.view.models);
      },
      configure: function(options) {
        var descriptor, key, option, value;
        if (options == null) {
          options = {};
        }
        for (option in options) {
          value = options[option];
          if (option === 'binders' || option === 'components' || option === 'formatters' || option === 'adapters') {
            for (key in value) {
              descriptor = value[key];
              Rivets[option][key] = descriptor;
            }
          } else {
            Rivets["public"][option] = value;
          }
        }
      },
      bind: function(el, models, options) {
        var view;
        if (models == null) {
          models = {};
        }
        if (options == null) {
          options = {};
        }
        view = new Rivets.View(el, models, options);
        view.bind();
        return view;
      },
      init: function(component, el, data) {
        var scope, view;
        if (data == null) {
          data = {};
        }
        if (el == null) {
          el = document.createElement('div');
        }
        component = Rivets["public"].components[component];
        el.innerHTML = component.template.call(this, el);
        scope = component.initialize.call(this, el, data);
        view = new Rivets.View(el, scope);
        view.bind();
        return view;
      }
    }
  };

  if (window['jQuery'] || window['$']) {
    _ref = 'on' in jQuery.prototype ? ['on', 'off'] : ['bind', 'unbind'], bindMethod = _ref[0], unbindMethod = _ref[1];
    Rivets.Util = {
      bindEvent: function(el, event, handler) {
        return jQuery(el)[bindMethod](event, handler);
      },
      unbindEvent: function(el, event, handler) {
        return jQuery(el)[unbindMethod](event, handler);
      },
      getInputValue: function(el) {
        var $el;
        $el = jQuery(el);
        if ($el.attr('type') === 'checkbox') {
          return $el.is(':checked');
        } else {
          return $el.val();
        }
      }
    };
  } else {
    Rivets.Util = {
      bindEvent: (function() {
        if ('addEventListener' in window) {
          return function(el, event, handler) {
            return el.addEventListener(event, handler, false);
          };
        }
        return function(el, event, handler) {
          return el.attachEvent('on' + event, handler);
        };
      })(),
      unbindEvent: (function() {
        if ('removeEventListener' in window) {
          return function(el, event, handler) {
            return el.removeEventListener(event, handler, false);
          };
        }
        return function(el, event, handler) {
          return el.detachEvent('on' + event, handler);
        };
      })(),
      getInputValue: function(el) {
        var o, _i, _len, _results;
        if (el.type === 'checkbox') {
          return el.checked;
        } else if (el.type === 'select-multiple') {
          _results = [];
          for (_i = 0, _len = el.length; _i < _len; _i++) {
            o = el[_i];
            if (o.selected) {
              _results.push(o.value);
            }
          }
          return _results;
        } else {
          return el.value;
        }
      }
    };
  }

  Rivets.TypeParser = (function() {
    function TypeParser() {}

    TypeParser.types = {
      primitive: 0,
      keypath: 1
    };

    TypeParser.parse = function(string) {
      if (/^'.*'$|^".*"$/.test(string)) {
        return {
          type: this.types.primitive,
          value: string.slice(1, -1)
        };
      } else if (string === 'true') {
        return {
          type: this.types.primitive,
          value: true
        };
      } else if (string === 'false') {
        return {
          type: this.types.primitive,
          value: false
        };
      } else if (string === 'null') {
        return {
          type: this.types.primitive,
          value: null
        };
      } else if (string === 'undefined') {
        return {
          type: this.types.primitive,
          value: void 0
        };
      } else if (isNaN(Number(string)) === false) {
        return {
          type: this.types.primitive,
          value: Number(string)
        };
      } else {
        return {
          type: this.types.keypath,
          value: string
        };
      }
    };

    return TypeParser;

  })();

  Rivets.TextTemplateParser = (function() {
    function TextTemplateParser() {}

    TextTemplateParser.types = {
      text: 0,
      binding: 1
    };

    TextTemplateParser.parse = function(template, delimiters) {
      var index, lastIndex, lastToken, length, substring, tokens, value;
      tokens = [];
      length = template.length;
      index = 0;
      lastIndex = 0;
      while (lastIndex < length) {
        index = template.indexOf(delimiters[0], lastIndex);
        if (index < 0) {
          tokens.push({
            type: this.types.text,
            value: template.slice(lastIndex)
          });
          break;
        } else {
          if (index > 0 && lastIndex < index) {
            tokens.push({
              type: this.types.text,
              value: template.slice(lastIndex, index)
            });
          }
          lastIndex = index + delimiters[0].length;
          index = template.indexOf(delimiters[1], lastIndex);
          if (index < 0) {
            substring = template.slice(lastIndex - delimiters[1].length);
            lastToken = tokens[tokens.length - 1];
            if ((lastToken != null ? lastToken.type : void 0) === this.types.text) {
              lastToken.value += substring;
            } else {
              tokens.push({
                type: this.types.text,
                value: substring
              });
            }
            break;
          }
          value = template.slice(lastIndex, index).trim();
          tokens.push({
            type: this.types.binding,
            value: value
          });
          lastIndex = index + delimiters[1].length;
        }
      }
      return tokens;
    };

    return TextTemplateParser;

  })();

  Rivets.View = (function() {
    function View(els, models, options) {
      var k, option, v, _base, _i, _j, _len, _len1, _ref1, _ref2, _ref3, _ref4, _ref5;
      this.els = els;
      this.models = models;
      if (options == null) {
        options = {};
      }
      this.update = __bind(this.update, this);
      this.publish = __bind(this.publish, this);
      this.sync = __bind(this.sync, this);
      this.unbind = __bind(this.unbind, this);
      this.bind = __bind(this.bind, this);
      this.select = __bind(this.select, this);
      this.traverse = __bind(this.traverse, this);
      this.build = __bind(this.build, this);
      this.buildBinding = __bind(this.buildBinding, this);
      this.bindingRegExp = __bind(this.bindingRegExp, this);
      this.options = __bind(this.options, this);
      if (!(this.els.jquery || this.els instanceof Array)) {
        this.els = [this.els];
      }
      _ref1 = Rivets.extensions;
      for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
        option = _ref1[_i];
        this[option] = {};
        if (options[option]) {
          _ref2 = options[option];
          for (k in _ref2) {
            v = _ref2[k];
            this[option][k] = v;
          }
        }
        _ref3 = Rivets["public"][option];
        for (k in _ref3) {
          v = _ref3[k];
          if ((_base = this[option])[k] == null) {
            _base[k] = v;
          }
        }
      }
      _ref4 = Rivets.options;
      for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) {
        option = _ref4[_j];
        this[option] = (_ref5 = options[option]) != null ? _ref5 : Rivets["public"][option];
      }
      this.build();
    }

    View.prototype.options = function() {
      var option, options, _i, _len, _ref1;
      options = {};
      _ref1 = Rivets.extensions.concat(Rivets.options);
      for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
        option = _ref1[_i];
        options[option] = this[option];
      }
      return options;
    };

    View.prototype.bindingRegExp = function() {
      return new RegExp("^" + this.prefix + "-");
    };

    View.prototype.buildBinding = function(binding, node, type, declaration) {
      var context, ctx, dependencies, keypath, options, pipe, pipes;
      options = {};
      pipes = (function() {
        var _i, _len, _ref1, _results;
        _ref1 = declaration.split('|');
        _results = [];
        for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
          pipe = _ref1[_i];
          _results.push(pipe.trim());
        }
        return _results;
      })();
      context = (function() {
        var _i, _len, _ref1, _results;
        _ref1 = pipes.shift().split('<');
        _results = [];
        for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
          ctx = _ref1[_i];
          _results.push(ctx.trim());
        }
        return _results;
      })();
      keypath = context.shift();
      options.formatters = pipes;
      if (dependencies = context.shift()) {
        options.dependencies = dependencies.split(/\s+/);
      }
      return this.bindings.push(new Rivets[binding](this, node, type, keypath, options));
    };

    View.prototype.build = function() {
      var el, parse, _i, _len, _ref1;
      this.bindings = [];
      parse = (function(_this) {
        return function(node) {
          var block, childNode, delimiters, n, parser, text, token, tokens, _i, _j, _len, _len1, _ref1, _results;
          if (node.nodeType === 3) {
            parser = Rivets.TextTemplateParser;
            if (delimiters = _this.templateDelimiters) {
              if ((tokens = parser.parse(node.data, delimiters)).length) {
                if (!(tokens.length === 1 && tokens[0].type === parser.types.text)) {
                  for (_i = 0, _len = tokens.length; _i < _len; _i++) {
                    token = tokens[_i];
                    text = document.createTextNode(token.value);
                    node.parentNode.insertBefore(text, node);
                    if (token.type === 1) {
                      _this.buildBinding('TextBinding', text, null, token.value);
                    }
                  }
                  node.parentNode.removeChild(node);
                }
              }
            }
          } else if (node.nodeType === 1) {
            block = _this.traverse(node);
          }
          if (!block) {
            _ref1 = (function() {
              var _k, _len1, _ref1, _results1;
              _ref1 = node.childNodes;
              _results1 = [];
              for (_k = 0, _len1 = _ref1.length; _k < _len1; _k++) {
                n = _ref1[_k];
                _results1.push(n);
              }
              return _results1;
            })();
            _results = [];
            for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
              childNode = _ref1[_j];
              _results.push(parse(childNode));
            }
            return _results;
          }
        };
      })(this);
      _ref1 = this.els;
      for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
        el = _ref1[_i];
        parse(el);
      }
      this.bindings.sort(function(a, b) {
        var _ref2, _ref3;
        return (((_ref2 = b.binder) != null ? _ref2.priority : void 0) || 0) - (((_ref3 = a.binder) != null ? _ref3.priority : void 0) || 0);
      });
    };

    View.prototype.traverse = function(node) {
      var attribute, attributes, binder, bindingRegExp, block, identifier, regexp, type, value, _i, _j, _len, _len1, _ref1, _ref2, _ref3;
      bindingRegExp = this.bindingRegExp();
      block = node.nodeName === 'SCRIPT' || node.nodeName === 'STYLE';
      _ref1 = node.attributes;
      for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
        attribute = _ref1[_i];
        if (bindingRegExp.test(attribute.name)) {
          type = attribute.name.replace(bindingRegExp, '');
          if (!(binder = this.binders[type])) {
            _ref2 = this.binders;
            for (identifier in _ref2) {
              value = _ref2[identifier];
              if (identifier !== '*' && identifier.indexOf('*') !== -1) {
                regexp = new RegExp("^" + (identifier.replace(/\*/g, '.+')) + "$");
                if (regexp.test(type)) {
                  binder = value;
                }
              }
            }
          }
          binder || (binder = this.binders['*']);
          if (binder.block) {
            block = true;
            attributes = [attribute];
          }
        }
      }
      _ref3 = attributes || node.attributes;
      for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
        attribute = _ref3[_j];
        if (bindingRegExp.test(attribute.name)) {
          type = attribute.name.replace(bindingRegExp, '');
          this.buildBinding('Binding', node, type, attribute.value);
        }
      }
      if (!block) {
        type = node.nodeName.toLowerCase();
        if (this.components[type] && !node._bound) {
          this.bindings.push(new Rivets.ComponentBinding(this, node, type));
          block = true;
        }
      }
      return block;
    };

    View.prototype.select = function(fn) {
      var binding, _i, _len, _ref1, _results;
      _ref1 = this.bindings;
      _results = [];
      for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
        binding = _ref1[_i];
        if (fn(binding)) {
          _results.push(binding);
        }
      }
      return _results;
    };

    View.prototype.bind = function() {
      var binding, _i, _len, _ref1, _results;
      _ref1 = this.bindings;
      _results = [];
      for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
        binding = _ref1[_i];
        _results.push(binding.bind());
      }
      return _results;
    };

    View.prototype.unbind = function() {
      var binding, _i, _len, _ref1, _results;
      _ref1 = this.bindings;
      _results = [];
      for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
        binding = _ref1[_i];
        _results.push(binding.unbind());
      }
      return _results;
    };

    View.prototype.sync = function() {
      var binding, _i, _len, _ref1, _results;
      _ref1 = this.bindings;
      _results = [];
      for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
        binding = _ref1[_i];
        _results.push(typeof binding.sync === "function" ? binding.sync() : void 0);
      }
      return _results;
    };

    View.prototype.publish = function() {
      var binding, _i, _len, _ref1, _results;
      _ref1 = this.select(function(b) {
        var _ref1;
        return (_ref1 = b.binder) != null ? _ref1.publishes : void 0;
      });
      _results = [];
      for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
        binding = _ref1[_i];
        _results.push(binding.publish());
      }
      return _results;
    };

    View.prototype.update = function(models) {
      var binding, key, model, _i, _len, _ref1, _results;
      if (models == null) {
        models = {};
      }
      for (key in models) {
        model = models[key];
        this.models[key] = model;
      }
      _ref1 = this.bindings;
      _results = [];
      for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
        binding = _ref1[_i];
        _results.push(typeof binding.update === "function" ? binding.update(models) : void 0);
      }
      return _results;
    };

    return View;

  })();

  Rivets.Binding = (function() {
    function Binding(view, el, type, keypath, options) {
      this.view = view;
      this.el = el;
      this.type = type;
      this.keypath = keypath;
      this.options = options != null ? options : {};
      this.getValue = __bind(this.getValue, this);
      this.update = __bind(this.update, this);
      this.unbind = __bind(this.unbind, this);
      this.bind = __bind(this.bind, this);
      this.publish = __bind(this.publish, this);
      this.sync = __bind(this.sync, this);
      this.set = __bind(this.set, this);
      this.eventHandler = __bind(this.eventHandler, this);
      this.formattedValue = __bind(this.formattedValue, this);
      this.parseTarget = __bind(this.parseTarget, this);
      this.observe = __bind(this.observe, this);
      this.setBinder = __bind(this.setBinder, this);
      this.formatters = this.options.formatters || [];
      this.dependencies = [];
      this.formatterObservers = {};
      this.model = void 0;
      this.setBinder();
    }

    Binding.prototype.setBinder = function() {
      var identifier, regexp, value, _ref1;
      if (!(this.binder = this.view.binders[this.type])) {
        _ref1 = this.view.binders;
        for (identifier in _ref1) {
          value = _ref1[identifier];
          if (identifier !== '*' && identifier.indexOf('*') !== -1) {
            regexp = new RegExp("^" + (identifier.replace(/\*/g, '.+')) + "$");
            if (regexp.test(this.type)) {
              this.binder = value;
              this.args = new RegExp("^" + (identifier.replace(/\*/g, '(.+)')) + "$").exec(this.type);
              this.args.shift();
            }
          }
        }
      }
      this.binder || (this.binder = this.view.binders['*']);
      if (this.binder instanceof Function) {
        return this.binder = {
          routine: this.binder
        };
      }
    };

    Binding.prototype.observe = function(obj, keypath, callback) {
      return Rivets.sightglass(obj, keypath, callback, {
        root: this.view.rootInterface,
        adapters: this.view.adapters
      });
    };

    Binding.prototype.parseTarget = function() {
      var token;
      token = Rivets.TypeParser.parse(this.keypath);
      if (token.type === 0) {
        return this.value = token.value;
      } else {
        this.observer = this.observe(this.view.models, this.keypath, this.sync);
        return this.model = this.observer.target;
      }
    };

    Binding.prototype.formattedValue = function(value) {
      var ai, arg, args, fi, formatter, id, observer, processedArgs, _base, _i, _j, _len, _len1, _ref1;
      _ref1 = this.formatters;
      for (fi = _i = 0, _len = _ref1.length; _i < _len; fi = ++_i) {
        formatter = _ref1[fi];
        args = formatter.match(/[^\s']+|'([^']|'[^\s])*'|"([^"]|"[^\s])*"/g);
        id = args.shift();
        formatter = this.view.formatters[id];
        args = (function() {
          var _j, _len1, _results;
          _results = [];
          for (_j = 0, _len1 = args.length; _j < _len1; _j++) {
            arg = args[_j];
            _results.push(Rivets.TypeParser.parse(arg));
          }
          return _results;
        })();
        processedArgs = [];
        for (ai = _j = 0, _len1 = args.length; _j < _len1; ai = ++_j) {
          arg = args[ai];
          processedArgs.push(arg.type === 0 ? arg.value : ((_base = this.formatterObservers)[fi] || (_base[fi] = {}), !(observer = this.formatterObservers[fi][ai]) ? (observer = this.observe(this.view.models, arg.value, this.sync), this.formatterObservers[fi][ai] = observer) : void 0, observer.value()));
        }
        if ((formatter != null ? formatter.read : void 0) instanceof Function) {
          value = formatter.read.apply(formatter, [value].concat(__slice.call(processedArgs)));
        } else if (formatter instanceof Function) {
          value = formatter.apply(null, [value].concat(__slice.call(processedArgs)));
        }
      }
      return value;
    };

    Binding.prototype.eventHandler = function(fn) {
      var binding, handler;
      handler = (binding = this).view.handler;
      return function(ev) {
        return handler.call(fn, this, ev, binding);
      };
    };

    Binding.prototype.set = function(value) {
      var _ref1;
      value = value instanceof Function && !this.binder["function"] ? this.formattedValue(value.call(this.model)) : this.formattedValue(value);
      return (_ref1 = this.binder.routine) != null ? _ref1.call(this, this.el, value) : void 0;
    };

    Binding.prototype.sync = function() {
      var dependency, observer;
      return this.set((function() {
        var _i, _j, _len, _len1, _ref1, _ref2, _ref3;
        if (this.observer) {
          if (this.model !== this.observer.target) {
            _ref1 = this.dependencies;
            for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
              observer = _ref1[_i];
              observer.unobserve();
            }
            this.dependencies = [];
            if (((this.model = this.observer.target) != null) && ((_ref2 = this.options.dependencies) != null ? _ref2.length : void 0)) {
              _ref3 = this.options.dependencies;
              for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
                dependency = _ref3[_j];
                observer = this.observe(this.model, dependency, this.sync);
                this.dependencies.push(observer);
              }
            }
          }
          return this.observer.value();
        } else {
          return this.value;
        }
      }).call(this));
    };

    Binding.prototype.publish = function() {
      var args, formatter, id, value, _i, _len, _ref1, _ref2, _ref3;
      if (this.observer) {
        value = this.getValue(this.el);
        _ref1 = this.formatters.slice(0).reverse();
        for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
          formatter = _ref1[_i];
          args = formatter.split(/\s+/);
          id = args.shift();
          if ((_ref2 = this.view.formatters[id]) != null ? _ref2.publish : void 0) {
            value = (_ref3 = this.view.formatters[id]).publish.apply(_ref3, [value].concat(__slice.call(args)));
          }
        }
        return this.observer.setValue(value);
      }
    };

    Binding.prototype.bind = function() {
      var dependency, observer, _i, _len, _ref1, _ref2, _ref3;
      this.parseTarget();
      if ((_ref1 = this.binder.bind) != null) {
        _ref1.call(this, this.el);
      }
      if ((this.model != null) && ((_ref2 = this.options.dependencies) != null ? _ref2.length : void 0)) {
        _ref3 = this.options.dependencies;
        for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
          dependency = _ref3[_i];
          observer = this.observe(this.model, dependency, this.sync);
          this.dependencies.push(observer);
        }
      }
      if (this.view.preloadData) {
        return this.sync();
      }
    };

    Binding.prototype.unbind = function() {
      var ai, args, fi, observer, _i, _len, _ref1, _ref2, _ref3, _ref4;
      if ((_ref1 = this.binder.unbind) != null) {
        _ref1.call(this, this.el);
      }
      if ((_ref2 = this.observer) != null) {
        _ref2.unobserve();
      }
      _ref3 = this.dependencies;
      for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
        observer = _ref3[_i];
        observer.unobserve();
      }
      this.dependencies = [];
      _ref4 = this.formatterObservers;
      for (fi in _ref4) {
        args = _ref4[fi];
        for (ai in args) {
          observer = args[ai];
          observer.unobserve();
        }
      }
      return this.formatterObservers = {};
    };

    Binding.prototype.update = function(models) {
      var _ref1, _ref2;
      if (models == null) {
        models = {};
      }
      this.model = (_ref1 = this.observer) != null ? _ref1.target : void 0;
      return (_ref2 = this.binder.update) != null ? _ref2.call(this, models) : void 0;
    };

    Binding.prototype.getValue = function(el) {
      if (this.binder && (this.binder.getValue != null)) {
        return this.binder.getValue.call(this, el);
      } else {
        return Rivets.Util.getInputValue(el);
      }
    };

    return Binding;

  })();

  Rivets.ComponentBinding = (function(_super) {
    __extends(ComponentBinding, _super);

    function ComponentBinding(view, el, type) {
      var attribute, bindingRegExp, propertyName, _i, _len, _ref1, _ref2;
      this.view = view;
      this.el = el;
      this.type = type;
      this.unbind = __bind(this.unbind, this);
      this.bind = __bind(this.bind, this);
      this.locals = __bind(this.locals, this);
      this.component = this.view.components[this.type];
      this["static"] = {};
      this.observers = {};
      this.upstreamObservers = {};
      bindingRegExp = view.bindingRegExp();
      _ref1 = this.el.attributes || [];
      for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
        attribute = _ref1[_i];
        if (!bindingRegExp.test(attribute.name)) {
          propertyName = this.camelCase(attribute.name);
          if (__indexOf.call((_ref2 = this.component["static"]) != null ? _ref2 : [], propertyName) >= 0) {
            this["static"][propertyName] = attribute.value;
          } else {
            this.observers[propertyName] = attribute.value;
          }
        }
      }
    }

    ComponentBinding.prototype.sync = function() {};

    ComponentBinding.prototype.update = function() {};

    ComponentBinding.prototype.publish = function() {};

    ComponentBinding.prototype.locals = function() {
      var key, observer, result, value, _ref1, _ref2;
      result = {};
      _ref1 = this["static"];
      for (key in _ref1) {
        value = _ref1[key];
        result[key] = value;
      }
      _ref2 = this.observers;
      for (key in _ref2) {
        observer = _ref2[key];
        result[key] = observer.value();
      }
      return result;
    };

    ComponentBinding.prototype.camelCase = function(string) {
      return string.replace(/-([a-z])/g, function(grouped) {
        return grouped[1].toUpperCase();
      });
    };

    ComponentBinding.prototype.bind = function() {
      var k, key, keypath, observer, option, options, scope, v, _base, _i, _j, _len, _len1, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _results;
      if (!this.bound) {
        _ref1 = this.observers;
        for (key in _ref1) {
          keypath = _ref1[key];
          this.observers[key] = this.observe(this.view.models, keypath, ((function(_this) {
            return function(key) {
              return function() {
                return _this.componentView.models[key] = _this.observers[key].value();
              };
            };
          })(this)).call(this, key));
        }
        this.bound = true;
      }
      if (this.componentView != null) {
        return this.componentView.bind();
      } else {
        this.el.innerHTML = this.component.template.call(this);
        scope = this.component.initialize.call(this, this.el, this.locals());
        this.el._bound = true;
        options = {};
        _ref2 = Rivets.extensions;
        for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
          option = _ref2[_i];
          options[option] = {};
          if (this.component[option]) {
            _ref3 = this.component[option];
            for (k in _ref3) {
              v = _ref3[k];
              options[option][k] = v;
            }
          }
          _ref4 = this.view[option];
          for (k in _ref4) {
            v = _ref4[k];
            if ((_base = options[option])[k] == null) {
              _base[k] = v;
            }
          }
        }
        _ref5 = Rivets.options;
        for (_j = 0, _len1 = _ref5.length; _j < _len1; _j++) {
          option = _ref5[_j];
          options[option] = (_ref6 = this.component[option]) != null ? _ref6 : this.view[option];
        }
        this.componentView = new Rivets.View(this.el, scope, options);
        this.componentView.bind();
        _ref7 = this.observers;
        _results = [];
        for (key in _ref7) {
          observer = _ref7[key];
          _results.push(this.upstreamObservers[key] = this.observe(this.componentView.models, key, ((function(_this) {
            return function(key, observer) {
              return function() {
                return observer.setValue(_this.componentView.models[key]);
              };
            };
          })(this)).call(this, key, observer)));
        }
        return _results;
      }
    };

    ComponentBinding.prototype.unbind = function() {
      var key, observer, _ref1, _ref2, _ref3;
      _ref1 = this.upstreamObservers;
      for (key in _ref1) {
        observer = _ref1[key];
        observer.unobserve();
      }
      _ref2 = this.observers;
      for (key in _ref2) {
        observer = _ref2[key];
        observer.unobserve();
      }
      return (_ref3 = this.componentView) != null ? _ref3.unbind.call(this) : void 0;
    };

    return ComponentBinding;

  })(Rivets.Binding);

  Rivets.TextBinding = (function(_super) {
    __extends(TextBinding, _super);

    function TextBinding(view, el, type, keypath, options) {
      this.view = view;
      this.el = el;
      this.type = type;
      this.keypath = keypath;
      this.options = options != null ? options : {};
      this.sync = __bind(this.sync, this);
      this.formatters = this.options.formatters || [];
      this.dependencies = [];
      this.formatterObservers = {};
    }

    TextBinding.prototype.binder = {
      routine: function(node, value) {
        return node.data = value != null ? value : '';
      }
    };

    TextBinding.prototype.sync = function() {
      return TextBinding.__super__.sync.apply(this, arguments);
    };

    return TextBinding;

  })(Rivets.Binding);

  Rivets["public"].binders.text = function(el, value) {
    if (el.textContent != null) {
      return el.textContent = value != null ? value : '';
    } else {
      return el.innerText = value != null ? value : '';
    }
  };

  Rivets["public"].binders.html = function(el, value) {
    return el.innerHTML = value != null ? value : '';
  };

  Rivets["public"].binders.show = function(el, value) {
    return el.style.display = value ? '' : 'none';
  };

  Rivets["public"].binders.hide = function(el, value) {
    return el.style.display = value ? 'none' : '';
  };

  Rivets["public"].binders.enabled = function(el, value) {
    return el.disabled = !value;
  };

  Rivets["public"].binders.disabled = function(el, value) {
    return el.disabled = !!value;
  };

  Rivets["public"].binders.checked = {
    publishes: true,
    priority: 2000,
    bind: function(el) {
      return Rivets.Util.bindEvent(el, 'change', this.publish);
    },
    unbind: function(el) {
      return Rivets.Util.unbindEvent(el, 'change', this.publish);
    },
    routine: function(el, value) {
      var _ref1;
      if (el.type === 'radio') {
        return el.checked = ((_ref1 = el.value) != null ? _ref1.toString() : void 0) === (value != null ? value.toString() : void 0);
      } else {
        return el.checked = !!value;
      }
    }
  };

  Rivets["public"].binders.unchecked = {
    publishes: true,
    priority: 2000,
    bind: function(el) {
      return Rivets.Util.bindEvent(el, 'change', this.publish);
    },
    unbind: function(el) {
      return Rivets.Util.unbindEvent(el, 'change', this.publish);
    },
    routine: function(el, value) {
      var _ref1;
      if (el.type === 'radio') {
        return el.checked = ((_ref1 = el.value) != null ? _ref1.toString() : void 0) !== (value != null ? value.toString() : void 0);
      } else {
        return el.checked = !value;
      }
    }
  };

  Rivets["public"].binders.value = {
    publishes: true,
    priority: 3000,
    bind: function(el) {
      if (!(el.tagName === 'INPUT' && el.type === 'radio')) {
        this.event = el.tagName === 'SELECT' ? 'change' : 'input';
        return Rivets.Util.bindEvent(el, this.event, this.publish);
      }
    },
    unbind: function(el) {
      if (!(el.tagName === 'INPUT' && el.type === 'radio')) {
        return Rivets.Util.unbindEvent(el, this.event, this.publish);
      }
    },
    routine: function(el, value) {
      var o, _i, _len, _ref1, _ref2, _ref3, _results;
      if (el.tagName === 'INPUT' && el.type === 'radio') {
        return el.setAttribute('value', value);
      } else if (window.jQuery != null) {
        el = jQuery(el);
        if ((value != null ? value.toString() : void 0) !== ((_ref1 = el.val()) != null ? _ref1.toString() : void 0)) {
          return el.val(value != null ? value : '');
        }
      } else {
        if (el.type === 'select-multiple') {
          if (value != null) {
            _results = [];
            for (_i = 0, _len = el.length; _i < _len; _i++) {
              o = el[_i];
              _results.push(o.selected = (_ref2 = o.value, __indexOf.call(value, _ref2) >= 0));
            }
            return _results;
          }
        } else if ((value != null ? value.toString() : void 0) !== ((_ref3 = el.value) != null ? _ref3.toString() : void 0)) {
          return el.value = value != null ? value : '';
        }
      }
    }
  };

  Rivets["public"].binders["if"] = {
    block: true,
    priority: 4000,
    bind: function(el) {
      var attr, declaration;
      if (this.marker == null) {
        attr = [this.view.prefix, this.type].join('-').replace('--', '-');
        declaration = el.getAttribute(attr);
        this.marker = document.createComment(" rivets: " + this.type + " " + declaration + " ");
        this.bound = false;
        el.removeAttribute(attr);
        el.parentNode.insertBefore(this.marker, el);
        return el.parentNode.removeChild(el);
      }
    },
    unbind: function() {
      var _ref1;
      return (_ref1 = this.nested) != null ? _ref1.unbind() : void 0;
    },
    routine: function(el, value) {
      var key, model, models, _ref1;
      if (!!value === !this.bound) {
        if (value) {
          models = {};
          _ref1 = this.view.models;
          for (key in _ref1) {
            model = _ref1[key];
            models[key] = model;
          }
          (this.nested || (this.nested = new Rivets.View(el, models, this.view.options()))).bind();
          this.marker.parentNode.insertBefore(el, this.marker.nextSibling);
          return this.bound = true;
        } else {
          el.parentNode.removeChild(el);
          this.nested.unbind();
          return this.bound = false;
        }
      }
    },
    update: function(models) {
      var _ref1;
      return (_ref1 = this.nested) != null ? _ref1.update(models) : void 0;
    }
  };

  Rivets["public"].binders.unless = {
    block: true,
    priority: 4000,
    bind: function(el) {
      return Rivets["public"].binders["if"].bind.call(this, el);
    },
    unbind: function() {
      return Rivets["public"].binders["if"].unbind.call(this);
    },
    routine: function(el, value) {
      return Rivets["public"].binders["if"].routine.call(this, el, !value);
    },
    update: function(models) {
      return Rivets["public"].binders["if"].update.call(this, models);
    }
  };

  Rivets["public"].binders['on-*'] = {
    "function": true,
    priority: 1000,
    unbind: function(el) {
      if (this.handler) {
        return Rivets.Util.unbindEvent(el, this.args[0], this.handler);
      }
    },
    routine: function(el, value) {
      if (this.handler) {
        Rivets.Util.unbindEvent(el, this.args[0], this.handler);
      }
      return Rivets.Util.bindEvent(el, this.args[0], this.handler = this.eventHandler(value));
    }
  };

  Rivets["public"].binders['each-*'] = {
    block: true,
    priority: 4000,
    bind: function(el) {
      var attr, view, _i, _len, _ref1;
      if (this.marker == null) {
        attr = [this.view.prefix, this.type].join('-').replace('--', '-');
        this.marker = document.createComment(" rivets: " + this.type + " ");
        this.iterated = [];
        el.removeAttribute(attr);
        el.parentNode.insertBefore(this.marker, el);
        el.parentNode.removeChild(el);
      } else {
        _ref1 = this.iterated;
        for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
          view = _ref1[_i];
          view.bind();
        }
      }
    },
    unbind: function(el) {
      var view, _i, _len, _ref1, _results;
      if (this.iterated != null) {
        _ref1 = this.iterated;
        _results = [];
        for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
          view = _ref1[_i];
          _results.push(view.unbind());
        }
        return _results;
      }
    },
    routine: function(el, collection) {
      var binding, data, i, index, key, model, modelName, options, previous, template, view, _i, _j, _k, _len, _len1, _len2, _ref1, _ref2, _ref3, _results;
      modelName = this.args[0];
      collection = collection || [];
      if (this.iterated.length > collection.length) {
        _ref1 = Array(this.iterated.length - collection.length);
        for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
          i = _ref1[_i];
          view = this.iterated.pop();
          view.unbind();
          this.marker.parentNode.removeChild(view.els[0]);
        }
      }
      for (index = _j = 0, _len1 = collection.length; _j < _len1; index = ++_j) {
        model = collection[index];
        data = {
          index: index
        };
        data[modelName] = model;
        if (this.iterated[index] == null) {
          _ref2 = this.view.models;
          for (key in _ref2) {
            model = _ref2[key];
            if (data[key] == null) {
              data[key] = model;
            }
          }
          previous = this.iterated.length ? this.iterated[this.iterated.length - 1].els[0] : this.marker;
          options = this.view.options();
          options.preloadData = true;
          template = el.cloneNode(true);
          view = new Rivets.View(template, data, options);
          view.bind();
          this.iterated.push(view);
          this.marker.parentNode.insertBefore(template, previous.nextSibling);
        } else if (this.iterated[index].models[modelName] !== model) {
          this.iterated[index].update(data);
        }
      }
      if (el.nodeName === 'OPTION') {
        _ref3 = this.view.bindings;
        _results = [];
        for (_k = 0, _len2 = _ref3.length; _k < _len2; _k++) {
          binding = _ref3[_k];
          if (binding.el === this.marker.parentNode && binding.type === 'value') {
            _results.push(binding.sync());
          } else {
            _results.push(void 0);
          }
        }
        return _results;
      }
    },
    update: function(models) {
      var data, key, model, view, _i, _len, _ref1, _results;
      data = {};
      for (key in models) {
        model = models[key];
        if (key !== this.args[0]) {
          data[key] = model;
        }
      }
      _ref1 = this.iterated;
      _results = [];
      for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
        view = _ref1[_i];
        _results.push(view.update(data));
      }
      return _results;
    }
  };

  Rivets["public"].binders['class-*'] = function(el, value) {
    var elClass;
    elClass = " " + el.className + " ";
    if (!value === (elClass.indexOf(" " + this.args[0] + " ") !== -1)) {
      return el.className = value ? "" + el.className + " " + this.args[0] : elClass.replace(" " + this.args[0] + " ", ' ').trim();
    }
  };

  Rivets["public"].binders['*'] = function(el, value) {
    if (value != null) {
      return el.setAttribute(this.type, value);
    } else {
      return el.removeAttribute(this.type);
    }
  };

  Rivets["public"].adapters['.'] = {
    id: '_rv',
    counter: 0,
    weakmap: {},
    weakReference: function(obj) {
      var id, _base, _name;
      if (!obj.hasOwnProperty(this.id)) {
        id = this.counter++;
        Object.defineProperty(obj, this.id, {
          value: id
        });
      }
      return (_base = this.weakmap)[_name = obj[this.id]] || (_base[_name] = {
        callbacks: {}
      });
    },
    cleanupWeakReference: function(ref, id) {
      if (!Object.keys(ref.callbacks).length) {
        if (!(ref.pointers && Object.keys(ref.pointers).length)) {
          return delete this.weakmap[id];
        }
      }
    },
    stubFunction: function(obj, fn) {
      var map, original, weakmap;
      original = obj[fn];
      map = this.weakReference(obj);
      weakmap = this.weakmap;
      return obj[fn] = function() {
        var callback, k, r, response, _i, _len, _ref1, _ref2, _ref3, _ref4;
        response = original.apply(obj, arguments);
        _ref1 = map.pointers;
        for (r in _ref1) {
          k = _ref1[r];
          _ref4 = (_ref2 = (_ref3 = weakmap[r]) != null ? _ref3.callbacks[k] : void 0) != null ? _ref2 : [];
          for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
            callback = _ref4[_i];
            callback();
          }
        }
        return response;
      };
    },
    observeMutations: function(obj, ref, keypath) {
      var fn, functions, map, _base, _i, _len;
      if (Array.isArray(obj)) {
        map = this.weakReference(obj);
        if (map.pointers == null) {
          map.pointers = {};
          functions = ['push', 'pop', 'shift', 'unshift', 'sort', 'reverse', 'splice'];
          for (_i = 0, _len = functions.length; _i < _len; _i++) {
            fn = functions[_i];
            this.stubFunction(obj, fn);
          }
        }
        if ((_base = map.pointers)[ref] == null) {
          _base[ref] = [];
        }
        if (__indexOf.call(map.pointers[ref], keypath) < 0) {
          return map.pointers[ref].push(keypath);
        }
      }
    },
    unobserveMutations: function(obj, ref, keypath) {
      var idx, map, pointers;
      if (Array.isArray(obj) && (obj[this.id] != null)) {
        if (map = this.weakmap[obj[this.id]]) {
          if (pointers = map.pointers[ref]) {
            if ((idx = pointers.indexOf(keypath)) >= 0) {
              pointers.splice(idx, 1);
            }
            if (!pointers.length) {
              delete map.pointers[ref];
            }
            return this.cleanupWeakReference(map, obj[this.id]);
          }
        }
      }
    },
    observe: function(obj, keypath, callback) {
      var callbacks, desc, value;
      callbacks = this.weakReference(obj).callbacks;
      if (callbacks[keypath] == null) {
        callbacks[keypath] = [];
        desc = Object.getOwnPropertyDescriptor(obj, keypath);
        if (!((desc != null ? desc.get : void 0) || (desc != null ? desc.set : void 0))) {
          value = obj[keypath];
          Object.defineProperty(obj, keypath, {
            enumerable: true,
            get: function() {
              return value;
            },
            set: (function(_this) {
              return function(newValue) {
                var map, _i, _len, _ref1;
                if (newValue !== value) {
                  _this.unobserveMutations(value, obj[_this.id], keypath);
                  value = newValue;
                  if (map = _this.weakmap[obj[_this.id]]) {
                    callbacks = map.callbacks;
                    if (callbacks[keypath]) {
                      _ref1 = callbacks[keypath].slice();
                      for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
                        callback = _ref1[_i];
                        if (__indexOf.call(callbacks[keypath], callback) >= 0) {
                          callback();
                        }
                      }
                    }
                    return _this.observeMutations(newValue, obj[_this.id], keypath);
                  }
                }
              };
            })(this)
          });
        }
      }
      if (__indexOf.call(callbacks[keypath], callback) < 0) {
        callbacks[keypath].push(callback);
      }
      return this.observeMutations(obj[keypath], obj[this.id], keypath);
    },
    unobserve: function(obj, keypath, callback) {
      var callbacks, idx, map;
      if (map = this.weakmap[obj[this.id]]) {
        if (callbacks = map.callbacks[keypath]) {
          if ((idx = callbacks.indexOf(callback)) >= 0) {
            callbacks.splice(idx, 1);
            if (!callbacks.length) {
              delete map.callbacks[keypath];
            }
          }
          this.unobserveMutations(obj[keypath], obj[this.id], keypath);
          return this.cleanupWeakReference(map, obj[this.id]);
        }
      }
    },
    get: function(obj, keypath) {
      return obj[keypath];
    },
    set: function(obj, keypath, value) {
      return obj[keypath] = value;
    }
  };

  Rivets.factory = function(sightglass) {
    Rivets.sightglass = sightglass;
    Rivets["public"]._ = Rivets;
    return Rivets["public"];
  };

  if (typeof (typeof module !== "undefined" && module !== null ? module.exports : void 0) === 'object') {
    module.exports = Rivets.factory(require('sightglass'));
  } else if (typeof define === 'function' && define.amd) {
    define(['sightglass'], function(sightglass) {
      return this.rivets = Rivets.factory(sightglass);
    });
  } else {
    this.rivets = Rivets.factory(sightglass);
  }

}).call(this);

(function() {
  var $document, Cart, CartJS, Item, processing, queue,
    __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

  Cart = (function() {
    function Cart() {
      this.update = __bind(this.update, this);
    }

    Cart.prototype.update = function(cart) {
      var item, key, value;
      for (key in cart) {
        value = cart[key];
        if (key !== 'items') {
          this[key] = value;
        }
      }
      return this.items = (function() {
        var _i, _len, _ref, _results;
        _ref = cart.items;
        _results = [];
        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
          item = _ref[_i];
          _results.push(new Item(item));
        }
        return _results;
      })();
    };

    return Cart;

  })();

  Item = (function() {
    function Item(item) {
      this.propertyArray = __bind(this.propertyArray, this);
      this.update = __bind(this.update, this);
      this.update(item);
    }

    Item.prototype.update = function(item) {
      var key, value;
      for (key in item) {
        value = item[key];
        if (key !== 'properties') {
          this[key] = value;
        }
      }
      return this.properties = CartJS.Utils.extend({}, item.properties);
    };

    Item.prototype.propertyArray = function() {
      var name, value, _ref, _results;
      _ref = this.properties;
      _results = [];
      for (name in _ref) {
        value = _ref[name];
        _results.push({
          name: name,
          value: value
        });
      }
      return _results;
    };

    return Item;

  })();

  CartJS = {
    settings: {
      debug: false,
      dataAPI: true,
      requestBodyClass: null,
      rivetsModels: {},
      currency: null,
      moneyFormat: null,
      moneyWithCurrencyFormat: null,
      weightUnit: 'g',
      weightPrecision: 0
    },
    cart: new Cart()
  };

  CartJS.init = function(cart, settings) {
    if (settings == null) {
      settings = {};
    }
    CartJS.configure(settings);
    CartJS.Utils.log('Initialising CartJS.');
    CartJS.cart.update(cart);
    if (CartJS.settings.dataAPI) {
      CartJS.Utils.log('"dataAPI" setting is true, initialising Data API.');
      CartJS.Data.init();
    }
    if (CartJS.settings.requestBodyClass) {
      CartJS.Utils.log('"requestBodyClass" set, adding event listeners.');
      jQuery(document).on('cart.requestStarted', function() {
        return jQuery('body').addClass(CartJS.settings.requestBodyClass);
      });
      jQuery(document).on('cart.requestComplete', function() {
        return jQuery('body').removeClass(CartJS.settings.requestBodyClass);
      });
    }
    CartJS.Rivets.init();
    return jQuery(document).trigger('cart.ready', [CartJS.cart]);
  };

  CartJS.configure = function(settings) {
    if (settings == null) {
      settings = {};
    }
    return CartJS.Utils.extend(CartJS.settings, settings);
  };

  if (window.console == null) {
    window.console = {};
    window.console.log = function() {};
  }

  CartJS.Utils = {
    log: function() {
      return CartJS.Utils.console(console.log, arguments);
    },
    error: function() {
      return CartJS.Utils.console(console.error, arguments);
    },
    console: function(method, args) {
      if (CartJS.settings.debug && (typeof console !== "undefined" && console !== null)) {
        args = Array.prototype.slice.call(args);
        args.unshift('[CartJS]:');
        return method.apply(console, args);
      }
    },
    wrapKeys: function(obj, type, override) {
      var key, value, wrapped;
      if (type == null) {
        type = 'properties';
      }
      wrapped = {};
      for (key in obj) {
        value = obj[key];
        wrapped["" + type + "[" + key + "]"] = override != null ? override : value;
      }
      return wrapped;
    },
    unwrapKeys: function(obj, type, override) {
      var key, unwrapped, unwrappedKey, value;
      if (type == null) {
        type = 'properties';
      }
      unwrapped = {};
      for (key in obj) {
        value = obj[key];
        unwrappedKey = key.replace("" + type + "[", "").replace("]", "");
        unwrapped[unwrappedKey] = override != null ? override : value;
      }
      return unwrapped;
    },
    extend: function(object, properties) {
      var key, val;
      for (key in properties) {
        val = properties[key];
        object[key] = val;
      }
      return object;
    },
    clone: function(object) {
      var key, newInstance;
      if ((object == null) || typeof object !== 'object') {
        return object;
      }
      newInstance = new object.constructor();
      for (key in object) {
        newInstance[key] = clone(object[key]);
      }
      return newInstance;
    },
    isArray: Array.isArray || function(value) {
      return {}.toString.call(value) === '[object Array]';
    },
    ensureArray: function(value) {
      if (CartJS.Utils.isArray(value)) {
        return value;
      }
      if (value != null) {
        return [value];
      } else {
        return [];
      }
    },
    formatMoney: function(value, format, formatName, currency) {
      var _ref, _ref1;
      if (currency == null) {
        currency = '';
      }
      if (!currency) {
        currency = CartJS.settings.currency;
      }
      if ((window.Currency != null) && currency !== CartJS.settings.currency) {
        value = Currency.convert(value, CartJS.settings.currency, currency);
        if ((((_ref = window.Currency) != null ? _ref.moneyFormats : void 0) != null) && (currency in window.Currency.moneyFormats)) {
          format = window.Currency.moneyFormats[currency][formatName];
        }
      }
      if (((_ref1 = window.Shopify) != null ? _ref1.formatMoney : void 0) != null) {
        return Shopify.formatMoney(value, format);
      } else {
        return value;
      }
    },
    getSizedImageUrl: function(src, size) {
      var _ref, _ref1;
      if (((_ref = window.Shopify) != null ? (_ref1 = _ref.Image) != null ? _ref1.getSizedImageUrl : void 0 : void 0) != null) {
        if (src) {
          return Shopify.Image.getSizedImageUrl(src, size);
        } else {
          return Shopify.Image.getSizedImageUrl('https://cdn.shopify.com/s/images/admin/no-image-.gif', size).replace('-_', '-');
        }
      } else {
        if (src) {
          return src;
        } else {
          return 'https://cdn.shopify.com/s/images/admin/no-image-large.gif';
        }
      }
    }
  };

  queue = [];

  processing = false;

  CartJS.Queue = {
    add: function(url, data, options) {
      var request;
      if (options == null) {
        options = {};
      }
      request = {
        url: url,
        data: data,
        type: options.type || 'POST',
        dataType: options.dataType || 'json',
        success: CartJS.Utils.ensureArray(options.success),
        error: CartJS.Utils.ensureArray(options.error),
        complete: CartJS.Utils.ensureArray(options.complete)
      };
      if (options.updateCart) {
        request.success.push(CartJS.cart.update);
      }
      queue.push(request);
      if (processing) {
        return;
      }
      jQuery(document).trigger('cart.requestStarted', [CartJS.cart]);
      return CartJS.Queue.process();
    },
    process: function() {
      var params;
      if (!queue.length) {
        processing = false;
        jQuery(document).trigger('cart.requestComplete', [CartJS.cart]);
        return;
      }
      processing = true;
      params = queue.shift();
      params.complete = CartJS.Queue.process;
      return jQuery.ajax(params);
    }
  };

  CartJS.Core = {
    getCart: function(options) {
      if (options == null) {
        options = {};
      }
      options.type = 'GET';
      options.updateCart = true;
      return CartJS.Queue.add('/cart.js', {}, options);
    },
    addItem: function(id, quantity, properties, options) {
      var data;
      if (quantity == null) {
        quantity = 1;
      }
      if (properties == null) {
        properties = {};
      }
      if (options == null) {
        options = {};
      }
      data = CartJS.Utils.wrapKeys(properties);
      data.id = id;
      data.quantity = quantity;
      CartJS.Queue.add('/cart/add.js', data, options);
      return CartJS.Core.getCart();
    },
    updateItem: function(line, quantity, properties, options) {
      var data;
      if (properties == null) {
        properties = {};
      }
      if (options == null) {
        options = {};
      }
      data = CartJS.Utils.wrapKeys(properties);
      data.line = line;
      if (quantity != null) {
        data.quantity = quantity;
      }
      options.updateCart = true;
      return CartJS.Queue.add('/cart/change.js', data, options);
    },
    removeItem: function(line, options) {
      if (options == null) {
        options = {};
      }
      return CartJS.Core.updateItem(line, 0, {}, options);
    },
    updateItemById: function(id, quantity, properties, options) {
      var data;
      if (properties == null) {
        properties = {};
      }
      if (options == null) {
        options = {};
      }
      data = CartJS.Utils.wrapKeys(properties);
      data.id = id;
      if (quantity != null) {
        data.quantity = quantity;
      }
      options.updateCart = true;
      return CartJS.Queue.add('/cart/change.js', data, options);
    },
    updateItemQuantitiesById: function(updates, options) {
      if (updates == null) {
        updates = {};
      }
      if (options == null) {
        options = {};
      }
      options.updateCart = true;
      return CartJS.Queue.add('/cart/update.js', {
        updates: updates
      }, options);
    },
    removeItemById: function(id, options) {
      var data;
      if (options == null) {
        options = {};
      }
      data = {
        id: id,
        quantity: 0
      };
      options.updateCart = true;
      return CartJS.Queue.add('/cart/change.js', data, options);
    },
    clear: function(options) {
      if (options == null) {
        options = {};
      }
      options.updateCart = true;
      return CartJS.Queue.add('/cart/clear.js', {}, options);
    },
    getAttribute: function(attributeName, defaultValue) {
      if (attributeName in CartJS.cart.attributes) {
        return CartJS.cart.attributes[attributeName];
      } else {
        return defaultValue;
      }
    },
    setAttribute: function(attributeName, value, options) {
      var attributes;
      if (options == null) {
        options = {};
      }
      attributes = {};
      attributes[attributeName] = value;
      return CartJS.Core.setAttributes(attributes, options);
    },
    getAttributes: function() {
      return CartJS.cart.attributes;
    },
    setAttributes: function(attributes, options) {
      if (attributes == null) {
        attributes = {};
      }
      if (options == null) {
        options = {};
      }
      options.updateCart = true;
      return CartJS.Queue.add('/cart/update.js', CartJS.Utils.wrapKeys(attributes, 'attributes'), options);
    },
    clearAttributes: function(options) {
      if (options == null) {
        options = {};
      }
      options.updateCart = true;
      return CartJS.Queue.add('/cart/update.js', CartJS.Utils.wrapKeys(CartJS.Core.getAttributes(), 'attributes', ''), options);
    },
    getNote: function() {
      return CartJS.cart.note;
    },
    setNote: function(note, options) {
      if (options == null) {
        options = {};
      }
      options.updateCart = true;
      return CartJS.Queue.add('/cart/update.js', {
        note: note
      }, options);
    }
  };

  $document = null;

  CartJS.Data = {
    init: function() {
      $document = jQuery(document);
      CartJS.Data.setEventListeners('on');
      return CartJS.Data.render(null, CartJS.cart);
    },
    destroy: function() {
      return CartJS.Data.setEventListeners('off');
    },
    setEventListeners: function(method) {
      $document[method]('click', '[data-cart-add]', CartJS.Data.add);
      $document[method]('click', '[data-cart-remove]', CartJS.Data.remove);
      $document[method]('click', '[data-cart-remove-id]', CartJS.Data.removeById);
      $document[method]('click', '[data-cart-update]', CartJS.Data.update);
      $document[method]('click', '[data-cart-update-id]', CartJS.Data.updateById);
      $document[method]('click', '[data-cart-clear]', CartJS.Data.clear);
      $document[method]('change', '[data-cart-toggle]', CartJS.Data.toggle);
      $document[method]('change', '[data-cart-toggle-attribute]', CartJS.Data.toggleAttribute);
      $document[method]('submit', '[data-cart-submit]', CartJS.Data.submit);
      return $document[method]('cart.requestComplete', CartJS.Data.render);
    },
    add: function(e) {
      var $this;
      e.preventDefault();
      $this = jQuery(this);
      return CartJS.Core.addItem($this.attr('data-cart-add'), $this.attr('data-cart-quantity'));
    },
    remove: function(e) {
      var $this;
      e.preventDefault();
      $this = jQuery(this);
      return CartJS.Core.removeItem($this.attr('data-cart-remove'));
    },
    removeById: function(e) {
      var $this;
      e.preventDefault();
      $this = jQuery(this);
      return CartJS.Core.removeItemById($this.attr('data-cart-remove-id'));
    },
    update: function(e) {
      var $this;
      e.preventDefault();
      $this = jQuery(this);
      return CartJS.Core.updateItem($this.attr('data-cart-update'), $this.attr('data-cart-quantity'));
    },
    updateById: function(e) {
      var $this;
      e.preventDefault();
      $this = jQuery(this);
      return CartJS.Core.updateItemById($this.attr('data-cart-update-id'), $this.attr('data-cart-quantity'));
    },
    clear: function(e) {
      e.preventDefault();
      return CartJS.Core.clear();
    },
    toggle: function(e) {
      var $input, id;
      $input = jQuery(this);
      id = $input.attr('data-cart-toggle');
      if ($input.is(':checked')) {
        return CartJS.Core.addItem(id);
      } else {
        return CartJS.Core.removeItemById(id);
      }
    },
    toggleAttribute: function(e) {
      var $input, attribute;
      $input = jQuery(this);
      attribute = $input.attr('data-cart-toggle-attribute');
      return CartJS.Core.setAttribute(attribute, $input.is(':checked') ? 'Yes' : '');
    },
    submit: function(e) {
      var dataArray, id, properties, quantity;
      e.preventDefault();
      dataArray = jQuery(this).serializeArray();
      id = void 0;
      quantity = void 0;
      properties = {};
      jQuery.each(dataArray, function(i, item) {
        if (item.name === 'id') {
          return id = item.value;
        } else if (item.name === 'quantity') {
          return quantity = item.value;
        } else {
          return properties[item.name] = item.value;
        }
      });
      return CartJS.Core.addItem(id, quantity, CartJS.Utils.unwrapKeys(properties));
    },
    render: function(e, cart) {
      var context;
      context = {
        'item_count': cart.item_count,
        'total_price': cart.total_price,
        'total_price_money': CartJS.Utils.formatMoney(cart.total_price, CartJS.settings.moneyFormat, 'money_format', (typeof Currency !== "undefined" && Currency !== null ? Currency.currentCurrency : void 0) != null ? Currency.currentCurrency : void 0),
        'total_price_money_with_currency': CartJS.Utils.formatMoney(cart.total_price, CartJS.settings.moneyWithCurrencyFormat, 'money_with_currency_format', (typeof Currency !== "undefined" && Currency !== null ? Currency.currentCurrency : void 0) != null ? Currency.currentCurrency : void 0)
      };
      return jQuery('[data-cart-render]').each(function() {
        var $this;
        $this = jQuery(this);
        return $this.html(context[$this.attr('data-cart-render')]);
      });
    }
  };

  if ('rivets' in window) {
    CartJS.Rivets = {
      model: null,
      boundViews: [],
      init: function() {
        return CartJS.Rivets.bindViews();
      },
      destroy: function() {
        return CartJS.Rivets.unbindViews();
      },
      bindViews: function() {
        CartJS.Utils.log('Rivets.js is present, binding views.');
        CartJS.Rivets.unbindViews();
        CartJS.Rivets.model = CartJS.Utils.extend({
          cart: CartJS.cart
        }, CartJS.settings.rivetsModels);
        if (window.Currency != null) {
          CartJS.Rivets.model.Currency = window.Currency;
        }
        return jQuery('[data-cart-view]').each(function() {
          var view;
          view = rivets.bind(jQuery(this), CartJS.Rivets.model);
          return CartJS.Rivets.boundViews.push(view);
        });
      },
      unbindViews: function() {
        var view, _i, _len, _ref;
        _ref = CartJS.Rivets.boundViews;
        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
          view = _ref[_i];
          view.unbind();
        }
        return CartJS.Rivets.boundViews = [];
      }
    };
    rivets.formatters.eq = function(a, b) {
      return a === b;
    };
    rivets.formatters.includes = function(a, b) {
      return a.indexOf(b) >= 0;
    };
    rivets.formatters.match = function(a, regexp, flags) {
      return a.match(new RegExp(regexp, flags));
    };
    rivets.formatters.lt = function(a, b) {
      return a < b;
    };
    rivets.formatters.gt = function(a, b) {
      return a > b;
    };
    rivets.formatters.not = function(a) {
      return !a;
    };
    rivets.formatters.empty = function(a) {
      return !a.length;
    };
    rivets.formatters.plus = function(a, b) {
      return parseInt(a) + parseInt(b);
    };
    rivets.formatters.minus = function(a, b) {
      return parseInt(a) - parseInt(b);
    };
    rivets.formatters.prepend = function(a, b) {
      return b + a;
    };
    rivets.formatters.append = function(a, b) {
      return a + b;
    };
    rivets.formatters.slice = function(value, start, end) {
      return value.slice(start, end);
    };
    rivets.formatters.pluralize = function(input, singular, plural) {
      if (plural == null) {
        plural = singular + 's';
      }
      if (CartJS.Utils.isArray(input)) {
        input = input.length;
      }
      if (input === 1) {
        return singular;
      } else {
        return plural;
      }
    };
    rivets.formatters.array_element = function(array, index) {
      return array[index];
    };
    rivets.formatters.array_first = function(array) {
      return array[0];
    };
    rivets.formatters.array_last = function(array) {
      return array[array.length - 1];
    };
    rivets.formatters.money = function(value, currency) {
      return CartJS.Utils.formatMoney(value, CartJS.settings.moneyFormat, 'money_format', currency);
    };
    rivets.formatters.money_with_currency = function(value, currency) {
      return CartJS.Utils.formatMoney(value, CartJS.settings.moneyWithCurrencyFormat, 'money_with_currency_format', currency);
    };
    rivets.formatters.weight = function(grams) {
      switch (CartJS.settings.weightUnit) {
        case 'kg':
          return (grams / 1000).toFixed(CartJS.settings.weightPrecision);
        case 'oz':
          return (grams * 0.035274).toFixed(CartJS.settings.weightPrecision);
        case 'lb':
          return (grams * 0.00220462).toFixed(CartJS.settings.weightPrecision);
        default:
          return grams.toFixed(CartJS.settings.weightPrecision);
      }
    };
    rivets.formatters.weight_with_unit = function(grams) {
      return rivets.formatters.weight(grams) + CartJS.settings.weightUnit;
    };
    rivets.formatters.product_image_size = function(src, size) {
      return CartJS.Utils.getSizedImageUrl(src, size);
    };
    rivets.formatters.moneyWithCurrency = rivets.formatters.money_with_currency;
    rivets.formatters.weightWithUnit = rivets.formatters.weight_with_unit;
    rivets.formatters.productImageSize = rivets.formatters.product_image_size;
  } else {
    CartJS.Rivets = {
      init: function() {},
      destroy: function() {}
    };
  }

  CartJS.factory = function(exports) {
    exports.init = CartJS.init;
    exports.configure = CartJS.configure;
    exports.cart = CartJS.cart;
    exports.settings = CartJS.settings;
    exports.getCart = CartJS.Core.getCart;
    exports.addItem = CartJS.Core.addItem;
    exports.updateItem = CartJS.Core.updateItem;
    exports.updateItemById = CartJS.Core.updateItemById;
    exports.updateItemQuantitiesById = CartJS.Core.updateItemQuantitiesById;
    exports.removeItem = CartJS.Core.removeItem;
    exports.removeItemById = CartJS.Core.removeItemById;
    exports.clear = CartJS.Core.clear;
    exports.getAttribute = CartJS.Core.getAttribute;
    exports.setAttribute = CartJS.Core.setAttribute;
    exports.getAttributes = CartJS.Core.getAttributes;
    exports.setAttributes = CartJS.Core.setAttributes;
    exports.clearAttributes = CartJS.Core.clearAttributes;
    exports.getNote = CartJS.Core.getNote;
    exports.setNote = CartJS.Core.setNote;
    return exports.render = CartJS.Data.render;
  };

  if (typeof exports === 'object') {
    CartJS.factory(exports);
  } else if (typeof define === 'function' && define.amd) {
    define(['exports'], function(exports) {
      CartJS.factory(this.CartJS = exports);
      return exports;
    });
  } else {
    CartJS.factory(this.CartJS = {});
  }

}).call(this);


text:
require 'uri'

class LatersController < ApplicationController
  load_and_authorize_resource :user
  before_action :check_accounts
  # skip_authorization_check :only => [:new, :test]
  # skip_before_action :authenticate_user!, :only => [:new, :test]
  # before_action :add_allow_credentials_headers, :only =>  [:new, :test]

  def test
    render json: {response: 'Success', email: params, message: 'Good job'}
  end

  def index
    @laters = Later.where(account_id: @account.id)
  end

  def old_index
    if @current_user.account_id.nil?
      flash[:notice] = 'Please follow the instructions below to install'
      redirect_to install_path
    end

    @laters = Later.where(account_id: @current_user.account_id).where('destined_at < ?', Time.now).order(destined_at: :asc)
  end

  def settings

  end

  def show
    @later = Later.find params[:id]
  end

  def update
    later_id = params[:laterid];
    ll = Later.where(id: later_id)
    if ll.count > 0
      email = params[:email]
      url = params[:url]
      renew = params[:renew]
      delay_param = params[:delay]
      if !delay_param.nil?
        destined = Chronic.parse('in ' + URI::decode(delay_param) )
      else
        destined = nil
      end
      output = "No good"
      if !email.nil? && !url.nil?

        uu = User.where(email: email)
        if uu.count == 0
          u = User.create(email: email, password: Faker::DizzleIpsum.words(4).join('!').first(20))
        else
          u = uu.first
        end

        ll = Later.where(url: url, user_id: u.id)
        if ll.count == 0
          l = Later.create(url: url, account_id: account_id, user_id: u.id, created_at: Time.now.utc)
        else
          ll.where('destined_at >= ?', Date.today).order(:destined_at)
          l = ll.first
          l.modified_at = Time.now.utc
        end

        if !destined.nil?
          if destined.future?
            l.destined_at = destined
          end
        else
          l.destined_at = Time.now.utc + 4.hours
        end
        if !renew.nil?
          l.has_sent = false
        end

        l.save
        output = {response: 'success', data: l}

        Later.delay.get_ograph_content(l.id)
      end

      redirect_to success_later_update_path
    else
      render json: {response: 'Error', message: 'The account ID is not recognized.', id: account_uid}
    end
  end

  def check_og_graph
    puts params
    url_string = params[:url]
    if url_string =~ URI::regexp
      open_graph = MetaInspector.new(url_string)
      render :json => {
        response: 'success',
        code: 200,
        open_graph: open_graph,
        param: url_string
      }
    else
      render :json => {
        response: 'failed',
        code: 400,
        param: url_string
      }
    end
  end

  # later/new { uid: 123, email: 123, url: 123, renew: 123, delay: 123 }
  def new
    @later = Later.new
  end

  def create
    later_params = params[:later]
    aa = @account
    puts aa.id
    if !aa.nil?
      account_id = aa.id
      email = later_params[:email]
      url = later_params[:url]
      delay_param = later_params[:destined_at]

      remind_user_id = RemindUser.create_email_if_needed(email)
      delay_date = RemindUser.scheduled_delay_time(delay_param)

      json_response = {response: 'Success', code: 200, message: 'Data was received.'}
    else
      json_response = {response: 'Success', code: 206, message: "Account ID #{uid} not found."}
    end

    @reminder = Later.new(account_id: account_id, user_id: remind_user_id, url: url, destined_at: delay_date)
    @reminder.save

    Later.delay.get_ograph_content(@reminder.id)

    respond_to do |format|
      if @reminder.save
        format.html { redirect_to laters_path, notice: 'Email template was successfully created.' }
        format.json { render json: json_response }
      else
        format.html { render :new }
        format.json { render json: json_response }
      end
    end
  end

end


text:
// Package install adds the node API group, making it available as
// an option to all of the API encoding/decoding machinery.
package install

import (
	"k8s.io/apimachinery/pkg/runtime"
	utilruntime "k8s.io/apimachinery/pkg/util/runtime"
	"k8s.io/kubernetes/pkg/api/legacyscheme"
	"k8s.io/kubernetes/pkg/apis/node"
	v1 "k8s.io/kubernetes/pkg/apis/node/v1"
	"k8s.io/kubernetes/pkg/apis/node/v1alpha1"
	"k8s.io/kubernetes/pkg/apis/node/v1beta1"
)

func init() {
	Install(legacyscheme.Scheme)
}

// Install registers the API group and adds types to a scheme
func Install(scheme *runtime.Scheme) {
	utilruntime.Must(node.AddToScheme(scheme))
	utilruntime.Must(v1alpha1.AddToScheme(scheme))
	utilruntime.Must(v1beta1.AddToScheme(scheme))
	utilruntime.Must(v1.AddToScheme(scheme))

	// TODO (SergeyKanzhelev): priority should change after 1.21. See https://github.com/kubernetes/kubernetes/pull/95718#discussion_r520969477
	// This is what controls the preferred serialization version. Add both v1beta1 and v1 here, and prefer v1beta1 over v1 until 1.21. See the comment on test/integration/etcd around serialized version.
	//
	// Details on why we can't advance the storage version for a release are at https://kubernetes.io/docs/reference/using-api/deprecation-policy/:
	//
	// > Rule #4b: The "preferred" API version and the "storage version" for a given group may not advance until after a release has been made that supports both the new version and the previous version
	utilruntime.Must(scheme.SetVersionPriority(v1beta1.SchemeGroupVersion, v1.SchemeGroupVersion))
}


text:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." name="MessageAgent" default="package" >

    <property name="name" value="MessageAgent" />
    <property file="${user.home}/${name}.properties"/>
    <property file="${user.home}/build.properties"/>
    <property name="config.filename" value="${user.name}.properties"/>
    <property file="${config.filename}"/>
    <property file="build.properties"/>

    <property name="project.base.dir" value="." />
    <property environment="env" />
    <property name="debuglevel" value="source,lines,vars" />
    <property file="build.properties" />
    <property name="src" value="${project.base.dir}/src" />
    <property name="resources" value="${project.base.dir}/resources" />
    <property name="test" value="${project.base.dir}/test" />
    <property name="build" value="${project.base.dir}/build" />
    <property name="project.lib" value="${project.base.dir}/lib" />
    <property name="war" value="${build}/war" />
    <property name="classes" value="${war}/WEB-INF/classes" />
    <property name="build.dir" location="build" />
    <property name="classes.dir" location="${build.dir}/classes" />
    <property name="resources.dir" location="resources" />
    <property name="dist" value="${project.base.dir}/dist" />

    <property name="hudson.url" value="jenkins.momentumsoftware.com:8080/" />

    <property name="dist.suffix" value="" />
    <property name="toughresources" value="TopStackResources${dist.suffix}" />
    <property name="toughresources.dir" value="${project.base.dir}/../${toughresources}"/>
    <import file="${toughresources.dir}/common.build.xml" />

    <!-- package from which to start: this one should work for any modern linux -->
    <property name="start.package" value="topstack-collectd-5.2.0-ubuntu12.04"/>

    <path id="project.classpath">
        <pathelement location="${classes.dir}"/>
    </path>

    <!-- general targets -->
    <target name="init">
        <mkdir dir="${build}" />
        <mkdir dir="${build}/exploded" />
        <gunzip src="package/${start.package}.tar.gz" dest="${build}"></gunzip>
        <echo message="Expanding build/${start.package}.tar into ${build}/exploded"/>
        <!-- Ant tar doesn't respect symlinks, so use OS tar -->
        <exec executable="tar" failonerror="true">
            <arg value="xf" />
            <arg value="${build}/${start.package}.tar" />
            <arg value="-C" />
            <arg value="${build}/exploded" />
        </exec>
	</target>

    <target name="copy.config" depends="init">
        <copy todir="${build}/exploded/collectd/etc" overwrite="true">
            <fileset dir="${resources}/etc">
            </fileset>
        </copy>
    </target>

    <target name="package" depends="init,copy.config">
        <!--
        <tar destfile="${build}/transcend-agent.tar.gz" compression="gzip">
            <tarfileset dir="${build}/exploded" filemode="755" username="root">
                <include name="collectd/sbin/*" />
                <include name="collectd/bin/*" />
            </tarfileset>
            <tarfileset dir="${build}/exploded" prefix="">
                <exclude name="collectd/sbin/*" />
                <exclude name="collectd/bin/*" />
            </tarfileset>
         </tar>
         -->
        <!-- Ant tar doesn't respect symlinks, so use OS tar -->
        <chmod dir="${build}/exploded" perm="ugo+rx" includes="collectd/sbin/*"/>
        <chmod dir="${build}/exploded" perm="ugo+rx" includes="collectd/bin/*"/>
        <exec executable="tar" failonerror="true">
            <arg value="czvf" />
            <arg value="${build}/transcend-agent.tar.gz" />
            <arg value="-C" />
            <arg value="${build}/exploded" />
            <arg value="collectd" />
        </exec>
    </target>

    <target name="dist" depends="package">
        <mkdir dir="${dist}"/>
        <move file="${build}/transcend-agent.tar.gz" tofile="${dist}/transcend-agent.tar.gz"/>
    </target>
</project>


text:
    <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" />
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5" />
    <title>Individual.xmax Field</title>
    <xml>
    </xml>
    <link rel="stylesheet" type="text/css" href="MSDN.css" />

            Multilayer Perzeptron and Learning Algorhims

Individual.xmax Field

public static readonly float xmax;

See Also

        Individual Class | MultilayerNet Namespace

      <object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e" viewastext="true" style="display: none;">
        <param name="Keyword" value="xmax field">
        </param>
        <param name="Keyword" value="xmax field, Individual class">
        </param>
        <param name="Keyword" value="Individual.xmax field">
        </param>
      </object>

          Send comments on this topic.

          (c) 2004 Rene Schulte and Torsten Baer


text:
angular.module('app').factory('theArea', function($http,appConfig,AccessToken,$rootScope,Area){

    return{

        getName:function(area){
            var deferred = $q.defer();
            console.log(area);
            console.log(appConfig);
            var k = Area.getSiteInfo(area.id);
            var name = "";
            k.then(function(info){
                area.greekLocalizedName     = (!$rootScope.isUndefined(info.data.greekLocalizedName)?info.data.greekLocalizedName:area.name);
                area.italianLocalizedName   = (!$rootScope.isUndefined(info.data.italianLocalizedName)?info.data.italianLocalizedName:area.name);
                area.swedishLocalizedName   = (!$rootScope.isUndefined(info.data.swedishLocalizedName)?info.data.swedishLocalizedName:area.name);
                area.englishLocalizedName   = (!$rootScope.isUndefined(info.data.englishLocalizedName)?info.data.englishLocalizedName:area.name);
                if($rootScope.lang=='el')
                    name = area.greekLocalizedName;
                else if ($rootScope.lang=='sw')
                    name = area.englishLocalizedName;
                else if ($rootScope.lang=='it')
                    name = area.italianLocalizedName;
                else
                    name = area.englishLocalizedName;
                deferred.resolve(name);

            },function(){
                deferred.reject('Greeting ' + name + ' is not allowed.');
            },function(){
                return deferred.promise;
            });

        }

    }

});


text:
<?php

defined("BASEPATH") or exit("No direct script access allowed");

class Pages_model extends CI_Model {

    var $id;
    var $title;
    var $keywords;
    var $description;
    var $page_data;
    var $date_time;
    var $is_published;
}


text:
<?php

/**
 * @author Petr Pliska <petr.pliska@post.cz>
 */

/**
 * Default settings
 * @see http://auraphp.com/packages/Aura.Router/defining-routes.html#2.2.1
 */
$map->tokens([
    // Allowed module prefixes are admin and api
    'module' => 'admin'
])->defaults([
    // Default module is web (without prefix)
    'module' => 'web',
    // No default controller
    'controller' => null,
    // Default action id "default"
    'action' => 'default',
    // No default id
    'id' => null,
]);

/**
 * homepage route
 */
$map->get('homepage', '/')->defaults([
    'controller' => 'index'
]);

/**
 * Cactch all routes
 * @see http://auraphp.com/packages/Aura.Router/other-topics.html#2.7.1
 */
$map->route('catchall', '{/module,controller,action,id}');
$map->route('web.catchall', '{/controller,action,id}');


text:
package org.shirdrn.smart.dag;

import java.util.Date;
import java.util.List;

@InterfaceAudience.Private
public abstract class DAGMetric extends AbstractNameableComponent<DAGMetric> {

	protected Date startDate;
	protected Date finishDate;
	protected long timeTaken;
	protected Status status = Status.INITIALIZATION;
	protected List<Throwable> causes;

	public DAGMetric() {
		super();
	}

	public DAGMetric(String name) {
		super(name);
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getFinishDate() {
		return finishDate;
	}

	public void setFinishDate(Date finishDate) {
		this.finishDate = finishDate;
	}

	public long getTimeTaken() {
		return timeTaken;
	}

	public void setTimeTaken(long timeTaken) {
		this.timeTaken = timeTaken;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public List<Throwable> getCauses() {
		return causes;
	}

	public void setCauses(List<Throwable> causes) {
		this.causes = causes;
	}

	public enum Status {
		INITIALIZATION,
		SUCCESS,
		FAILURE
	}
}


text:
//using OpenSim.Framework.Console;
using Nini.Config;
using OpenMetaverse;

namespace OpenSim.Framework
{
    public delegate void restart(RegionInfo thisRegion);

    /// <value>
    /// Indicate what action to take on an object derez request
    /// </value>
    public enum DeRezAction : byte
    {
        SaveToExistingUserInventoryItem = 0,
        TakeCopy = 1,
        Take = 4,
        GodTakeCopy = 5,
        Delete = 6,
        Return = 9
    };

    public enum RegionStatus : int
    {
        Down = 0,
        Up = 1,
        Crashed = 2,
        Starting = 3,
    };

    public interface IScene
    {
        event restart OnRestart;

        bool AllowScriptCrossings { get; }

        IConfigSource Config { get; }

        /// <summary>
        /// Are logins enabled on this simulator?
        /// </summary>
        bool LoginsEnabled { get; set; }

        /// <summary>
        /// The name of this scene.
        /// </summary>
        string Name { get; }

        /// <summary>
        /// Is this region ready for use?
        /// </summary>
        /// <remarks>
        /// This does not mean that logins are enabled, merely that they can be.
        /// </remarks>
        bool Ready { get; set; }

        RegionInfo RegionInfo { get; }

        RegionStatus RegionStatus { get; set; }

        float TimeDilation { get; }

        /// <summary>
        /// Add a new agent with an attached client.  All agents except initial login clients will starts off as a child agent
        /// - the later agent crossing will promote it to a root agent.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="type">The type of agent to add.</param>
        /// <returns>
        /// The scene agent if the new client was added or if an agent that already existed.</returns>
        ISceneAgent AddNewAgent(IClientAPI client, PresenceType type);

        bool CheckClient(UUID agentID, System.Net.IPEndPoint ep);

        /// <summary>
        /// Tell a single agent to disconnect from the region.
        /// </summary>
        /// <param name="agentID"></param>
        /// <param name="force">
        /// Force the agent to close even if it might be in the middle of some other operation.  You do not want to
        /// force unless you are absolutely sure that the agent is dead and a normal close is not working.
        /// </param>
        bool CloseAgent(UUID agentID, bool force);

        ISceneObject DeserializeObject(string representation);

        string GetSimulatorVersion();

        /// <summary>
        /// Register an interface to a region module.  This allows module methods to be called directly as
        /// well as via events.  If there is already a module registered for this interface, it is not replaced
        /// (is this the best behaviour?)
        /// </summary>
        /// <param name="mod"></param>
        void RegisterModuleInterface<M>(M mod);

        /// <summary>
        /// For the given interface, retrieve the region module which implements it.
        /// </summary>
        /// <returns>null if there is no registered module implementing that interface</returns>
        T RequestModuleInterface<T>();

        /// <summary>
        /// For the given interface, retrieve an array of region modules that implement it.
        /// </summary>
        /// <returns>an empty array if there are no registered modules implementing that interface</returns>
        T[] RequestModuleInterfaces<T>();

        void Restart();

        void StackModuleInterface<M>(M mod);

        //        void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback);
        /// <summary>
        /// Start the scene and associated scripts within it.
        /// </summary>
        void Start();

        bool TryGetScenePresence(UUID agentID, out object scenePresence);
    }
}