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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eee889a85158656a06f2ee225244f29d2982cbd2
4
- data.tar.gz: d5115b6db5258b3e2bcd437cc50fefd940f3415f
3
+ metadata.gz: 172da4856dff2f533cc1ed9d3473f843b7021436
4
+ data.tar.gz: 101a76825e44c714cfc3493f99eb9f8c8ea4d642
5
5
  SHA512:
6
- metadata.gz: 343758edc279b8878a45746fc084a4b955069131a5cc598401c1f1e8a406a299551266ad525b42f6149ff6c9b2b93e6af6ae8ea187b6dd5a0c3ec7684e00bc29
7
- data.tar.gz: ba367a8117dbd4b4a47ef16082913b7c08d71199f78051f78882df26ce30551593c39d671c471638e15a257abed1d7fb5a027678b67abc06c2808e8164126c4b
6
+ metadata.gz: ba253c60367dd684ee31e07c0eff9dad75146b269175f9bce99168f01aab16c80f5a1d66cad9c26914892001b1e1b1da60663cd170ef70f25a62ff8c8f80c469
7
+ data.tar.gz: 3129ac7e2d073eb79950374296f3e6c67dca6e21df7c5caf85dc9ed6bcee41ea1a0e00cbb630f312a934f501d5f4f0fd73a7d40bac579f6a7f5503b46991d159
@@ -47,7 +47,7 @@ class UIC::Asset
47
47
  end
48
48
 
49
49
  def find(criteria={},&block)
50
- criteria[:under] ||= self
50
+ criteria[:_under] ||= self
51
51
  presentation.find(criteria,&block)
52
52
  end
53
53
 
@@ -298,25 +298,27 @@ class UIC::Presentation
298
298
 
299
299
  def find(options={})
300
300
  index = -1
301
- start = options[:under] ? options[:under].el : @graph
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 if options.key?(:attr) && !options[:attr].all?{ |att,val|
310
- if asset.properties[att.to_s]
311
- value = asset[att.to_s].value
312
- case val
313
- when Regexp then val =~ value.to_s
314
- when Numeric then (val-value).abs < 0.001
315
- when Array then value.to_a.zip(val).map{ |a,b| !b || (a-b).abs<0.001 }.all?
316
- else value == val
317
- end
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
@@ -1,3 +1,3 @@
1
1
  class RUIC
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -5,19 +5,15 @@ show app.errors if app.errors?
5
5
 
6
6
  main = app.main_presentation
7
7
 
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', attr:{position:[-150,60,0]} ).length==2
13
- assert main.find( type:'Model', attr:{position:[-150,60,0]} ).length==2
14
- assert main.find( type:'Model', attr:{position:[nil,60,nil]} ).length==4
15
- assert main.find( type:'Model', attr:{sourcepath:'#Cube'} ).length==1
16
- assert main.find( under:main/"Scene.Layer.Sphere1" ).length==1
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 type:'Model'
29
+ expected = main.find _type:'Model'
34
30
  found = 0
35
- main.find type:'Model' do |mod,i|
31
+ main.find _type:'Model' do |mod,i|
36
32
  found += 1
37
33
  assert mod == expected[i]
38
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RUIC
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Kistner