{"id":16125642,"url":"https://github.com/phrogz/ruic","last_synced_at":"2025-04-14T23:53:43.009Z","repository":{"id":20665024,"uuid":"23947492","full_name":"Phrogz/RUIC","owner":"Phrogz","description":"Ruby API for NVIDIA's UI Composer, with a mini DSL for easy analysis and manipulation.","archived":false,"fork":false,"pushed_at":"2015-12-22T16:29:17.000Z","size":2782,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T23:53:29.524Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Phrogz.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-12T05:01:25.000Z","updated_at":"2017-09-22T16:46:31.000Z","dependencies_parsed_at":"2022-08-20T16:10:20.135Z","dependency_job_id":null,"html_url":"https://github.com/Phrogz/RUIC","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phrogz%2FRUIC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phrogz%2FRUIC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phrogz%2FRUIC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phrogz%2FRUIC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Phrogz","download_url":"https://codeload.github.com/Phrogz/RUIC/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248981261,"owners_count":21193144,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T21:30:19.183Z","updated_at":"2025-04-14T23:53:42.993Z","avatar_url":"https://github.com/Phrogz.png","language":"Ruby","readme":"# What is RUIC?\nRUIC is a Ruby API for reading, analyzing, and manipulating application assets created by [NVIDIA DRIVE™ Design][1]. Among other things, it allows you to:\n\n* See if an application is missing any assets (e.g. images or meshes) and what parts of the application are looking for those.\n* See if there are any files in the application folder that you can delete (e.g. images or materials that are no longer being used).\n* Read and modify the attributes of elements on different slides.\n* Batch change attributes (e.g. change all usage of one font or color to another).\n* Procedurally generate many models with automated placement in your scene.\n\n_Some of the features above are planned, but not yet implemented; see Known Limitations below._\n\n\n# Documentation\n\nIn addition to the examples in this file full API documentation is available at:\nhttp://www.rubydoc.info/gems/RUIC/\n\n\n\n# Installing RUIC\nRUIC can be installed via RubyGems (part of Ruby) via the command:\n\n    gem install ruic   # May need `sudo gem install ruic` depending on your setup\n\nAlthough RUIC is a pure-Ruby library, it relies on [Nokogiri][2] for all the XML processing and manipulation. Installing RUIC will also automatically install Nokogiri, which may require some compilation.\n\n\n\n# Using the RUIC DSL\n\nRUIC scripts are pure Ruby with a few convenience methods added. You run them via the `ruic` command-line script, e.g.\n\n    ruic myscript.ruic  # or .rb extension, for syntax highlighting while editing\n\n\n## Creating and Accessing Applications\nRUIC scripts must start with `uia` commands to load an application and all its assets.\nAfter this you can access the application as `app`:\n\n```ruby\nuia '../MyApp.uia'      # Relative to the ruic script file, or absolute\n\nshow app.file           #=\u003e /var/projects/MyApp/main/MyApp.uia\nshow app.filename       #=\u003e MyApp.uia\n\nshow app.assets.count   #=\u003e 7\n# You can ask for app.behaviors, app.presentations, app.statemachines, and app.renderplugins\n# for arrays of specific asset types\n```\n\n_The `show` command prints the result; it is simply a nicer alias for `puts`._\n\nIf you need to load multiple applications in the same script, subsequent `uia` commands will create\n`app2`, `app3`, etc. for you to use.\n\n```ruby\nuia '../MyApp.uia'       # Available as 'app'\nuia '../../v1/MyApp.uia' # Available as 'app2'\n```\n\n\n## Working with Presentations\n\n```ruby\nuia '../MyApp.uia'\n\nmain = app.main_presentation   # The presentation displayed as the main presentation (regardless of id)\nsub  = app['#nav']             # You can ask for an asset based on the id in the .uia...\nsub  = app['Navigation.uip']   # or based on the path to the file (relative to the .uia)\n\n\ncar = sub/\"Scene.Vehicle.Group.Car\"      # Find elements in a presentation by presentation path…\ncar = app/\"nav:Scene.Vehicle.Group.Car\"  # …or absolute application path\n\nshow car.name #=\u003e Car\nshow car.type #=\u003e Model                  # Scene, Layer, Camera, Light, Group, Model, Material,\n                                         # Image, Behavior, Effect, ReferencedMaterial, Text,\n                                         # RenderPlugin, Component, (custom materials)\n\nshow car.component?  #=\u003e false           # Ask if an element is a component\nassert car.component==sub.scene          # Ask for the owning component; may be the scene\n```\n\n## Finding Many Assets\n\n```ruby\nuia 'MyApp.uia'\nmain = app.main_presentation\n\nevery_asset   = main.find                                  # Array of matching assets\nmaster_assets = main.find _master:true                     # Test for master/nonmaster\nmodels        = main.find _type:'Model'                    # …or based on type\nslide2_assets = main.find _slide:2                         # …or presence on slide\nrectangles    = main.find sourcepath:'#Rectangle'          # …or attribute values\ngamecovers    = main.find name:'Game Cover'                # …including the name\n\n# Combine tests to get more specific\nmaster_models = main.find _type:'Model', _master:true\nslide2_rects  = main.find _type:'Model', _slide:2, sourcepath:'#Rectangle'\nnonmaster_s2  = main.find _slide:2, _master:false\nred_materials = main.find _type:'Material', diffuse:[1,0,0]\n\n# You can match values more loosely\npistons       = main.find name:/^Piston/                   # Regex for batch finding\nbottom_row    = main.find position:[nil,-200,nil]          # nil for wildcards in vectors\n\n# Restrict the search to a sub-tree\ngroup        = main/\"Scene.Layer.Group\"\ngroup_models = group.find _type:'Model'                    # Orig asset is never included\ngroup_models = main.find _under:group, _type:'Model'       # Or, use `_under` to limit\n\n# Iterate the results as they are found\nmain.find _type:'Model', name:/^Piston/ do |model, index|  # Using the index is optional\n\tshow \"Model #{index} is named #{model.name}\"\nend\n```\n\nNotes:\n\n* `nil` inside an array is a \"wildcard\" value, allowing you to test only specific values\n* Numbers (both in vectors/colors/rotations and float/long values) must only be within `0.001` to match.\n  * _For example, `attr:{diffuse:[1,0,0]}` will match a color with `diffuse=\".9997 0.0003 0\"`_\n* Results of `find` are always in scene-graph order.\n\n\n## Working with References\n\n```ruby\nuia 'MyApp.uia'\nmat1 = app/\"main:Scene.Layer.Sphere.Material\" # A standard NDD Material\nmat2 = app/\"main:Scene.Layer.Cube.Material\"   # A standard NDD Material\np mat2.type                                   #=\u003e \"Material\"\nref = mat2.replace_with_referenced_material   # A very specific method :)\np ref.properties['referencedmaterial'].type   #=\u003e \"ObjectRef\"\np ref['referencedmaterial',0].object          #=\u003e nil\np ref['referencedmaterial',0].type            #=\u003e :absolute\nref['referencedmaterial',0].object = mat1     #=\u003e Sets an absolute reference\nref['referencedmaterial',0].type = :path      #=\u003e Use a relative path instead\n\n# Alternatively, you can omit the .object when setting the reference:\n# ref['referencedmaterial',0] = mat1\n\nmat3 = ref['referencedmaterial',1].object     #=\u003e Get the asset pointed to\nassert mat1 == mat3                           #=\u003e They are the same! It worked!\n\napp.save_all!                                 #=\u003e Write presentations in place\n```\n\n\n## Locating MetaData.xml\nRUIC needs access to a NDD `MetaData.xml` file to understand the properties in the various XML files.\nBy default RUIC will look in the location specified by `RUIC::DEFAULTMETADATA`, e.g.\n`C:\\Program Files (x86)\\NVIDIA Corporation\\DRIVE Design 8.5\\res\\DataModelMetadata\\en-us\\MetaData.xml`\n\nIf this file is in another location, you can tell the script where to find it either:\n\n* on the command line: `ruic -m path/to/MetaData.xml myscript.ruic`\n* in your ruic script: `metadata 'path/to/MetaData.xml' # before any 'app' commands`\n\n\n# Interactive RUIC\nIn addition to executing a standalone script, RUIC also has a REPL (like IRB) that allows you to\ninteractively execute and test changes to your application/presentations before saving.\nThere are two ways to enter interactive mode:\n\n* If you invoke the `ruic` binary with a `.uia` file as the argument the interpreter will load\n  the application and enter the REPL:\n\n      $ ruic myapp.uia\n      (RUIC v0.6.0 interactive session; 'quit' or ctrl-d to end)\n\n      uia \"test/projects/SimpleScene/SimpleScene.uia\"\n      #=\u003e \u003cNDD::Application 'SimpleScene.uia'\u003e\n\n* Alternatively, you can have RUIC execute a script and then enter the interactive REPL\n  by supplying the `-i` command-line switch:\n\n      $ ruic -i test/referencematerials.ruic\n      (RUIC v0.6.0 interactive session; 'quit' or ctrl-d to end)\n\n      app\n      #=\u003e \u003cNDD::Application 'ReferencedMaterials.uia'\u003e\n\n      cubemat\n      #=\u003e \u003casset Material#Material_002\u003e\n\n  As shown above, all local variables created by the script continue to be available\n  in the interactive session.\n\n\n\n# Known Limitations (aka TODO)\n_In decreasing priority…_\n\n- Report on image assets, their sizes\n- Report used assets (and where they are used)\n- Report unused assets (in a format suitable for automated destruction)\n- Report missing assets (and who was looking for them)\n- Gobs more unit tests\n- Parse .lua headers (in case one references an image)\n- Parse render plugins\n- Read/edit animation tracks\n- Find all colors, and where they are used\n- Visual actions for State Machines\n- Create new presentation assets (e.g. add a new sphere)\n- Modify the scene graph of presentations\n- Create new presentations/applications from code\n- Report on image asset file formats (e.g. find PNGs, find DXT1 vs DXT3 vs DXT Luminance…)\n\n\n\n# License \u0026 Contact\nRUIC is copyright ©2014 by Gavin Kistner and is licensed under the [MIT License][3]. See the `LICENSE` file for more details.\n\nFor bugs or feature requests please open [issues on GitHub][4]. For other communication you can [email the author directly](mailto:!@phrogz.net?subject=RUIC).\n\n[1]: http://www.nvidia.com/object/drive-design.html\n[2]: http://nokogiri.org\n[3]: http://opensource.org/licenses/MIT\n[4]: https://github.com/Phrogz/RUIC/issues\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphrogz%2Fruic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphrogz%2Fruic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphrogz%2Fruic/lists"}