RUIC 0.2.6 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0cc675abb175c24f21e6c947e4bc3e3abc880c3
4
- data.tar.gz: 5e18d03cc07085cccfeab2062ea326da42f2961a
3
+ metadata.gz: eee889a85158656a06f2ee225244f29d2982cbd2
4
+ data.tar.gz: d5115b6db5258b3e2bcd437cc50fefd940f3415f
5
5
  SHA512:
6
- metadata.gz: 0ff4d45f592471d0b143d3083376d17eabb66e12aa18f56c460b0e5c849571b6af933442c2c1fc7901cf7af0789856d0fdc84513d81feb7cc9b8e095fc1b11b5
7
- data.tar.gz: 33ec67a3e355b8f52e1b5ddbbbca2a578127ea04963a4b8a227d4f207d8131ecfea8d6b3fcd4441d1fe89ab0fc7da77eb87a0adf233c508702eee8865490f177
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 # 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 attributes:{sourcepath:'#Rectangle'} # …or attribute values
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, attributes:{sourcepath:'#Rectangle'}
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', attributes:{ diffuse:[1,0,0] }
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/ # Regex for batch finding
113
- bottom_row = main.find attributes:{position:[nil,-200,nil]} # nil for wildcards
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' # Original asset is never included
118
- group_models = main.find under:group, type:'Model' # Or use `under` for sub-tree
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| # Using the index is optional
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, `attributes:{diffuse:[1,0,0]}` will match a color with `diffuse=".9997 0.0003 0"`_
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
 
@@ -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[:attributes]||={})[:name]=options[:name] if options[:name]
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?(:attributes) && options[:attributes].any?{ |att,val|
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 !~ 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 }.any?
316
- else value != 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
317
  end
318
318
  end
319
319
  }
@@ -1,3 +1,3 @@
1
1
  class RUIC
2
- VERSION = '0.2.6'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -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', attributes:{position:[-150,60,0]} ).length==2
13
- assert main.find( type:'Model', attributes:{position:[-150,60,0]} ).length==2
14
- assert main.find( type:'Model', attributes:{position:[nil,60,nil]} ).length==4
15
- assert main.find( type:'Model', attributes:{sourcepath:'#Cube'} ).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
16
  assert main.find( under:main/"Scene.Layer.Sphere1" ).length==1
17
- assert main.find( attributes:{name:'Material'} ).length==4
18
- assert main.find( attributes:{name:/^Sphere/} ).length==2
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
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.2.6
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Kistner