Jodi Showers
2006-May-06 00:14 UTC
[Rails] [BUMP] conditional require? conditional action code?
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
Eden Brandeis
2006-May-06 00:36 UTC
[Rails] [BUMP] conditional require? conditional action code?
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 5/5/06, Jodi Showers <jodi@nnovation.ca> wrote:> > 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060506/c833e1bf/attachment.html
Jodi Showers
2006-May-06 00:52 UTC
[Rails] [BUMP] conditional require? conditional action code?
Great info Eden - thanx. I''ll dig in. On 5-May-06, at 8:36 PM, Eden Brandeis wrote:> 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 5/5/06, Jodi Showers <jodi@nnovation.ca> wrote: > 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060506/1e70f721/attachment.html
Jodi Showers
2006-May-06 01:34 UTC
[Rails] [BUMP] conditional require? conditional action code? Solved
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 On 5-May-06, at 8:36 PM, Eden Brandeis wrote:> 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 5/5/06, Jodi Showers <jodi@nnovation.ca> wrote: > 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060506/cc6a550d/attachment.html