Greetings all. I have some controller code that uses win32ole (only available on windows). This code is now solid, and I'd now like to resume development on (any) other OS(grin). But alas, the controller bails because the OS specific library can't be found. Can I conditionally specify action code compilation (and a require 'win32ole') based on OS or maybe an environment variable? (I'm thinking C #IFDEFs) Or perhaps an empty stub win32ole library for OSX/Linux? Thanks for your thoughts. Cheers, Jodi
on 2006-05-06 04:14
on 2006-05-06 04:38
I think you will want to hide the OS dependent stuff in a class. The class can then detect the operating system and respond with the desired functionality if available, or fail gracefully if not. I think you can detect the operating system from the Ruby config file. This is from "Programming Ruby": require "rbconfig.rb" include Config CONFIG["host"] â?? "i686-pc-linux" CONFIG["LDFLAGS"] â?? "-rdynamic" Try playing around with CONFIG and see if there are values in there that will tell you what you need to know. Eden
on 2006-05-06 04:53
Great info Eden - thanx. I'll dig in.
on 2006-05-06 05:36
Although my implementation will vary the core code looks like, require 'rbconfig' include Config require 'win32ole' if CONFIG["build_os"] =~ /mswin/ Thanx Eden - Happy to be back testing on osx! J