csl 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/csl/node.rb +16 -10
- data/lib/csl/version.rb +1 -1
- data/spec/csl/node_spec.rb +1 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cab543528f090e62ec1de8296b73a9bed91f6753
|
4
|
+
data.tar.gz: fe30a500160c78d30915572e95a95890817b6b5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ed351e95b6bf9fdd3c38199f2197c9c6c3140ce1b5ad78e7da38be7b7f483c517d63b40acae8967dcfee622ed8cca34072628d75de1f1201a71c7106e9265f4
|
7
|
+
data.tar.gz: e1c5ac96e6826f0178f34dc6dcfeb1b0a112e6b3011dc7925c61ae86954aff362bf924c586e2ea5947722f754aedf3fff3b0ab6b91775a32b00b711613617f85
|
data/lib/csl/node.rb
CHANGED
@@ -474,11 +474,12 @@ module CSL
|
|
474
474
|
attribute?(:'quotes') && !!(attributes[:'quotes'].to_s =~ /^true$/i)
|
475
475
|
end
|
476
476
|
|
477
|
+
|
477
478
|
def <=>(other)
|
478
479
|
return nil unless other.is_a?(Node)
|
479
|
-
|
480
|
-
|
481
|
-
|
480
|
+
comparables <=> other.comparables
|
481
|
+
rescue
|
482
|
+
nil
|
482
483
|
end
|
483
484
|
|
484
485
|
# Returns the node' XML tags (including attribute assignments) as an
|
@@ -511,6 +512,18 @@ module CSL
|
|
511
512
|
def match_conditions
|
512
513
|
end
|
513
514
|
|
515
|
+
def comparables
|
516
|
+
c = []
|
517
|
+
|
518
|
+
c << nodename
|
519
|
+
c << attributes
|
520
|
+
|
521
|
+
c << (textnode? ? text : '')
|
522
|
+
c << (has_children? ? children : [])
|
523
|
+
|
524
|
+
c
|
525
|
+
end
|
526
|
+
|
514
527
|
private
|
515
528
|
|
516
529
|
def attribute_assignments
|
@@ -604,13 +617,6 @@ module CSL
|
|
604
617
|
["<#{attribute_assignments.unshift(nodename).join(' ')}>#{to_s}</#{nodename}>"]
|
605
618
|
end
|
606
619
|
|
607
|
-
def <=>(other)
|
608
|
-
return nil unless other.is_a?(Node)
|
609
|
-
return -1 unless other.textnode?
|
610
|
-
|
611
|
-
[nodename, attributes, text] <=> [other.nodename, other.attributes, other.text]
|
612
|
-
end
|
613
|
-
|
614
620
|
def inspect
|
615
621
|
"#<#{[self.class.name, text.inspect, *attribute_assignments].join(' ')}>"
|
616
622
|
end
|
data/lib/csl/version.rb
CHANGED
data/spec/csl/node_spec.rb
CHANGED
@@ -207,11 +207,11 @@ module CSL
|
|
207
207
|
n1.children[0][:foo] = 'bar'
|
208
208
|
expect(n1).to eq(n2)
|
209
209
|
end
|
210
|
+
|
210
211
|
end
|
211
212
|
end
|
212
213
|
|
213
214
|
describe TextNode do
|
214
|
-
|
215
215
|
it { is_expected.not_to be nil }
|
216
216
|
it { is_expected.not_to have_children }
|
217
217
|
it { is_expected.to have_attributes(:attributes => {}) }
|
@@ -267,11 +267,6 @@ module CSL
|
|
267
267
|
n2.text = 'foo'
|
268
268
|
expect(n1).to eq(n2)
|
269
269
|
end
|
270
|
-
|
271
|
-
it 'text nodes are less than other nodes' do
|
272
|
-
expect(TextNode.new).to be < Node.new
|
273
|
-
expect(Node.new).not_to be < TextNode.new
|
274
|
-
end
|
275
270
|
end
|
276
271
|
end
|
277
272
|
|