RUIC 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -19
- data/lib/ruic/presentation.rb +6 -6
- data/lib/ruic/version.rb +1 -1
- data/test/filtering.ruic +6 -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: eee889a85158656a06f2ee225244f29d2982cbd2
|
4
|
+
data.tar.gz: d5115b6db5258b3e2bcd437cc50fefd940f3415f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 343758edc279b8878a45746fc084a4b955069131a5cc598401c1f1e8a406a299551266ad525b42f6149ff6c9b2b93e6af6ae8ea187b6dd5a0c3ec7684e00bc29
|
7
|
+
data.tar.gz: ba367a8117dbd4b4a47ef16082913b7c08d71199f78051f78882df26ce30551593c39d671c471638e15a257abed1d7fb5a027678b67abc06c2808e8164126c4b
|
data/README.md
CHANGED
@@ -47,7 +47,7 @@ After this you can access the application as `app`:
|
|
47
47
|
|
48
48
|
```ruby
|
49
49
|
uia '../MyApp.uia' # Relative to the ruic script file, or absolute
|
50
|
-
|
50
|
+
|
51
51
|
show app.file #=> /var/projects/UIC/MyApp/main/MyApp.uia
|
52
52
|
show app.filename #=> MyApp.uia
|
53
53
|
|
@@ -85,7 +85,7 @@ show car.type #=> Model # Scene, Layer, Camera, Light, Group, M
|
|
85
85
|
# Image, Behavior, Effect, ReferencedMaterial, Text,
|
86
86
|
# RenderPlugin, Component, (custom materials)
|
87
87
|
|
88
|
-
show car.component? #=> false # Ask if an element is a component
|
88
|
+
show car.component? #=> false # Ask if an element is a component
|
89
89
|
assert car.component==sub.scene # Ask for the owning component; may be the scene
|
90
90
|
```
|
91
91
|
|
@@ -95,30 +95,30 @@ assert car.component==sub.scene # Ask for the owning component; may be
|
|
95
95
|
uia 'MyApp.uia'
|
96
96
|
main = app.main_presentation
|
97
97
|
|
98
|
-
every_asset = main.find
|
99
|
-
master_assets = main.find master:true
|
100
|
-
models = main.find type:'Model'
|
101
|
-
gamecovers = main.find name:'Game Cover'
|
102
|
-
slide2_assets = main.find slide:2
|
103
|
-
rectangles = main.find
|
98
|
+
every_asset = main.find # Array of matching assets
|
99
|
+
master_assets = main.find master:true # Test for master/nonmaster
|
100
|
+
models = main.find type:'Model' # …or based on type
|
101
|
+
gamecovers = main.find name:'Game Cover' # …or based on name
|
102
|
+
slide2_assets = main.find slide:2 # …or presence on slide
|
103
|
+
rectangles = main.find attr:{sourcepath:'#Rectangle'} # …or attribute values
|
104
104
|
|
105
105
|
# Combine tests to get more specific
|
106
|
-
master_models = main.find type:'Model', master:true
|
107
|
-
slide2_rects = main.find type:'Model', slide:2,
|
106
|
+
master_models = main.find type:'Model', master:true
|
107
|
+
slide2_rects = main.find type:'Model', slide:2, attr:{sourcepath:'#Rectangle'}
|
108
108
|
nonmaster_s2 = main.find slide:2, master:false
|
109
|
-
red_materials = main.find type:'Material',
|
109
|
+
red_materials = main.find type:'Material', attr:{ diffuse:[1,0,0] }
|
110
110
|
|
111
111
|
# You can match values more loosely
|
112
|
-
pistons = main.find name:/^Piston/
|
113
|
-
bottom_row = main.find
|
112
|
+
pistons = main.find name:/^Piston/ # Regex for batch finding
|
113
|
+
bottom_row = main.find attr:{position:[nil,-200,nil]} # nil for wildcards in vectors
|
114
114
|
|
115
115
|
# Restrict the search to a sub-tree
|
116
116
|
group = main/"Scene.Layer.Group"
|
117
|
-
group_models = group.find type:'Model'
|
118
|
-
group_models = main.find under:group, type:'Model'
|
117
|
+
group_models = group.find type:'Model' # Orig asset is never included
|
118
|
+
group_models = main.find under:group, type:'Model' # Or use `under` for sub-tree
|
119
119
|
|
120
120
|
# Iterate the results as they are found
|
121
|
-
main.find type:'Model', name:/^Piston/ do |model, index|
|
121
|
+
main.find type:'Model', name:/^Piston/ do |model, index| # Using the index is optional
|
122
122
|
show "Model #{index} is named #{model.name}"
|
123
123
|
end
|
124
124
|
```
|
@@ -126,7 +126,7 @@ end
|
|
126
126
|
Notes:
|
127
127
|
* `nil` inside an array is a "wildcard" value, allowing you to test only specific values
|
128
128
|
* Numbers (both in vectors/colors/rotations and float/long values) must only be within `0.001` to match.
|
129
|
-
* _For example, `
|
129
|
+
* _For example, `attr:{diffuse:[1,0,0]}` will match a color with `diffuse=".9997 0.0003 0"`_
|
130
130
|
* Results of `find` are always in scene-graph order.
|
131
131
|
|
132
132
|
|
@@ -158,12 +158,12 @@ app.save_all! #=> Write presentations in place
|
|
158
158
|
|
159
159
|
## Locating MetaData.xml
|
160
160
|
RUIC needs access to a UIC `MetaData.xml` file to understand the properties in the various XML files.
|
161
|
-
By default RUIC will look in the location specified by `RUIC::DEFAULTMETADATA`, e.g.
|
161
|
+
By default RUIC will look in the location specified by `RUIC::DEFAULTMETADATA`, e.g.
|
162
162
|
`C:/Program Files (x86)/NVIDIA Corporation/UI Composer 8.0/res/DataModelMetadata/en-us/MetaData.xml`
|
163
163
|
|
164
164
|
If this file is in another location, you can tell the script where to find it either:
|
165
165
|
|
166
|
-
* on the command line: `ruic -m path/to/MetaData.xml myscript.ruic`
|
166
|
+
* on the command line: `ruic -m path/to/MetaData.xml myscript.ruic`
|
167
167
|
* in your ruic script: `metadata 'path/to/MetaData.xml' # before any 'app' commands`
|
168
168
|
|
169
169
|
|
@@ -219,6 +219,11 @@ _In decreasing priority…_
|
|
219
219
|
|
220
220
|
# History
|
221
221
|
|
222
|
+
## v0.3.0 - 2014-Nov-10
|
223
|
+
* Switch attribute filtering to use `attr:{ … }` instead of `attributes:{ … }`
|
224
|
+
* Attribute matching now requires that a requested attribute be present, or else the asset matching fails.
|
225
|
+
* _For example, `main.find attr:{ diffusecolor:[nil,nil,nil] }` will now only find assets with a `diffusecolor` attribute._
|
226
|
+
|
222
227
|
## v0.2.5 - 2014-Nov-10
|
223
228
|
* Re-adds blank line after REPL result.
|
224
229
|
|
data/lib/ruic/presentation.rb
CHANGED
@@ -299,21 +299,21 @@ class UIC::Presentation
|
|
299
299
|
def find(options={})
|
300
300
|
index = -1
|
301
301
|
start = options[:under] ? options[:under].el : @graph
|
302
|
-
(options[:
|
302
|
+
(options[:attr]||={})[:name]=options[:name] if options[:name]
|
303
303
|
[].tap do |result|
|
304
304
|
start.xpath('./descendant::*').each do |el|
|
305
305
|
next if options.key?(:type) && el.name != options[:type]
|
306
306
|
next if options.key?(:slide) && !has_slide?(el,options[:slide])
|
307
307
|
next if options.key?(:master) && master?(el)!= options[:master]
|
308
308
|
asset = asset_for_el(el)
|
309
|
-
next if options.key?(:
|
309
|
+
next if options.key?(:attr) && !options[:attr].all?{ |att,val|
|
310
310
|
if asset.properties[att.to_s]
|
311
311
|
value = asset[att.to_s].value
|
312
312
|
case val
|
313
|
-
when Regexp then val
|
314
|
-
when Numeric then (val-value).abs
|
315
|
-
when Array then value.to_a.zip(val).map{ |a,b| b
|
316
|
-
else value
|
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
317
|
end
|
318
318
|
end
|
319
319
|
}
|
data/lib/ruic/version.rb
CHANGED
data/test/filtering.ruic
CHANGED
@@ -9,13 +9,13 @@ assert main.find( type:'Model' ).length==4
|
|
9
9
|
assert main.find( type:'Model', slide:0 ).length==3
|
10
10
|
assert main.find( type:'Model', slide:1 ).length==4
|
11
11
|
assert main.find( type:'Model', slide:1, master:false ).length==1
|
12
|
-
assert main.find( type:'Model',
|
13
|
-
assert main.find( type:'Model',
|
14
|
-
assert main.find( type:'Model',
|
15
|
-
assert main.find( type:'Model',
|
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
16
|
assert main.find( under:main/"Scene.Layer.Sphere1" ).length==1
|
17
|
-
assert main.find(
|
18
|
-
assert main.find(
|
17
|
+
assert main.find( attr:{name:'Material'} ).length==4
|
18
|
+
assert main.find( attr:{name:/^Sphere/} ).length==2
|
19
19
|
|
20
20
|
# You can use name not as an attribute
|
21
21
|
assert main.find( name:'Material' ).length==4
|