RUIC 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruic/assets.rb +1 -1
- data/lib/ruic/presentation.rb +17 -15
- data/lib/ruic/version.rb +1 -1
- data/test/filtering.ruic +11 -15
- 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: 172da4856dff2f533cc1ed9d3473f843b7021436
|
4
|
+
data.tar.gz: 101a76825e44c714cfc3493f99eb9f8c8ea4d642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba253c60367dd684ee31e07c0eff9dad75146b269175f9bce99168f01aab16c80f5a1d66cad9c26914892001b1e1b1da60663cd170ef70f25a62ff8c8f80c469
|
7
|
+
data.tar.gz: 3129ac7e2d073eb79950374296f3e6c67dca6e21df7c5caf85dc9ed6bcee41ea1a0e00cbb630f312a934f501d5f4f0fd73a7d40bac579f6a7f5503b46991d159
|
data/lib/ruic/assets.rb
CHANGED
data/lib/ruic/presentation.rb
CHANGED
@@ -298,25 +298,27 @@ class UIC::Presentation
|
|
298
298
|
|
299
299
|
def find(options={})
|
300
300
|
index = -1
|
301
|
-
start = options
|
302
|
-
(options[:attr]||={})[:name]=options[:name] if options[:name]
|
301
|
+
start = options.key?(:_under) ? options.delete(:_under).el : @graph
|
303
302
|
[].tap do |result|
|
304
303
|
start.xpath('./descendant::*').each do |el|
|
305
|
-
next if options.key?(:type) && el.name != options[:type]
|
306
|
-
next if options.key?(:slide) && !has_slide?(el,options[:slide])
|
307
|
-
next if options.key?(:master) && master?(el)!= options[:master]
|
308
304
|
asset = asset_for_el(el)
|
309
|
-
next
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
305
|
+
next unless options.all? do |att,val|
|
306
|
+
case att
|
307
|
+
when :_type then el.name == val
|
308
|
+
when :_slide then has_slide?(el,val)
|
309
|
+
when :_master then master?(el)==val
|
310
|
+
else
|
311
|
+
if asset.properties[att.to_s]
|
312
|
+
value = asset[att.to_s].value
|
313
|
+
case val
|
314
|
+
when Regexp then val =~ value.to_s
|
315
|
+
when Numeric then (val-value).abs < 0.001
|
316
|
+
when Array then value.to_a.zip(val).map{ |a,b| !b || (a-b).abs<0.001 }.all?
|
317
|
+
else value == val
|
318
|
+
end
|
319
|
+
end
|
318
320
|
end
|
319
|
-
|
321
|
+
end
|
320
322
|
yield asset, index+=1 if block_given?
|
321
323
|
result << asset
|
322
324
|
end
|
data/lib/ruic/version.rb
CHANGED
data/test/filtering.ruic
CHANGED
@@ -5,19 +5,15 @@ show app.errors if app.errors?
|
|
5
5
|
|
6
6
|
main = app.main_presentation
|
7
7
|
|
8
|
-
assert main.find(
|
9
|
-
assert main.find(
|
10
|
-
assert main.find(
|
11
|
-
assert main.find(
|
12
|
-
assert main.find(
|
13
|
-
assert main.find(
|
14
|
-
assert main.find(
|
15
|
-
assert main.find(
|
16
|
-
assert main.find(
|
17
|
-
assert main.find( attr:{name:'Material'} ).length==4
|
18
|
-
assert main.find( attr:{name:/^Sphere/} ).length==2
|
19
|
-
|
20
|
-
# You can use name not as an attribute
|
8
|
+
assert main.find( _type:'Model' ).length==4
|
9
|
+
assert main.find( _type:'Model', _slide:0 ).length==3
|
10
|
+
assert main.find( _type:'Model', _slide:1 ).length==4
|
11
|
+
assert main.find( _type:'Model', _slide:1, _master:false ).length==1
|
12
|
+
assert main.find( _type:'Model', position:[-150,60,0] ).length==2
|
13
|
+
assert main.find( _type:'Model', position:[-150,60,0] ).length==2
|
14
|
+
assert main.find( _type:'Model', position:[nil,60,nil] ).length==4
|
15
|
+
assert main.find( _type:'Model', sourcepath:'#Cube' ).length==1
|
16
|
+
assert main.find( _under:main/"Scene.Layer.Sphere1" ).length==1
|
21
17
|
assert main.find( name:'Material' ).length==4
|
22
18
|
assert main.find( name:/^Sphere/ ).length==2
|
23
19
|
|
@@ -30,9 +26,9 @@ sphere = main/"Scene.Layer.Sphere1"
|
|
30
26
|
assert sphere.find.length==1
|
31
27
|
|
32
28
|
# Supplying a block will iterate, including the index
|
33
|
-
expected = main.find
|
29
|
+
expected = main.find _type:'Model'
|
34
30
|
found = 0
|
35
|
-
main.find
|
31
|
+
main.find _type:'Model' do |mod,i|
|
36
32
|
found += 1
|
37
33
|
assert mod == expected[i]
|
38
34
|
end
|