The Ruby API is runtime (eg. SketchUp needs to be open) so there is already a Publish function within the TC extension. You could write your own, but you would need to use the Trimble Connect API:
Integrations Overview | Trimble Connect
But, why invent the wheel if you have access to Trimble Connect Sync?
You can manage your data and set sync roots (what local folder/files) to your Project(s), set filters for stuff you don’t want in the cloud, alerts, timed schedules or manual, choose what direction (bi-directional, upload or download only etc…)
Per example, here’s a thread for setting it up for local libraries: