ember-source 1.0.0.rc6 → 1.0.0.rc6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ember-source might be problematic. Click here for more details.

@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NzdiY2QxYjc4YThlZWVmZDE2NmI2ZjQwYTY5OTYyNzA4ZmIwYjljZQ==
5
+ data.tar.gz: !binary |-
6
+ MTI3NzZkNmE4YmU2ZTFlYzU5ZjQ0NmVlZWU2MjFhMTY0NGRiMzZmNA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ OTQ0YjBhY2M1ZmQ2YWY5ODk3NmFmZmJjMmQxMWQ4NTgzNTk2YTc5MTExY2Vk
10
+ NDMwZTkzZmVkZWVhNDA1NTcxMjU2Njc0YzQ1YjM2MjhhN2JmMDliNzU3MDE4
11
+ YzliZTYxNmM2YmNhYzZjMjY0MjBhY2YxOWVlNDk4OTYxOTYyMTQ=
12
+ data.tar.gz: !binary |-
13
+ YzdiMzIwM2UwOGYwMjhiZjdhZGU1YWQ2ODBlMWU1YjlhMzEzZTM5NDQ5YzAz
14
+ ZGQ1Njg5MTVhZjFmYzFkOWIyYjQ2NTBhNTk1ZGQ4NmZjMTBhZmNjNWQwMGUz
15
+ YTMyNzA4OWM0ODFkN2Q1N2QwZWYxYTYyZWRiNWY2MzMzNDhkMTE=
@@ -1,5 +1,5 @@
1
- // Version: v1.0.0-rc.6-1-g42f0c68
2
- // Last commit: 42f0c68 (2013-06-23 15:43:35 -0400)
1
+ // Version: v1.0.0-rc.6-56-g19271bc
2
+ // Last commit: 19271bc (2013-06-30 23:18:40 -0700)
3
3
 
4
4
 
5
5
  (function() {
@@ -156,8 +156,8 @@ Ember.deprecateFunc = function(message, func) {
156
156
 
157
157
  })();
158
158
 
159
- // Version: v1.0.0-rc.6-1-g42f0c68
160
- // Last commit: 42f0c68 (2013-06-23 15:43:35 -0400)
159
+ // Version: v1.0.0-rc.6-56-g19271bc
160
+ // Last commit: 19271bc (2013-06-30 23:18:40 -0700)
161
161
 
162
162
 
163
163
  (function() {
@@ -1198,9 +1198,9 @@ var needsFinallyFix = (function() {
1198
1198
  @for Ember
1199
1199
  @param {Function} tryable The function to run the try callback
1200
1200
  @param {Function} finalizer The function to run the finally callback
1201
- @param [binding]
1201
+ @param {Object} [binding] The optional calling object. Defaults to 'this'
1202
1202
  @return {*} The return value is the that of the finalizer,
1203
- unless that valueis undefined, in which case it is the return value
1203
+ unless that value is undefined, in which case it is the return value
1204
1204
  of the tryable
1205
1205
  */
1206
1206
 
@@ -1249,7 +1249,7 @@ if (needsFinallyFix) {
1249
1249
  @param {Function} tryable The function to run the try callback
1250
1250
  @param {Function} catchable The function to run the catchable callback
1251
1251
  @param {Function} finalizer The function to run the finally callback
1252
- @param [binding]
1252
+ @param {Object} [binding] The optional calling object. Defaults to 'this'
1253
1253
  @return {*} The return value is the that of the finalizer,
1254
1254
  unless that value is undefined, in which case it is the return value
1255
1255
  of the tryable.
@@ -7311,12 +7311,43 @@ define("container",
7311
7311
  [],
7312
7312
  function() {
7313
7313
 
7314
+ /**
7315
+ A safe and simple inheriting object.
7316
+
7317
+ @class InheritingDict
7318
+ */
7314
7319
  function InheritingDict(parent) {
7315
7320
  this.parent = parent;
7316
7321
  this.dict = {};
7317
7322
  }
7318
7323
 
7319
7324
  InheritingDict.prototype = {
7325
+
7326
+ /**
7327
+ @property parent
7328
+ @type InheritingDict
7329
+ @default null
7330
+ */
7331
+
7332
+ parent: null,
7333
+
7334
+ /**
7335
+ Object used to store the current nodes data.
7336
+
7337
+ @property dict
7338
+ @type Object
7339
+ @default Object
7340
+ */
7341
+ dict: null,
7342
+
7343
+ /**
7344
+ Retrieve the value given a key, if the value is present at the current
7345
+ level use it, otherwise walk up the parent hierarchy and try again. If
7346
+ no matching key is found, return undefined.
7347
+
7348
+ @method get
7349
+ @return {any}
7350
+ */
7320
7351
  get: function(key) {
7321
7352
  var dict = this.dict;
7322
7353
 
@@ -7329,10 +7360,26 @@ define("container",
7329
7360
  }
7330
7361
  },
7331
7362
 
7363
+ /**
7364
+ Set the given value for the given key, at the current level.
7365
+
7366
+ @method set
7367
+ @param {String} key
7368
+ @param {Any} value
7369
+ */
7332
7370
  set: function(key, value) {
7333
7371
  this.dict[key] = value;
7334
7372
  },
7335
7373
 
7374
+ /**
7375
+ Check for the existence of given a key, if the key is present at the current
7376
+ level return true, otherwise walk up the parent hierarchy and try again. If
7377
+ no matching key is found, return false.
7378
+
7379
+ @method has
7380
+ @param {String} key
7381
+ @returns {Boolean}
7382
+ */
7336
7383
  has: function(key) {
7337
7384
  var dict = this.dict;
7338
7385
 
@@ -7347,6 +7394,13 @@ define("container",
7347
7394
  return false;
7348
7395
  },
7349
7396
 
7397
+ /**
7398
+ Iterate and invoke a callback for each local key-value pair.
7399
+
7400
+ @method eachLocal
7401
+ @param {Function} callback
7402
+ @param {Object} binding
7403
+ */
7350
7404
  eachLocal: function(callback, binding) {
7351
7405
  var dict = this.dict;
7352
7406
 
@@ -7358,6 +7412,11 @@ define("container",
7358
7412
  }
7359
7413
  };
7360
7414
 
7415
+ /**
7416
+ A lightweight container that helps to assemble and decouple components.
7417
+
7418
+ @class Container
7419
+ */
7361
7420
  function Container(parent) {
7362
7421
  this.parent = parent;
7363
7422
  this.children = [];
@@ -7372,16 +7431,115 @@ define("container",
7372
7431
  }
7373
7432
 
7374
7433
  Container.prototype = {
7434
+
7435
+ /**
7436
+ @property parent
7437
+ @type Container
7438
+ @default null
7439
+ */
7440
+ parent: null,
7441
+
7442
+ /**
7443
+ @property children
7444
+ @type Array
7445
+ @default []
7446
+ */
7447
+ children: null,
7448
+
7449
+ /**
7450
+ @property resolver
7451
+ @type function
7452
+ */
7453
+ resolver: null,
7454
+
7455
+ /**
7456
+ @property registry
7457
+ @type InheritingDict
7458
+ */
7459
+ registry: null,
7460
+
7461
+ /**
7462
+ @property cache
7463
+ @type InheritingDict
7464
+ */
7465
+ cache: null,
7466
+
7467
+ /**
7468
+ @property typeInjections
7469
+ @type InheritingDict
7470
+ */
7471
+ typeInjections: null,
7472
+
7473
+ /**
7474
+ @property injections
7475
+ @type Object
7476
+ @default {}
7477
+ */
7478
+ injections: null,
7479
+
7480
+ /**
7481
+ @private
7482
+
7483
+ @property _options
7484
+ @type InheritingDict
7485
+ @default null
7486
+ */
7487
+ _options: null,
7488
+
7489
+ /**
7490
+ @private
7491
+
7492
+ @property _typeOptions
7493
+ @type InheritingDict
7494
+ */
7495
+ _typeOptions: null,
7496
+
7497
+ /**
7498
+ Returns a new child of the current container. These children are configured
7499
+ to correctly inherit from the current container.
7500
+
7501
+ @method child
7502
+ @returns {Container}
7503
+ */
7375
7504
  child: function() {
7376
7505
  var container = new Container(this);
7377
7506
  this.children.push(container);
7378
7507
  return container;
7379
7508
  },
7380
7509
 
7510
+ /**
7511
+ Sets a key-value pair on the current container. If a parent container,
7512
+ has the same key, once set on a child, the parent and child will diverge
7513
+ as expected.
7514
+
7515
+ @method set
7516
+ @param {Object} obkect
7517
+ @param {String} key
7518
+ @param {any} value
7519
+ */
7381
7520
  set: function(object, key, value) {
7382
7521
  object[key] = value;
7383
7522
  },
7384
7523
 
7524
+ /**
7525
+ Registers a factory for later injection.
7526
+
7527
+ Example:
7528
+
7529
+ ```javascript
7530
+ var container = new Container();
7531
+
7532
+ container.register('model:user', Person, {singleton: false });
7533
+ container.register('fruit:favorite', Orange);
7534
+ container.register('communication:main', Email, {singleton: false});
7535
+ ```
7536
+
7537
+ @method register
7538
+ @param {String} type
7539
+ @param {String} name
7540
+ @param {Function} factory
7541
+ @param {Object} options
7542
+ */
7385
7543
  register: function(type, name, factory, options) {
7386
7544
  var fullName;
7387
7545
 
@@ -7400,14 +7558,92 @@ define("container",
7400
7558
  this._options.set(normalizedName, options || {});
7401
7559
  },
7402
7560
 
7561
+ /**
7562
+ Given a fullName return the corresponding factory.
7563
+
7564
+ By default `resolve` will retreive the factory from
7565
+ it's containers registry.
7566
+
7567
+ ```javascript
7568
+ var container = new Container();
7569
+ container.register('api:twitter', Twitter);
7570
+
7571
+ container.resolve('api:twitter') // => Twitter
7572
+ ```
7573
+
7574
+ Optionally the container can be provided with a custom resolver.
7575
+ If provided, `resolve` will first provide the custom resolver
7576
+ the oppertunity to resolve the fullName, otherwise it will fallback
7577
+ to the registry.
7578
+
7579
+ ```javascript
7580
+ var container = new Container();
7581
+ container.resolver = function(fullName) {
7582
+ // lookup via the module system of choice
7583
+ };
7584
+
7585
+ // the twitter factory is added to the module system
7586
+ container.resolve('api:twitter') // => Twitter
7587
+ ```
7588
+
7589
+ @method resolve
7590
+ @param {String} fullName
7591
+ @returns {Function} fullName's factory
7592
+ */
7403
7593
  resolve: function(fullName) {
7404
7594
  return this.resolver(fullName) || this.registry.get(fullName);
7405
7595
  },
7406
7596
 
7597
+ /**
7598
+ A hook to enable custom fullName normalization behaviour
7599
+
7600
+ @method normalize
7601
+ @param {String} fullName
7602
+ @return {string} normalized fullName
7603
+ */
7407
7604
  normalize: function(fullName) {
7408
7605
  return fullName;
7409
7606
  },
7410
7607
 
7608
+ /**
7609
+ Given a fullName return a corresponding instance.
7610
+
7611
+ The default behaviour is for lookup to return a singleton instance.
7612
+ The singleton is scoped to the container, allowing multiple containers
7613
+ to all have there own locally scoped singletons.
7614
+
7615
+ ```javascript
7616
+ var container = new Container();
7617
+ container.register('api:twitter', Twitter);
7618
+
7619
+ var twitter = container.lookup('api:twitter');
7620
+
7621
+ twitter instanceof Twitter; // => true
7622
+
7623
+ // by default the container will return singletons
7624
+ twitter2 = container.lookup('api:twitter');
7625
+ twitter instanceof Twitter; // => true
7626
+
7627
+ twitter === twitter2; //=> true
7628
+ ```
7629
+
7630
+ If singletons are not wanted an optional flag can be provided at lookup.
7631
+
7632
+ ```javascript
7633
+ var container = new Container();
7634
+ container.register('api:twitter', Twitter);
7635
+
7636
+ var twitter = container.lookup('api:twitter', { singleton: false });
7637
+ var twitter2 = container.lookup('api:twitter', { singleton: false });
7638
+
7639
+ twitter === twitter2; //=> false
7640
+ ```
7641
+
7642
+ @method lookup
7643
+ @param {String} fullName
7644
+ @param {Object} options
7645
+ @return {any}
7646
+ */
7411
7647
  lookup: function(fullName, options) {
7412
7648
  fullName = this.normalize(fullName);
7413
7649
 
@@ -7428,10 +7664,25 @@ define("container",
7428
7664
  return value;
7429
7665
  },
7430
7666
 
7667
+ /**
7668
+ Given a fullName return the corresponding factory.
7669
+
7670
+ @method lookupFactory
7671
+ @param {String} fullName
7672
+ @return {any}
7673
+ */
7431
7674
  lookupFactory: function(fullName) {
7432
7675
  return factoryFor(this, fullName);
7433
7676
  },
7434
7677
 
7678
+ /**
7679
+ Given a fullName check if the container is aware of its factory
7680
+ or singleton instance.
7681
+
7682
+ @method has
7683
+ @param {String} fullName
7684
+ @return {Boolean}
7685
+ */
7435
7686
  has: function(fullName) {
7436
7687
  if (this.cache.has(fullName)) {
7437
7688
  return true;
@@ -7440,27 +7691,144 @@ define("container",
7440
7691
  return !!factoryFor(this, fullName);
7441
7692
  },
7442
7693
 
7694
+ /**
7695
+ Allow registerying options for all factories of a type.
7696
+
7697
+ ```javascript
7698
+ var container = new Container();
7699
+
7700
+ // if all of type `connection` must not be singletons
7701
+ container.optionsForType('connection', { singleton: false });
7702
+
7703
+ container.register('connection:twitter', TwitterConnection);
7704
+ container.register('connection:facebook', FacebookConnection);
7705
+
7706
+ var twitter = container.lookup('connection:twitter');
7707
+ var twitter2 = container.lookup('connection:twitter');
7708
+
7709
+ twitter === twitter2; // => false
7710
+
7711
+ var facebook = container.lookup('connection:facebook');
7712
+ var facebook2 = container.lookup('connection:facebook');
7713
+
7714
+ facebook === facebook2; // => false
7715
+ ```
7716
+
7717
+ @method optionsForType
7718
+ @param {String} type
7719
+ @param {Object} options
7720
+ */
7443
7721
  optionsForType: function(type, options) {
7444
7722
  if (this.parent) { illegalChildOperation('optionsForType'); }
7445
7723
 
7446
7724
  this._typeOptions.set(type, options);
7447
7725
  },
7448
7726
 
7727
+ /**
7728
+ @method options
7729
+ @param {String} type
7730
+ @param {Object} options
7731
+ */
7449
7732
  options: function(type, options) {
7450
7733
  this.optionsForType(type, options);
7451
7734
  },
7452
7735
 
7736
+ /*
7737
+ @private
7738
+
7739
+ Used only via `injection`.
7740
+
7741
+ Provides a specialized form of injection, specifically enabling
7742
+ all objects of one type to be injected with a reference to another
7743
+ object.
7744
+
7745
+ For example, provided each object of type `controller` needed a `router`.
7746
+ one would do the following:
7747
+
7748
+ ```javascript
7749
+ var container = new Container();
7750
+
7751
+ container.register('router:main', Router);
7752
+ container.register('controller:user', UserController);
7753
+ container.register('controller:post', PostController);
7754
+
7755
+ container.typeInjection('controller', 'router', 'router:main');
7756
+
7757
+ var user = container.lookup('controller:user');
7758
+ var post = container.lookup('controller:post');
7759
+
7760
+ user.router instanceof Router; //=> true
7761
+ post.router instanceof Router; //=> true
7762
+
7763
+ // both controllers share the same router
7764
+ user.router === post.router; //=> true
7765
+ ```
7766
+
7767
+ @method typeInjection
7768
+ @param {String} type
7769
+ @param {String} property
7770
+ @param {String} fullName
7771
+ */
7453
7772
  typeInjection: function(type, property, fullName) {
7454
7773
  if (this.parent) { illegalChildOperation('typeInjection'); }
7455
7774
 
7456
7775
  var injections = this.typeInjections.get(type);
7776
+
7457
7777
  if (!injections) {
7458
7778
  injections = [];
7459
7779
  this.typeInjections.set(type, injections);
7460
7780
  }
7461
- injections.push({ property: property, fullName: fullName });
7781
+
7782
+ injections.push({
7783
+ property: property,
7784
+ fullName: fullName
7785
+ });
7462
7786
  },
7463
7787
 
7788
+ /*
7789
+ Defines injection rules.
7790
+
7791
+ These rules are used to inject dependencies onto objects when they
7792
+ are instantiated.
7793
+
7794
+ Two forms of injections are possible:
7795
+
7796
+ * Injecting one fullName on another fullName
7797
+ * Injecting one fullName on a type
7798
+
7799
+ Example:
7800
+
7801
+ ```javascript
7802
+ var container = new Container();
7803
+
7804
+ container.register('source:main', Source);
7805
+ container.register('model:user', User);
7806
+ container.register('model:post', PostController);
7807
+
7808
+ // injecting one fullName on another fullName
7809
+ // eg. each user model gets a post model
7810
+ container.injection('model:user', 'post', 'model:post');
7811
+
7812
+ // injecting one fullName on another type
7813
+ container.injection('model', 'source', 'source:main');
7814
+
7815
+ var user = container.lookup('model:user');
7816
+ var post = container.lookup('model:post');
7817
+
7818
+ user.source instanceof Source; //=> true
7819
+ post.source instanceof Source; //=> true
7820
+
7821
+ user.post instanceof Post; //=> true
7822
+
7823
+ // and both models share the same source
7824
+ user.source === post.source; //=> true
7825
+ ```
7826
+
7827
+ @method injection
7828
+ @param {String} factoryName
7829
+ @param {String} property
7830
+ @param {String} injectionName
7831
+ */
7464
7832
  injection: function(factoryName, property, injectionName) {
7465
7833
  if (this.parent) { illegalChildOperation('injection'); }
7466
7834
 
@@ -7472,6 +7840,12 @@ define("container",
7472
7840
  injections.push({ property: property, fullName: injectionName });
7473
7841
  },
7474
7842
 
7843
+ /**
7844
+ A depth first traversal, destroying the container, its descendant containers and all
7845
+ their managed objects.
7846
+
7847
+ @method destroy
7848
+ */
7475
7849
  destroy: function() {
7476
7850
  this.isDestroyed = true;
7477
7851
 
@@ -7489,6 +7863,9 @@ define("container",
7489
7863
  this.isDestroyed = true;
7490
7864
  },
7491
7865
 
7866
+ /**
7867
+ @method reset
7868
+ */
7492
7869
  reset: function() {
7493
7870
  for (var i=0, l=this.children.length; i<l; i++) {
7494
7871
  resetCache(this.children[i]);
@@ -7517,7 +7894,12 @@ define("container",
7517
7894
  for (var i=0, l=injections.length; i<l; i++) {
7518
7895
  injection = injections[i];
7519
7896
  lookup = container.lookup(injection.fullName);
7520
- hash[injection.property] = lookup;
7897
+
7898
+ if (lookup) {
7899
+ hash[injection.property] = lookup;
7900
+ } else {
7901
+ throw new Error('Attempting to inject an unknown injection: `' + injection.fullName + '`');
7902
+ }
7521
7903
  }
7522
7904
 
7523
7905
  return hash;
@@ -8706,7 +9088,7 @@ Ember.Enumerable = Ember.Mixin.create({
8706
9088
  @return {Array} The mapped array.
8707
9089
  */
8708
9090
  map: function(callback, target) {
8709
- var ret = Ember.A([]);
9091
+ var ret = Ember.A();
8710
9092
  this.forEach(function(x, idx, i) {
8711
9093
  ret[idx] = callback.call(target, x, idx,i);
8712
9094
  });
@@ -8756,7 +9138,7 @@ Ember.Enumerable = Ember.Mixin.create({
8756
9138
  @return {Array} A filtered array.
8757
9139
  */
8758
9140
  filter: function(callback, target) {
8759
- var ret = Ember.A([]);
9141
+ var ret = Ember.A();
8760
9142
  this.forEach(function(x, idx, i) {
8761
9143
  if (callback.call(target, x, idx, i)) ret.push(x);
8762
9144
  });
@@ -9045,7 +9427,7 @@ Ember.Enumerable = Ember.Mixin.create({
9045
9427
  @return {Array} return values from calling invoke.
9046
9428
  */
9047
9429
  invoke: function(methodName) {
9048
- var args, ret = Ember.A([]);
9430
+ var args, ret = Ember.A();
9049
9431
  if (arguments.length>1) args = a_slice.call(arguments, 1);
9050
9432
 
9051
9433
  this.forEach(function(x, idx) {
@@ -9066,7 +9448,7 @@ Ember.Enumerable = Ember.Mixin.create({
9066
9448
  @return {Array} the enumerable as an array.
9067
9449
  */
9068
9450
  toArray: function() {
9069
- var ret = Ember.A([]);
9451
+ var ret = Ember.A();
9070
9452
  this.forEach(function(o, idx) { ret[idx] = o; });
9071
9453
  return ret ;
9072
9454
  },
@@ -9102,7 +9484,7 @@ Ember.Enumerable = Ember.Mixin.create({
9102
9484
  */
9103
9485
  without: function(value) {
9104
9486
  if (!this.contains(value)) return this; // nothing to do
9105
- var ret = Ember.A([]);
9487
+ var ret = Ember.A();
9106
9488
  this.forEach(function(k) {
9107
9489
  if (k !== value) ret[ret.length] = k;
9108
9490
  }) ;
@@ -9122,7 +9504,7 @@ Ember.Enumerable = Ember.Mixin.create({
9122
9504
  @return {Ember.Enumerable}
9123
9505
  */
9124
9506
  uniq: function() {
9125
- var ret = Ember.A([]);
9507
+ var ret = Ember.A();
9126
9508
  this.forEach(function(k){
9127
9509
  if (a_indexOf(ret, k)<0) ret.push(k);
9128
9510
  });
@@ -9438,7 +9820,7 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
9438
9820
  @return {Array} New array with specified slice
9439
9821
  */
9440
9822
  slice: function(beginIndex, endIndex) {
9441
- var ret = Ember.A([]);
9823
+ var ret = Ember.A();
9442
9824
  var length = get(this, 'length') ;
9443
9825
  if (isNone(beginIndex)) beginIndex = 0 ;
9444
9826
  if (isNone(endIndex) || (endIndex > length)) endIndex = length ;
@@ -11126,7 +11508,7 @@ Ember.Evented = Ember.Mixin.create({
11126
11508
  },
11127
11509
 
11128
11510
  /**
11129
- Cancels subscription for give name, target, and method.
11511
+ Cancels subscription for given name, target, and method.
11130
11512
 
11131
11513
  @method off
11132
11514
  @param {String} name The name of the event
@@ -14837,10 +15219,10 @@ var sendEvent = function(eventName, sendRecursiveArguments, isUnhandledPass) {
14837
15219
  })
14838
15220
  }),
14839
15221
  stateTwo: Ember.State.create({
14840
- anAction: function(manager, context){
14841
- // will not be called below because it is
14842
- // not a parent of the current state
14843
- }
15222
+ anAction: function(manager, context){
15223
+ // will not be called below because it is
15224
+ // not a parent of the current state
15225
+ }
14844
15226
  })
14845
15227
  })
14846
15228