micro-rails 0.1.0.pre.alpha3 → 0.1.0.pre.alpha4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eabb6be33c02b03ec1eeac4cd276cd42a5dbf7f0
4
- data.tar.gz: b7536b1947afb465ebefa7d2af7255250316714d
3
+ metadata.gz: d7568da37f76d162e043f25911d1eb83fbd36de3
4
+ data.tar.gz: 20e616e3455ee92e51d5eee8270d01a53aa3e6b2
5
5
  SHA512:
6
- metadata.gz: e69d9fb6e03946e6458d6c6bc888b29656480a3f32774e698060610963e5daceab22d1b2ad00df30ced601da3c43fa387cf5837408cfed4546281e137944b5ea
7
- data.tar.gz: 7e258ffc3b815fc09afb65c3aa6a4f7700d94ae6df52c0f6837af13b072a6e2317f03b1d9bf2e1a92e3d2d431797836d5293054e6fddb0d609b7829d1e9b948d
6
+ metadata.gz: c9f376271722ec63e6f7e6182d0e2f9bc0e4a13d4e392bd6e16c2fc3ae7a32674cbf8d872f5a2f65b1453c4d05c8edf7e16834313df3fbeca04452d7161442c8
7
+ data.tar.gz: 1341431fdf733c867051c4053417f35a47bee10feb9b2eb57649750206a5fd99e0774ca61d57229622a49747252a9d08cee8be133b9d5971f6674eda6d20bc44
@@ -1,6 +1,6 @@
1
1
  module Micro
2
2
  module Rails
3
- VERSION = "0.1.0-alpha3"
4
- MICRO_VERSION = "0.1.0-alpha"
3
+ VERSION = "0.1.0-alpha4"
4
+ MICRO_VERSION = "0.1.0-alpha2"
5
5
  end
6
6
  end
@@ -59,7 +59,7 @@
59
59
  Component = _this.component(name);
60
60
  selector || (selector = Component.config.defaultSelector);
61
61
  if (!selector) {
62
- throw new Error('you must provide a selector or define defaultSelector in the component configuration');
62
+ throw new Error('you must provide a selector or define' + ' defaultSelector in the component configuration');
63
63
  }
64
64
  _this._initialize.push(function() {
65
65
  Component.initialize(this.filter(selector), config);
@@ -231,7 +231,7 @@
231
231
  } else if (prototype instanceof Module) {
232
232
  return this._addModule(Unit);
233
233
  } else {
234
- throw new Error("the unit must be a module or a component");
234
+ throw new Error('the unit must be a module or a component');
235
235
  }
236
236
  };
237
237
 
@@ -265,10 +265,10 @@
265
265
  Unit.extend = function(options) {
266
266
  var Child, Parent;
267
267
  if (!options.namespace) {
268
- throw new Error("you must provide a namespace when creating a component");
268
+ throw new Error('you must provide a namespace when creating a component');
269
269
  }
270
270
  if (!options.label) {
271
- throw new Error("you must provide a name when creating a component");
271
+ throw new Error('you must provide a name when creating a component');
272
272
  }
273
273
  if (!options.label.match(this.labelFormat)) {
274
274
  throw new Error(options.label + " is not a valid component name");
@@ -446,7 +446,7 @@
446
446
  if (this._modules[Module.fullName()]) {
447
447
  throw new Error("module " + Module.namespace + "." + Module.label + " is already included");
448
448
  }
449
- this._modules[Module.label] = Module;
449
+ this._modules[Module.fullName()] = Module;
450
450
  return Module.included(this);
451
451
  };
452
452
 
@@ -525,7 +525,7 @@
525
525
  };
526
526
 
527
527
  function Component(_at_$el, config) {
528
- var Module, components, factory, moduleLabel, name, _ref;
528
+ var Module, components, factory, moduleName, name, _ref;
529
529
  this.$el = _at_$el;
530
530
  factory = this.constructor.namespace.factory;
531
531
  components = factory.data(this.$el, 'components') || {};
@@ -540,27 +540,27 @@
540
540
  this._dataFull = $();
541
541
  this._dataNames = [];
542
542
  Component.__super__.constructor.call(this, config);
543
- this._moduleInstances = [];
543
+ this._moduleInstances = {};
544
544
  _ref = this.constructor._modules;
545
- for (moduleLabel in _ref) {
546
- Module = _ref[moduleLabel];
547
- this._moduleInstances.push(new Module(this, this.config));
545
+ for (moduleName in _ref) {
546
+ Module = _ref[moduleName];
547
+ this._moduleInstances[moduleName] = new Module(this, this.config);
548
548
  }
549
549
  }
550
550
 
551
551
  Component.prototype.destroy = function() {
552
- var components, dataName, factory, moduleInstance, _i, _j, _len, _len1, _ref, _ref1;
552
+ var components, dataName, factory, moduleInstance, moduleName, _i, _len, _ref, _ref1;
553
553
  Component.__super__.destroy.apply(this, arguments);
554
554
  _ref = this._moduleInstances;
555
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
556
- moduleInstance = _ref[_i];
555
+ for (moduleName in _ref) {
556
+ moduleInstance = _ref[moduleName];
557
557
  moduleInstance.destroy();
558
558
  }
559
559
  factory = this.constructor.namespace.factory;
560
560
  this._listeners.off("." + this._uniqueId);
561
561
  _ref1 = this._dataNames;
562
- for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
563
- dataName = _ref1[_j];
562
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
563
+ dataName = _ref1[_i];
564
564
  factory.removeData(this._dataFull, dataName);
565
565
  }
566
566
  components = factory.data(this.$el, 'components');
@@ -622,9 +622,11 @@
622
622
  };
623
623
 
624
624
  Component.prototype.trigger = function() {
625
- var eventType, namespace, params, _ref;
625
+ var componentLabel, eventType, namespace, namespaceLabel, params, _ref;
626
626
  eventType = arguments[0], params = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
627
- namespace = this.constructor.fullName();
627
+ namespaceLabel = this.constructor.namespace.label.toLowerCase();
628
+ componentLabel = this.constructor.label.toLowerCase();
629
+ namespace = namespaceLabel + ":" + componentLabel;
628
630
  return (_ref = this.$el).trigger.apply(_ref, [namespace + ":" + eventType].concat(__slice.call(params)));
629
631
  };
630
632
 
@@ -725,7 +727,22 @@
725
727
  };
726
728
 
727
729
  Module.included = function(Component) {
728
- return _.extend(Component.prototype, this._extensions);
730
+ var extension, fullName, name, _ref, _results;
731
+ fullName = this.fullName();
732
+ _ref = this._extensions;
733
+ _results = [];
734
+ for (name in _ref) {
735
+ extension = _ref[name];
736
+ _results.push((function(extension) {
737
+ return Component.prototype[name] = function() {
738
+ var args, instance;
739
+ args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
740
+ instance = this._moduleInstances[fullName];
741
+ return extension.apply(instance, args);
742
+ };
743
+ })(extension));
744
+ }
745
+ return _results;
729
746
  };
730
747
 
731
748
  function Module(_at_component, config) {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: micro-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.alpha3
4
+ version: 0.1.0.pre.alpha4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jérôme Guyon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-03 00:00:00.000000000 Z
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jquery-rails