This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Public: Abstracts pagination into an Enumerator so all of the objects for | |
| # a given response can be retreived without having to know that they were | |
| # split into pages from the server | |
| # | |
| # Examples | |
| # | |
| # orders = client.get("orders", limit: 10) | |
| # | |
| # paged = PagedEnumerator.new(orders) do |response, yielder| | |
| # response.body["orders"].each do |obj| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define([], function() { | |
| /* | |
| Public: Returns the query string decoded as an Object | |
| queryArg - a String that is a query string. eg: "one=1&two=2&three" | |
| Returns an Object | |
| */ | |
| return function(queryArg) { | |
| var query = queryArg || window.location.search.substring(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| new RSVP.promise(function(resolve, reject) { | |
| var promise = new RSVP.promise(function(resovle, reject) { | |
| request({ | |
| dataType: 'json', | |
| url: window.ENV.prependHost + "/sa/api/v2/auth" | |
| }) | |
| .then(resolve) // if the first is a success, just resolve! | |
| .catch(function() { // not a success, trying again | |
| request({ | |
| dataType: 'json', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Dir.glob(File.join(%w(** *.rb))) do |filename| | |
| buffer = File.open(filename, "r").read | |
| File.open(filename, "w") do |output| | |
| output.puts buffer.gsub(/\r\n/, "\n") | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- mode: ruby -*- | |
| # vi: set ft=ruby : | |
| # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
| VAGRANTFILE_API_VERSION = "2" | |
| Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
| config.vm.box = "centos64" | |
| config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210.box" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| App.module "Data", (Data, App, Backbone, Marionette, $, _)-> | |
| class Data.IdentityMap | |
| constructor: (@collection, opts={})-> | |
| @promiseAll = false | |
| @promiseEach = {} | |
| if opts.fetch == false | |
| @promiseAll = $.Deferred() | |
| @promiseAll.resolve @collection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MutantCollection extends Backbone.Collection | |
| constructor: (collection, mutator, options = {})-> | |
| super(collection.map(mutator), options) | |
| @listenTo collection, 'reset', -> | |
| @reset collection.map(mutator) | |
| @listenTo collection, 'add', (model)-> | |
| @add mutator(model) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| App.module "Lib", (Lib, App, Backbone, Marionette, $, _)-> | |
| class Lib.EventRouter | |
| constructor: (opts = {})-> | |
| @events = _.extend(_.result(@, "events"), _.result(opts, "events")) | |
| @vent = _.result(opts, "vent") || _.result(@, "vent") | |
| @namespace = _.result(opts, "namespace") || _.result(@, "namespace") | |
| @controller = _.result(opts, "controller") || _.result(@, "controller") || @router.controller | |
| @event(name, route) for name, route of @events |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| App.module "Lib", (Lib, App, Backbone, Marionette, $, _)-> | |
| class Lib.ResourceAppRouter extends Marionette.AppRouter | |
| constructor: (opts = {})-> | |
| @resource = _.result(opts, "resource") || @resource || throw "A ResourceRouter needs a resource defined" | |
| delete opts.resource | |
| super(opts) | |
| @appRoute @resource , "index" | |
| @appRoute "@resource/new" , "new" | |
| @appRoute "#{@resource}/:id" , "show" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| App.module "Lib", (Lib, App, Backbone, Marionette, $, _)-> | |
| class Lib.ResourceEventRouter extends App.Lib.EventRouter | |
| constructor: (opts = {})-> | |
| @resource = _.result(opts, "resource") || _.result(@, "resource") | |
| opts.namespace = @resource | |
| opts.events ||= {} | |
| resourceEvents = | |
| index : @resource | |
| new : "#{@resource}/new" |
OlderNewer