polymer-rails 1.1.0 → 1.1.1
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.
- checksums.yaml +4 -4
- data/Rakefile +18 -0
- data/app/assets/javascripts/polymer/polymer-micro.html +6 -3
- data/app/assets/javascripts/polymer/polymer-mini.html +48 -51
- data/app/assets/javascripts/polymer/polymer.html +29 -18
- data/app/assets/javascripts/webcomponentsjs/webcomponents-lite.js +10 -7
- data/app/assets/javascripts/webcomponentsjs/webcomponents.js +12 -9
- data/lib/polymer-rails.rb +3 -6
- data/lib/polymer-rails/component.rb +8 -32
- data/lib/polymer-rails/processors/component.rb +68 -0
- data/lib/polymer-rails/processors/directive.rb +8 -0
- data/lib/polymer-rails/processors/sprockets_v2_processor.rb +12 -0
- data/lib/polymer-rails/processors/{components_processor_v3.rb → sprockets_v3_processor.rb} +1 -5
- data/lib/polymer-rails/railtie.rb +12 -18
- data/lib/polymer-rails/version.rb +1 -1
- data/lib/polymer-rails/xml_adapters/base.rb +23 -0
- data/lib/polymer-rails/xml_adapters/jsoup.rb +48 -0
- data/lib/polymer-rails/xml_adapters/nokogiri.rb +49 -0
- metadata +48 -17
- data/lib/polymer-rails/processors/components_processor.rb +0 -59
- data/lib/polymer-rails/processors/components_processor_v2.rb +0 -16
- data/lib/polymer-rails/processors/directive_processor.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ccbca115d533cf6aa8769934efda7779e1c420b
|
4
|
+
data.tar.gz: 927f6f95af53a59e42436cec30a1916911eb68ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b870fe572b064787015fc7041b321facf6c356d46bae30b816310711be9498bf8c377e35a3a26d641822a76a2dc48ae54b051ece3b7551396c4eaf2e751a02c5
|
7
|
+
data.tar.gz: d557945c318a077454f4e05698b4e962280e6fb422023249f9794e2d89cf344a6137b9973d4cf6d5cd542c860edfb99f443c19071c4c1c20b29c418586f41082
|
data/Rakefile
CHANGED
@@ -1 +1,19 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
task :default
|
4
|
+
|
5
|
+
if RUBY_PLATFORM =~ /java/
|
6
|
+
require 'maven/ruby/maven'
|
7
|
+
require 'jar_installer'
|
8
|
+
|
9
|
+
desc 'setup jar dependencies to be used for "testing" and generates lib/example_jars.rb'
|
10
|
+
task :setup do
|
11
|
+
Jars::JarInstaller.install_jars
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'compile src/main/java/** into lib/example.jar'
|
15
|
+
task :jar do
|
16
|
+
Maven::Ruby::Maven.new.exec 'prepare-package'
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -217,6 +217,9 @@ Polymer.telemetry.instanceCount = 0;
|
|
217
217
|
(function () {
|
218
218
|
var modules = {};
|
219
219
|
var lcModules = {};
|
220
|
+
var findModule = function (id) {
|
221
|
+
return modules[id] || lcModules[id.toLowerCase()];
|
222
|
+
};
|
220
223
|
var DomModule = function () {
|
221
224
|
return document.createElement('dom-module');
|
222
225
|
};
|
@@ -235,10 +238,10 @@ lcModules[id.toLowerCase()] = this;
|
|
235
238
|
}
|
236
239
|
},
|
237
240
|
import: function (id, selector) {
|
238
|
-
var m =
|
241
|
+
var m = findModule(id);
|
239
242
|
if (!m) {
|
240
243
|
forceDocumentUpgrade();
|
241
|
-
m =
|
244
|
+
m = findModule(id);
|
242
245
|
}
|
243
246
|
if (m && selector) {
|
244
247
|
m = m.querySelector(selector);
|
@@ -558,7 +561,7 @@ debouncer.stop();
|
|
558
561
|
}
|
559
562
|
}
|
560
563
|
});
|
561
|
-
Polymer.version = '1.1.
|
564
|
+
Polymer.version = '1.1.1';
|
562
565
|
Polymer.Base._addFeature({
|
563
566
|
_registerFeatures: function () {
|
564
567
|
this._prepIs();
|
@@ -457,47 +457,43 @@ Polymer.dom.addDebouncer(host.debounce('_distribute', host._distributeContent));
|
|
457
457
|
}
|
458
458
|
},
|
459
459
|
appendChild: function (node) {
|
460
|
-
|
461
|
-
this._ensureContentLogicalInfo(node);
|
462
|
-
this._removeNodeFromHost(node, true);
|
463
|
-
if (this._nodeIsInLogicalTree(this.node)) {
|
464
|
-
this._addLogicalInfo(node, this.node);
|
465
|
-
this._addNodeToHost(node);
|
466
|
-
handled = this._maybeDistribute(node, this.node);
|
467
|
-
} else {
|
468
|
-
this._addNodeToHost(node);
|
469
|
-
}
|
470
|
-
if (!handled && !this._tryRemoveUndistributedNode(node)) {
|
471
|
-
var container = this.node._isShadyRoot ? this.node.host : this.node;
|
472
|
-
addToComposedParent(container, node);
|
473
|
-
nativeAppendChild.call(container, node);
|
474
|
-
}
|
475
|
-
return node;
|
460
|
+
return this._addNode(node);
|
476
461
|
},
|
477
462
|
insertBefore: function (node, ref_node) {
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
var handled;
|
482
|
-
this._ensureContentLogicalInfo(node);
|
463
|
+
return this._addNode(node, ref_node);
|
464
|
+
},
|
465
|
+
_addNode: function (node, ref_node) {
|
483
466
|
this._removeNodeFromHost(node, true);
|
484
|
-
|
467
|
+
var addedInsertionPoint;
|
468
|
+
var root = this.getOwnerRoot();
|
469
|
+
if (root) {
|
470
|
+
addedInsertionPoint = this._maybeAddInsertionPoint(node, this.node);
|
471
|
+
}
|
472
|
+
if (this._nodeHasLogicalChildren(this.node)) {
|
473
|
+
if (ref_node) {
|
485
474
|
var children = this.childNodes;
|
486
475
|
var index = children.indexOf(ref_node);
|
487
476
|
if (index < 0) {
|
488
477
|
throw Error('The ref_node to be inserted before is not a child ' + 'of this node');
|
489
478
|
}
|
479
|
+
}
|
490
480
|
this._addLogicalInfo(node, this.node, index);
|
491
|
-
this._addNodeToHost(node);
|
492
|
-
handled = this._maybeDistribute(node, this.node);
|
493
|
-
} else {
|
494
|
-
this._addNodeToHost(node);
|
495
481
|
}
|
496
|
-
|
482
|
+
this._addNodeToHost(node);
|
483
|
+
if (!this._maybeDistribute(node, this.node) && !this._tryRemoveUndistributedNode(node)) {
|
484
|
+
if (ref_node) {
|
497
485
|
ref_node = ref_node.localName === CONTENT ? this._firstComposedNode(ref_node) : ref_node;
|
486
|
+
}
|
498
487
|
var container = this.node._isShadyRoot ? this.node.host : this.node;
|
499
488
|
addToComposedParent(container, node, ref_node);
|
489
|
+
if (ref_node) {
|
500
490
|
nativeInsertBefore.call(container, node, ref_node);
|
491
|
+
} else {
|
492
|
+
nativeAppendChild.call(container, node);
|
493
|
+
}
|
494
|
+
}
|
495
|
+
if (addedInsertionPoint) {
|
496
|
+
this._updateInsertionPoints(root.host);
|
501
497
|
}
|
502
498
|
return node;
|
503
499
|
},
|
@@ -505,14 +501,8 @@ removeChild: function (node) {
|
|
505
501
|
if (factory(node).parentNode !== this.node) {
|
506
502
|
console.warn('The node to be removed is not a child of this node', node);
|
507
503
|
}
|
508
|
-
var handled;
|
509
|
-
if (this._nodeIsInLogicalTree(this.node)) {
|
510
|
-
this._removeNodeFromHost(node);
|
511
|
-
handled = this._maybeDistribute(node, this.node);
|
512
|
-
} else {
|
513
504
|
this._removeNodeFromHost(node);
|
514
|
-
|
515
|
-
if (!handled) {
|
505
|
+
if (!this._maybeDistribute(node, this.node)) {
|
516
506
|
var container = this.node._isShadyRoot ? this.node.host : this.node;
|
517
507
|
if (container === node.parentNode) {
|
518
508
|
removeFromComposedParent(container, node);
|
@@ -560,7 +550,6 @@ if (hasContent) {
|
|
560
550
|
var root = this._ownerShadyRootForNode(parent);
|
561
551
|
if (root) {
|
562
552
|
var host = root.host;
|
563
|
-
this._updateInsertionPoints(host);
|
564
553
|
this._lazyDistribute(host);
|
565
554
|
}
|
566
555
|
}
|
@@ -570,6 +559,25 @@ this._lazyDistribute(parent);
|
|
570
559
|
}
|
571
560
|
return parentNeedsDist || hasContent && !wrappedContent;
|
572
561
|
},
|
562
|
+
_maybeAddInsertionPoint: function (node, parent) {
|
563
|
+
var added;
|
564
|
+
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && !node.__noContent) {
|
565
|
+
var c$ = factory(node).querySelectorAll(CONTENT);
|
566
|
+
for (var i = 0, n, np, na; i < c$.length && (n = c$[i]); i++) {
|
567
|
+
np = factory(n).parentNode;
|
568
|
+
if (np === node) {
|
569
|
+
np = parent;
|
570
|
+
}
|
571
|
+
na = this._maybeAddInsertionPoint(n, np);
|
572
|
+
added = added || na;
|
573
|
+
}
|
574
|
+
} else if (node.localName === CONTENT) {
|
575
|
+
saveLightChildrenIfNeeded(parent);
|
576
|
+
saveLightChildrenIfNeeded(node);
|
577
|
+
added = true;
|
578
|
+
}
|
579
|
+
return added;
|
580
|
+
},
|
573
581
|
_tryRemoveUndistributedNode: function (node) {
|
574
582
|
if (this.node.shadyRoot) {
|
575
583
|
if (node._composedParent) {
|
@@ -586,20 +594,8 @@ saveLightChildrenIfNeeded(c);
|
|
586
594
|
saveLightChildrenIfNeeded(factory(c).parentNode);
|
587
595
|
}
|
588
596
|
},
|
589
|
-
|
590
|
-
return Boolean(node.
|
591
|
-
},
|
592
|
-
_ensureContentLogicalInfo: function (node) {
|
593
|
-
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
594
|
-
saveLightChildrenIfNeeded(this.node);
|
595
|
-
var c$ = Array.prototype.slice.call(node.childNodes);
|
596
|
-
for (var i = 0, n; i < c$.length && (n = c$[i]); i++) {
|
597
|
-
this._ensureContentLogicalInfo(n);
|
598
|
-
}
|
599
|
-
} else if (node.localName === CONTENT) {
|
600
|
-
saveLightChildrenIfNeeded(this.node);
|
601
|
-
saveLightChildrenIfNeeded(node);
|
602
|
-
}
|
597
|
+
_nodeHasLogicalChildren: function (node) {
|
598
|
+
return Boolean(node._lightChildren !== undefined);
|
603
599
|
},
|
604
600
|
_parentNeedsDistribution: function (parent) {
|
605
601
|
return parent && parent.shadyRoot && hasInsertionPoint(parent.shadyRoot);
|
@@ -609,6 +605,7 @@ var hostNeedsDist;
|
|
609
605
|
var root;
|
610
606
|
var parent = node._lightParent;
|
611
607
|
if (parent) {
|
608
|
+
factory(node)._distributeParent();
|
612
609
|
root = this._ownerShadyRootForNode(node);
|
613
610
|
if (root) {
|
614
611
|
root.host._elementRemove(node);
|
@@ -621,7 +618,7 @@ if (root && hostNeedsDist) {
|
|
621
618
|
this._updateInsertionPoints(root.host);
|
622
619
|
this._lazyDistribute(root.host);
|
623
620
|
} else if (ensureComposedRemoval) {
|
624
|
-
removeFromComposedParent(
|
621
|
+
removeFromComposedParent(node._composedParent, node);
|
625
622
|
}
|
626
623
|
},
|
627
624
|
_removeDistributedChildren: function (root, container) {
|
@@ -1147,7 +1144,7 @@ node._lightChildren = c$;
|
|
1147
1144
|
}
|
1148
1145
|
}
|
1149
1146
|
function hasInsertionPoint(root) {
|
1150
|
-
return Boolean(root._insertionPoints.length);
|
1147
|
+
return Boolean(root && root._insertionPoints.length);
|
1151
1148
|
}
|
1152
1149
|
var p = Element.prototype;
|
1153
1150
|
var matchesSelector = p.matches || p.matchesSelector || p.mozMatchesSelector || p.msMatchesSelector || p.oMatchesSelector || p.webkitMatchesSelector;
|
@@ -1656,6 +1656,9 @@ name: arg,
|
|
1656
1656
|
model: this._modelForPath(arg)
|
1657
1657
|
};
|
1658
1658
|
var fc = arg[0];
|
1659
|
+
if (fc === '-') {
|
1660
|
+
fc = arg[1];
|
1661
|
+
}
|
1659
1662
|
if (fc >= '0' && fc <= '9') {
|
1660
1663
|
fc = '#';
|
1661
1664
|
}
|
@@ -2276,30 +2279,24 @@ return m && m._cssText || '';
|
|
2276
2279
|
_cssFromElement: function (element) {
|
2277
2280
|
var cssText = '';
|
2278
2281
|
var content = element.content || element;
|
2279
|
-
var sourceDoc = element.ownerDocument;
|
2280
2282
|
var e$ = Array.prototype.slice.call(content.querySelectorAll(this.MODULE_STYLES_SELECTOR));
|
2281
|
-
for (var i = 0, e
|
2283
|
+
for (var i = 0, e; i < e$.length; i++) {
|
2282
2284
|
e = e$[i];
|
2283
|
-
resolveDoc = sourceDoc;
|
2284
|
-
addModule = null;
|
2285
2285
|
if (e.localName === 'template') {
|
2286
2286
|
cssText += this._cssFromElement(e);
|
2287
2287
|
} else {
|
2288
2288
|
if (e.localName === 'style') {
|
2289
|
-
|
2289
|
+
var include = e.getAttribute(this.INCLUDE_ATTR);
|
2290
2290
|
e = e.__appliedElement || e;
|
2291
2291
|
e.parentNode.removeChild(e);
|
2292
|
-
|
2293
|
-
|
2294
|
-
|
2292
|
+
cssText += this.resolveCss(e.textContent, element.ownerDocument);
|
2293
|
+
if (include) {
|
2294
|
+
cssText += this.cssFromModules(include);
|
2295
2295
|
}
|
2296
|
-
if (e) {
|
2297
|
-
cssText += this.resolveCss(e.textContent,
|
2296
|
+
} else if (e.import && e.import.body) {
|
2297
|
+
cssText += this.resolveCss(e.import.body.textContent, e.import);
|
2298
2298
|
}
|
2299
2299
|
}
|
2300
|
-
if (addModule) {
|
2301
|
-
cssText += this.cssFromModules(addModule);
|
2302
|
-
}
|
2303
2300
|
}
|
2304
2301
|
return cssText;
|
2305
2302
|
},
|
@@ -3234,16 +3231,18 @@ var e = this.__appliedElement || this;
|
|
3234
3231
|
if (this.include) {
|
3235
3232
|
e.textContent += styleUtil.cssFromModules(this.include);
|
3236
3233
|
}
|
3234
|
+
var rules = styleUtil.rulesForStyle(e);
|
3235
|
+
styleUtil.forEachStyleRule(rules, function (rule) {
|
3236
|
+
styleTransformer.documentRule(rule);
|
3237
|
+
});
|
3237
3238
|
this._computeStyleProperties();
|
3238
3239
|
var props = this._styleProperties;
|
3239
|
-
|
3240
|
-
e.textContent = styleUtil.toCssText(styleUtil.rulesForStyle(e), function (rule) {
|
3240
|
+
e.textContent = styleUtil.toCssText(rules, function (rule) {
|
3241
3241
|
var css = rule.cssText = rule.parsedCssText;
|
3242
3242
|
if (rule.propertyInfo && rule.propertyInfo.cssText) {
|
3243
3243
|
css = cssParse.removeCustomPropAssignment(css);
|
3244
3244
|
rule.cssText = propertyUtils.valueForProperties(css, props);
|
3245
3245
|
}
|
3246
|
-
styleTransformer.documentRule(rule);
|
3247
3246
|
});
|
3248
3247
|
}
|
3249
3248
|
});
|
@@ -3799,6 +3798,9 @@ this._instances.splice(keys.length, this._instances.length - keys.length);
|
|
3799
3798
|
_keySort: function (a, b) {
|
3800
3799
|
return this.collection.getKey(a) - this.collection.getKey(b);
|
3801
3800
|
},
|
3801
|
+
_numericSort: function (a, b) {
|
3802
|
+
return a - b;
|
3803
|
+
},
|
3802
3804
|
_applySplicesUserSort: function (splices) {
|
3803
3805
|
var c = this.collection;
|
3804
3806
|
var instances = this._instances;
|
@@ -3826,7 +3828,7 @@ addedKeys.push(key);
|
|
3826
3828
|
}
|
3827
3829
|
}
|
3828
3830
|
if (removedIdxs.length) {
|
3829
|
-
removedIdxs.sort();
|
3831
|
+
removedIdxs.sort(this._numericSort);
|
3830
3832
|
for (var i = removedIdxs.length - 1; i >= 0; i--) {
|
3831
3833
|
var idx = removedIdxs[i];
|
3832
3834
|
if (idx !== undefined) {
|
@@ -4009,6 +4011,10 @@ selected: {
|
|
4009
4011
|
type: Object,
|
4010
4012
|
notify: true
|
4011
4013
|
},
|
4014
|
+
selectedItem: {
|
4015
|
+
type: Object,
|
4016
|
+
notify: true
|
4017
|
+
},
|
4012
4018
|
toggle: {
|
4013
4019
|
type: Boolean,
|
4014
4020
|
value: false
|
@@ -4031,6 +4037,7 @@ this._selectedColl = Polymer.Collection.get(this.selected);
|
|
4031
4037
|
this.selected = null;
|
4032
4038
|
this._selectedColl = null;
|
4033
4039
|
}
|
4040
|
+
this.selectedItem = null;
|
4034
4041
|
},
|
4035
4042
|
isSelected: function (item) {
|
4036
4043
|
if (this.multi) {
|
@@ -4048,7 +4055,9 @@ this.unlinkPaths('selected.' + skey);
|
|
4048
4055
|
}
|
4049
4056
|
} else {
|
4050
4057
|
this.selected = null;
|
4058
|
+
this.selectedItem = null;
|
4051
4059
|
this.unlinkPaths('selected');
|
4060
|
+
this.unlinkPaths('selectedItem');
|
4052
4061
|
}
|
4053
4062
|
},
|
4054
4063
|
select: function (item) {
|
@@ -4068,8 +4077,10 @@ this.linkPaths('selected.' + skey, 'items.' + key);
|
|
4068
4077
|
if (this.toggle && item == this.selected) {
|
4069
4078
|
this.deselect();
|
4070
4079
|
} else {
|
4071
|
-
this.linkPaths('selected', 'items.' + key);
|
4072
4080
|
this.selected = item;
|
4081
|
+
this.selectedItem = item;
|
4082
|
+
this.linkPaths('selected', 'items.' + key);
|
4083
|
+
this.linkPaths('selectedItem', 'items.' + key);
|
4073
4084
|
}
|
4074
4085
|
}
|
4075
4086
|
}
|
@@ -7,7 +7,7 @@
|
|
7
7
|
* Code distributed by Google as part of the polymer project is also
|
8
8
|
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
9
|
*/
|
10
|
-
// @version 0.7.
|
10
|
+
// @version 0.7.12
|
11
11
|
window.WebComponents = window.WebComponents || {};
|
12
12
|
|
13
13
|
(function(scope) {
|
@@ -909,7 +909,7 @@ if (typeof WeakMap === "undefined") {
|
|
909
909
|
};
|
910
910
|
global.JsMutationObserver = JsMutationObserver;
|
911
911
|
if (!global.MutationObserver) global.MutationObserver = JsMutationObserver;
|
912
|
-
})(
|
912
|
+
})(window);
|
913
913
|
|
914
914
|
window.HTMLImports = window.HTMLImports || {
|
915
915
|
flags: {}
|
@@ -1675,6 +1675,7 @@ window.CustomElements = window.CustomElements || {
|
|
1675
1675
|
scope.addModule = addModule;
|
1676
1676
|
scope.initializeModules = initializeModules;
|
1677
1677
|
scope.hasNative = Boolean(document.registerElement);
|
1678
|
+
scope.isIE = /Trident/.test(navigator.userAgent);
|
1678
1679
|
scope.useNative = !flags.register && scope.hasNative && !window.ShadowDOMPolyfill && (!window.HTMLImports || window.HTMLImports.useNative);
|
1679
1680
|
})(window.CustomElements);
|
1680
1681
|
|
@@ -1983,7 +1984,7 @@ window.CustomElements.addModule(function(scope) {
|
|
1983
1984
|
});
|
1984
1985
|
|
1985
1986
|
window.CustomElements.addModule(function(scope) {
|
1986
|
-
var
|
1987
|
+
var isIE = scope.isIE;
|
1987
1988
|
var upgradeDocumentTree = scope.upgradeDocumentTree;
|
1988
1989
|
var upgradeAll = scope.upgradeAll;
|
1989
1990
|
var upgradeWithDefinition = scope.upgradeWithDefinition;
|
@@ -2179,7 +2180,7 @@ window.CustomElements.addModule(function(scope) {
|
|
2179
2180
|
}
|
2180
2181
|
wrapDomMethodToForceUpgrade(Node.prototype, "cloneNode");
|
2181
2182
|
wrapDomMethodToForceUpgrade(document, "importNode");
|
2182
|
-
if (
|
2183
|
+
if (isIE) {
|
2183
2184
|
(function() {
|
2184
2185
|
var importNode = document.importNode;
|
2185
2186
|
document.importNode = function() {
|
@@ -2207,7 +2208,7 @@ window.CustomElements.addModule(function(scope) {
|
|
2207
2208
|
(function(scope) {
|
2208
2209
|
var useNative = scope.useNative;
|
2209
2210
|
var initializeModules = scope.initializeModules;
|
2210
|
-
var
|
2211
|
+
var isIE = scope.isIE;
|
2211
2212
|
if (useNative) {
|
2212
2213
|
var nop = function() {};
|
2213
2214
|
scope.watchShadow = nop;
|
@@ -2244,6 +2245,9 @@ window.CustomElements.addModule(function(scope) {
|
|
2244
2245
|
function bootstrap() {
|
2245
2246
|
upgradeDocumentTree(window.wrap(document));
|
2246
2247
|
window.CustomElements.ready = true;
|
2248
|
+
var requestAnimationFrame = window.requestAnimationFrame || function(f) {
|
2249
|
+
setTimeout(f, 16);
|
2250
|
+
};
|
2247
2251
|
requestAnimationFrame(function() {
|
2248
2252
|
setTimeout(function() {
|
2249
2253
|
window.CustomElements.readyTime = Date.now();
|
@@ -2256,7 +2260,7 @@ window.CustomElements.addModule(function(scope) {
|
|
2256
2260
|
});
|
2257
2261
|
});
|
2258
2262
|
}
|
2259
|
-
if (
|
2263
|
+
if (isIE && typeof window.CustomEvent !== "function") {
|
2260
2264
|
window.CustomEvent = function(inType, params) {
|
2261
2265
|
params = params || {};
|
2262
2266
|
var e = document.createEvent("CustomEvent");
|
@@ -2280,7 +2284,6 @@ window.CustomElements.addModule(function(scope) {
|
|
2280
2284
|
var loadEvent = window.HTMLImports && !window.HTMLImports.ready ? "HTMLImportsLoaded" : "DOMContentLoaded";
|
2281
2285
|
window.addEventListener(loadEvent, bootstrap);
|
2282
2286
|
}
|
2283
|
-
scope.isIE11OrOlder = isIE11OrOlder;
|
2284
2287
|
})(window.CustomElements);
|
2285
2288
|
|
2286
2289
|
if (typeof HTMLTemplateElement === "undefined") {
|
@@ -7,7 +7,7 @@
|
|
7
7
|
* Code distributed by Google as part of the polymer project is also
|
8
8
|
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
9
|
*/
|
10
|
-
// @version 0.7.
|
10
|
+
// @version 0.7.12
|
11
11
|
window.WebComponents = window.WebComponents || {};
|
12
12
|
|
13
13
|
(function(scope) {
|
@@ -1781,8 +1781,8 @@ if (WebComponents.flags.shadow) {
|
|
1781
1781
|
var originalInsertBefore = OriginalNode.prototype.insertBefore;
|
1782
1782
|
var originalRemoveChild = OriginalNode.prototype.removeChild;
|
1783
1783
|
var originalReplaceChild = OriginalNode.prototype.replaceChild;
|
1784
|
-
var
|
1785
|
-
var removeChildOriginalHelper =
|
1784
|
+
var isIEOrEdge = /Trident|Edge/.test(navigator.userAgent);
|
1785
|
+
var removeChildOriginalHelper = isIEOrEdge ? function(parent, child) {
|
1786
1786
|
try {
|
1787
1787
|
originalRemoveChild.call(parent, child);
|
1788
1788
|
} catch (ex) {
|
@@ -5678,7 +5678,7 @@ if (WebComponents.flags.shadow) {
|
|
5678
5678
|
};
|
5679
5679
|
global.JsMutationObserver = JsMutationObserver;
|
5680
5680
|
if (!global.MutationObserver) global.MutationObserver = JsMutationObserver;
|
5681
|
-
})(
|
5681
|
+
})(window);
|
5682
5682
|
|
5683
5683
|
window.HTMLImports = window.HTMLImports || {
|
5684
5684
|
flags: {}
|
@@ -6444,6 +6444,7 @@ window.CustomElements = window.CustomElements || {
|
|
6444
6444
|
scope.addModule = addModule;
|
6445
6445
|
scope.initializeModules = initializeModules;
|
6446
6446
|
scope.hasNative = Boolean(document.registerElement);
|
6447
|
+
scope.isIE = /Trident/.test(navigator.userAgent);
|
6447
6448
|
scope.useNative = !flags.register && scope.hasNative && !window.ShadowDOMPolyfill && (!window.HTMLImports || window.HTMLImports.useNative);
|
6448
6449
|
})(window.CustomElements);
|
6449
6450
|
|
@@ -6752,7 +6753,7 @@ window.CustomElements.addModule(function(scope) {
|
|
6752
6753
|
});
|
6753
6754
|
|
6754
6755
|
window.CustomElements.addModule(function(scope) {
|
6755
|
-
var
|
6756
|
+
var isIE = scope.isIE;
|
6756
6757
|
var upgradeDocumentTree = scope.upgradeDocumentTree;
|
6757
6758
|
var upgradeAll = scope.upgradeAll;
|
6758
6759
|
var upgradeWithDefinition = scope.upgradeWithDefinition;
|
@@ -6948,7 +6949,7 @@ window.CustomElements.addModule(function(scope) {
|
|
6948
6949
|
}
|
6949
6950
|
wrapDomMethodToForceUpgrade(Node.prototype, "cloneNode");
|
6950
6951
|
wrapDomMethodToForceUpgrade(document, "importNode");
|
6951
|
-
if (
|
6952
|
+
if (isIE) {
|
6952
6953
|
(function() {
|
6953
6954
|
var importNode = document.importNode;
|
6954
6955
|
document.importNode = function() {
|
@@ -6976,7 +6977,7 @@ window.CustomElements.addModule(function(scope) {
|
|
6976
6977
|
(function(scope) {
|
6977
6978
|
var useNative = scope.useNative;
|
6978
6979
|
var initializeModules = scope.initializeModules;
|
6979
|
-
var
|
6980
|
+
var isIE = scope.isIE;
|
6980
6981
|
if (useNative) {
|
6981
6982
|
var nop = function() {};
|
6982
6983
|
scope.watchShadow = nop;
|
@@ -7013,6 +7014,9 @@ window.CustomElements.addModule(function(scope) {
|
|
7013
7014
|
function bootstrap() {
|
7014
7015
|
upgradeDocumentTree(window.wrap(document));
|
7015
7016
|
window.CustomElements.ready = true;
|
7017
|
+
var requestAnimationFrame = window.requestAnimationFrame || function(f) {
|
7018
|
+
setTimeout(f, 16);
|
7019
|
+
};
|
7016
7020
|
requestAnimationFrame(function() {
|
7017
7021
|
setTimeout(function() {
|
7018
7022
|
window.CustomElements.readyTime = Date.now();
|
@@ -7025,7 +7029,7 @@ window.CustomElements.addModule(function(scope) {
|
|
7025
7029
|
});
|
7026
7030
|
});
|
7027
7031
|
}
|
7028
|
-
if (
|
7032
|
+
if (isIE && typeof window.CustomEvent !== "function") {
|
7029
7033
|
window.CustomEvent = function(inType, params) {
|
7030
7034
|
params = params || {};
|
7031
7035
|
var e = document.createEvent("CustomEvent");
|
@@ -7049,7 +7053,6 @@ window.CustomElements.addModule(function(scope) {
|
|
7049
7053
|
var loadEvent = window.HTMLImports && !window.HTMLImports.ready ? "HTMLImportsLoaded" : "DOMContentLoaded";
|
7050
7054
|
window.addEventListener(loadEvent, bootstrap);
|
7051
7055
|
}
|
7052
|
-
scope.isIE11OrOlder = isIE11OrOlder;
|
7053
7056
|
})(window.CustomElements);
|
7054
7057
|
|
7055
7058
|
(function(scope) {
|
data/lib/polymer-rails.rb
CHANGED
@@ -6,12 +6,9 @@ end
|
|
6
6
|
|
7
7
|
require "sprockets"
|
8
8
|
require "polymer-rails/version"
|
9
|
-
require "polymer-rails/
|
10
|
-
|
11
|
-
|
12
|
-
else
|
13
|
-
require "polymer-rails/processors/components_processor_v3"
|
14
|
-
end
|
9
|
+
require "polymer-rails/xml_adapters/base"
|
10
|
+
require "polymer-rails/processors/directive"
|
11
|
+
require "polymer-rails/processors/component"
|
15
12
|
require "polymer-rails/helpers/asset_tag_helper"
|
16
13
|
require "polymer-rails/engine" if defined?(::Rails)
|
17
14
|
require "polymer-rails/railtie" if defined?(::Rails)
|
@@ -1,18 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'uri'
|
2
2
|
|
3
3
|
module Polymer
|
4
4
|
module Rails
|
5
5
|
class Component
|
6
6
|
|
7
|
-
# HTML Encoding
|
8
|
-
ENCODING = 'UTF-8'
|
9
|
-
|
10
|
-
# Nodes that should be parsed as XML nodes
|
11
|
-
XML_NODES = ['*[selected]', '*[checked]', '*[src]:not(script)']
|
12
|
-
|
13
|
-
# XML options for to_xml method
|
14
|
-
XML_OPTIONS = { save_with: Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS }
|
15
|
-
|
16
7
|
# Selectors for component resources
|
17
8
|
SELECTORS = {
|
18
9
|
html: "link[rel='import']:not([type='css'])",
|
@@ -21,49 +12,34 @@ module Polymer
|
|
21
12
|
}
|
22
13
|
|
23
14
|
def initialize(data)
|
24
|
-
@
|
15
|
+
@adapter = XmlAdapters::Base.factory
|
16
|
+
@doc = @adapter.parse_document(data)
|
25
17
|
end
|
26
18
|
|
27
19
|
def stringify
|
28
|
-
|
29
|
-
output.gsub(node.to_html, node.to_xml(XML_OPTIONS)).encode(ENCODING)
|
30
|
-
end
|
20
|
+
@adapter.stringify(@doc)
|
31
21
|
end
|
32
22
|
|
33
23
|
def replace_node(node, name, content)
|
34
|
-
node.
|
24
|
+
@adapter.replace_node node, @adapter.create_node(@doc, name, content)
|
35
25
|
end
|
36
26
|
|
37
27
|
def stylesheets
|
38
|
-
@
|
28
|
+
@adapter.css_select(@doc, SELECTORS[:stylesheet]).reject{|tag| is_external? tag.attributes['href'].value}
|
39
29
|
end
|
40
30
|
|
41
31
|
def javascripts
|
42
|
-
@
|
32
|
+
@adapter.css_select(@doc, SELECTORS[:javascript]).reject do |tag|
|
43
33
|
is_external? tag.attributes['src'].value
|
44
34
|
end
|
45
35
|
end
|
46
36
|
|
47
37
|
def html_imports
|
48
|
-
@
|
38
|
+
@adapter.css_select(@doc, SELECTORS[:html])
|
49
39
|
end
|
50
40
|
|
51
41
|
private
|
52
42
|
|
53
|
-
def create_node(name, content)
|
54
|
-
node = ::Nokogiri::XML::Node.new(name, @doc)
|
55
|
-
node.content = content
|
56
|
-
node
|
57
|
-
end
|
58
|
-
|
59
|
-
def to_html
|
60
|
-
@doc.css("body").children.to_html(encoding: ENCODING).lstrip
|
61
|
-
end
|
62
|
-
|
63
|
-
def xml_nodes
|
64
|
-
@doc.css(XML_NODES.join(','))
|
65
|
-
end
|
66
|
-
|
67
43
|
def is_external?(source)
|
68
44
|
!URI(source).host.nil?
|
69
45
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'polymer-rails/component'
|
2
|
+
if Polymer::Rails::LEGACY_SPROCKETS
|
3
|
+
require 'polymer-rails/processors/sprockets_v2_processor'
|
4
|
+
else
|
5
|
+
require "polymer-rails/processors/sprockets_v3_processor"
|
6
|
+
end
|
7
|
+
|
8
|
+
module Polymer
|
9
|
+
module Rails
|
10
|
+
module Processors
|
11
|
+
class Component < Polymer::Rails::SprocketsProcessor
|
12
|
+
|
13
|
+
def process
|
14
|
+
inline_styles
|
15
|
+
inline_javascripts
|
16
|
+
require_imports
|
17
|
+
@component.stringify
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def require_imports
|
23
|
+
@component.html_imports.each do |import|
|
24
|
+
@context.require_asset absolute_asset_path(import.attributes['href'].value)
|
25
|
+
import.remove
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def inline_javascripts
|
30
|
+
@component.javascripts.each do |script|
|
31
|
+
@component.replace_node(script, 'script', asset_content(script.attributes['src'].value))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def inline_styles
|
36
|
+
@component.stylesheets.each do |link|
|
37
|
+
@component.replace_node(link, 'style', asset_content(link.attributes['href'].value))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def asset_content(file)
|
42
|
+
asset_path = absolute_asset_path(file)
|
43
|
+
asset = find_asset(asset_path)
|
44
|
+
unless asset.blank?
|
45
|
+
@context.depend_on_asset asset_path
|
46
|
+
asset.to_s
|
47
|
+
else
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def absolute_asset_path(file)
|
53
|
+
search_file = file.sub(/^(\.\.\/)+/, '/').sub(/^\/*/, '')
|
54
|
+
::Rails.application.assets.paths.each do |path|
|
55
|
+
file_list = Dir.glob( "#{File.absolute_path search_file, path }*")
|
56
|
+
return file_list.first unless file_list.blank?
|
57
|
+
end
|
58
|
+
components = Dir.glob("#{File.absolute_path file, File.dirname(@context.pathname)}*")
|
59
|
+
return components.blank? ? nil : components.first
|
60
|
+
end
|
61
|
+
|
62
|
+
def find_asset(asset_path)
|
63
|
+
::Rails.application.assets.find_asset(asset_path)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -1,10 +1,6 @@
|
|
1
|
-
require 'polymer-rails/component'
|
2
|
-
require 'polymer-rails/processors/components_processor'
|
3
|
-
|
4
1
|
module Polymer
|
5
2
|
module Rails
|
6
|
-
class
|
7
|
-
include ::Polymer::Rails::ComponentsProcessor
|
3
|
+
class SprocketsProcessor
|
8
4
|
|
9
5
|
def self.instance
|
10
6
|
@instance ||= new
|
@@ -8,36 +8,30 @@ module Polymer
|
|
8
8
|
end
|
9
9
|
|
10
10
|
initializer :precompile_polymer do |app|
|
11
|
-
if app.config.respond_to?
|
11
|
+
if app.config.respond_to?(:assets)
|
12
12
|
app.config.assets.precompile += %w( polymer/polymer.js )
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
initializer :add_preprocessors do |app|
|
17
|
-
|
18
|
-
add_preprocessors_legacy(app)
|
19
|
-
else
|
20
|
-
add_preprocessors(app)
|
21
|
-
end
|
17
|
+
add_preprocessors(app)
|
22
18
|
end
|
23
19
|
|
24
20
|
private
|
25
21
|
|
26
22
|
def add_preprocessors(app)
|
27
|
-
app.assets.
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
Polymer::Rails::ComponentsProcessorV2.new(context, data).process
|
23
|
+
app.assets.register_preprocessor 'text/html', Polymer::Rails::Processors::Directive
|
24
|
+
if Polymer::Rails::LEGACY_SPROCKETS
|
25
|
+
app.assets.register_mime_type "text/html", '.html'
|
26
|
+
app.assets.register_postprocessor 'text/html', :web do |context, data|
|
27
|
+
Polymer::Rails::Processors::Component.new(context, data).process
|
28
|
+
end
|
29
|
+
else
|
30
|
+
app.assets.register_mime_type 'text/html', extensions: ['.html']
|
31
|
+
app.assets.register_bundle_processor 'text/html', ::Sprockets::Bundle
|
32
|
+
app.assets.register_postprocessor 'text/html', Polymer::Rails::Processors::Component
|
38
33
|
end
|
39
34
|
end
|
40
|
-
|
41
35
|
end
|
42
36
|
end
|
43
37
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Polymer
|
2
|
+
module Rails
|
3
|
+
module XmlAdapters
|
4
|
+
class Base
|
5
|
+
|
6
|
+
# HTML Encoding
|
7
|
+
ENCODING = 'UTF-8'
|
8
|
+
|
9
|
+
def self.factory
|
10
|
+
klass = "#{parent}::#{RUBY_PLATFORM =~ /java/ ? 'Jsoup' : 'Nokogiri'}"
|
11
|
+
klass.constantize.new
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
if RUBY_PLATFORM =~ /java/
|
20
|
+
require "polymer-rails/xml_adapters/jsoup"
|
21
|
+
else
|
22
|
+
require "polymer-rails/xml_adapters/nokogiri"
|
23
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
require 'jar_dependencies'
|
3
|
+
require_jar 'org.jsoup', 'jsoup', '1.8.3'
|
4
|
+
|
5
|
+
module Polymer
|
6
|
+
module Rails
|
7
|
+
module XmlAdapters
|
8
|
+
class Jsoup < Base
|
9
|
+
|
10
|
+
def parse_document data
|
11
|
+
doc = org.jsoup.Jsoup.parse_body_fragment(data)
|
12
|
+
doc.output_settings.charset(ENCODING)
|
13
|
+
doc
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_node doc, name, content
|
17
|
+
node = doc.create_element(name)
|
18
|
+
datanode = org.jsoup.nodes.DataNode.new(content, doc.base_uri)
|
19
|
+
node.append_child datanode
|
20
|
+
node
|
21
|
+
end
|
22
|
+
|
23
|
+
def stringify doc
|
24
|
+
doc.select('body').html
|
25
|
+
end
|
26
|
+
|
27
|
+
def replace_node old_node, new_node
|
28
|
+
old_node.replace_with new_node
|
29
|
+
end
|
30
|
+
|
31
|
+
def css_select doc, selector
|
32
|
+
doc.select selector.gsub('\'', '')
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Java::OrgJsoupNodes::Attributes.class_eval do
|
41
|
+
def [] name
|
42
|
+
OpenStruct.new value: get(name)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Java::OrgJsoupNodes::Element.class_eval do
|
47
|
+
alias name nodeName
|
48
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'nokogumbo'
|
3
|
+
|
4
|
+
module Polymer
|
5
|
+
module Rails
|
6
|
+
module XmlAdapters
|
7
|
+
class Nokogiri < Base
|
8
|
+
|
9
|
+
# XML options for to_xml method
|
10
|
+
XML_OPTIONS = { save_with: ::Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS }
|
11
|
+
|
12
|
+
# Nodes that should be parsed as XML nodes
|
13
|
+
XML_NODES = ['*[selected]', '*[checked]', '*[src]:not(script)']
|
14
|
+
|
15
|
+
def parse_document data
|
16
|
+
::Nokogiri::HTML5 data
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_node doc, name, content
|
20
|
+
node = ::Nokogiri::XML::Node.new(name, doc)
|
21
|
+
node.content = content
|
22
|
+
node
|
23
|
+
end
|
24
|
+
|
25
|
+
def replace_node old_node, new_node
|
26
|
+
old_node.replace new_node
|
27
|
+
end
|
28
|
+
|
29
|
+
def stringify doc
|
30
|
+
xml_nodes(doc).reduce(to_html(doc)) do |output, node|
|
31
|
+
output.gsub(node.to_html, node.to_xml(XML_OPTIONS)).encode(ENCODING)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def css_select doc, selector
|
36
|
+
doc.css selector
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def xml_nodes doc
|
41
|
+
doc.css(XML_NODES.join(','))
|
42
|
+
end
|
43
|
+
def to_html doc
|
44
|
+
doc.css("head,body").children.to_html(encoding: ENCODING).lstrip
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,57 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polymer-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Chaplinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '1.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: nokogumbo
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.1.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sprockets
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
61
|
+
version: 3.0.0
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
68
|
+
version: 3.0.0
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: 3.0.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
97
125
|
description: Use of web components and polymer-project in Ruby on Rails projects
|
98
126
|
email:
|
99
127
|
- alchapone@yandex.ru
|
@@ -119,12 +147,15 @@ files:
|
|
119
147
|
- lib/polymer-rails/component.rb
|
120
148
|
- lib/polymer-rails/engine.rb
|
121
149
|
- lib/polymer-rails/helpers/asset_tag_helper.rb
|
122
|
-
- lib/polymer-rails/processors/
|
123
|
-
- lib/polymer-rails/processors/
|
124
|
-
- lib/polymer-rails/processors/
|
125
|
-
- lib/polymer-rails/processors/
|
150
|
+
- lib/polymer-rails/processors/component.rb
|
151
|
+
- lib/polymer-rails/processors/directive.rb
|
152
|
+
- lib/polymer-rails/processors/sprockets_v2_processor.rb
|
153
|
+
- lib/polymer-rails/processors/sprockets_v3_processor.rb
|
126
154
|
- lib/polymer-rails/railtie.rb
|
127
155
|
- lib/polymer-rails/version.rb
|
156
|
+
- lib/polymer-rails/xml_adapters/base.rb
|
157
|
+
- lib/polymer-rails/xml_adapters/jsoup.rb
|
158
|
+
- lib/polymer-rails/xml_adapters/nokogiri.rb
|
128
159
|
homepage: http://github.com/alchapone/polymer-rails
|
129
160
|
licenses:
|
130
161
|
- MIT
|
@@ -1,59 +0,0 @@
|
|
1
|
-
module Polymer
|
2
|
-
module Rails
|
3
|
-
module ComponentsProcessor
|
4
|
-
|
5
|
-
def process
|
6
|
-
inline_styles
|
7
|
-
inline_javascripts
|
8
|
-
require_imports
|
9
|
-
@component.stringify
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def require_imports
|
15
|
-
@component.html_imports.each do |import|
|
16
|
-
@context.require_asset absolute_asset_path(import.attributes['href'].value)
|
17
|
-
import.remove
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def inline_javascripts
|
22
|
-
@component.javascripts.each do |script|
|
23
|
-
@component.replace_node(script, 'script', asset_content(script.attributes['src'].value))
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def inline_styles
|
28
|
-
@component.stylesheets.each do |link|
|
29
|
-
@component.replace_node(link, 'style', asset_content(link.attributes['href'].value))
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def asset_content(file)
|
34
|
-
asset_path = absolute_asset_path(file)
|
35
|
-
asset = find_asset(asset_path)
|
36
|
-
unless asset.blank?
|
37
|
-
@context.depend_on_asset asset_path
|
38
|
-
asset.to_s
|
39
|
-
else
|
40
|
-
nil
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def absolute_asset_path(file)
|
45
|
-
search_file = file.sub(/^(\.\.\/)+/, '/').sub(/^\/*/, '')
|
46
|
-
::Rails.application.assets.paths.each do |path|
|
47
|
-
file_list = Dir.glob( "#{File.absolute_path search_file, path }*")
|
48
|
-
return file_list.first unless file_list.blank?
|
49
|
-
end
|
50
|
-
components = Dir.glob("#{File.absolute_path file, File.dirname(@context.pathname)}*")
|
51
|
-
return components.blank? ? nil : components.first
|
52
|
-
end
|
53
|
-
|
54
|
-
def find_asset(asset_path)
|
55
|
-
::Rails.application.assets.find_asset(asset_path)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'polymer-rails/component'
|
2
|
-
require 'polymer-rails/processors/components_processor'
|
3
|
-
|
4
|
-
module Polymer
|
5
|
-
module Rails
|
6
|
-
class ComponentsProcessorV2 < Sprockets::Processor
|
7
|
-
include ::Polymer::Rails::ComponentsProcessor
|
8
|
-
|
9
|
-
def initialize(context, data)
|
10
|
-
@context = context
|
11
|
-
@component = Component.new(data)
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|