From: "D. Deryl Downey" Date: 2013-01-04T12:08:06+09:00 Subject: Re: Cross-platform gems / conditional loading of gems This is a multi-part message in MIME format. --------------050202020706040405030503 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit In my config/database.yml I have the following: development: adapter: <%= "jdbc" if defined?(JRUBY_PLATFORM) %>sqlite3 database: db/dtf_development.sqlite3 pool: 5 timeout: 5000 In my spec/spec_helper I have the following (Need to change the YAML engine used under JRuby): # Set the YAML engine for JRuby if RUBY_PLATFORM == "java" ::YAML::ENGINE.yamler = 'psych' end When working with gems (as in writing them) use this in your gemspec for specifying a specific sqlite3 based on the platform: gem.add_dependency "sqlite3" if RUBY_PLATFORM == "ruby" gem.add_dependency "jdbc-sqlite3" if RUBY_PLATFORM == "java" #gem.add_dependency "activerecord-jdbcsqlite3-adapter" if RUBY_PLATFORM == "java" gem.add_dependency "jruby-openssl" if RUBY_PLATFORM == "java" In these instances, I am adapting to change for use with JRuby. Modify as you need for the Windows platform. > Intransition > January 3, 2013 9:04 PM > Try something like: > > if RUBY_PLATFORM =~ /(win|ming)/ > ... > else > ... > end > > > Alex Allmont > January 3, 2013 6:59 AM > > Hi all, > > We use ruby as part of our development team tools for Windows and Mac > machines. This is maintained internally in an SVN repository where > the platform-specific files are interleaved, i.e. the bin/ directory > contains both a Windows ruby.exe and a Mac ruby executable. This > repository is packaged into installers so we can deploy to our dev > team ensuring that everyone has the correct ruby version and gems. > > New gems are installed on an administrator's machine and SVN added to > the gems folder (and the corresponding gemspec is added to the > specifications folder). Most of these are platform agnostic but we > have a few that are Windows-only, e.g. qtbindings. > > This was working fine until trying to get sqlite3 running on both PC > and Mac. The PC version was installed first > (gems/sqlite3-1.3.6-x86-mingw32) and this worked fine. The mingw32 > version is PC only so I installed sqlite3 on an OSX machine which > added the new gem to gems\sqlite3-1.3.6. > > This new gem conflicts with the PC version, e.g. attempting to require > via IRB on the Mac: > > irb(main):001:0> require 'sqlite3' > > LoadError: cannot load such file -- sqlite3/sqlite3_native > > from > /Users/aallmont/nm/buildtools/ruby/1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in > `require' > > from > /Users/aallmont/nm/buildtools/ruby/1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in > `require' > > This error goes away if I remove the gems/sqlite3-1.3.6-x86-mingw32 > folder on the Mac. There is a similar error on the PC which goes away > if I remove the gems/sqlite3-1.3.6-x86 folder, i.e. they are mutually > exclusive. > > I would like to only load gems/sqlite3-1.3.6-x86 when running on the > Mac and only load gems/sqlite3-1.3.6-x86-mingw32 when running on the > PC. Is this possible? > > Many thanks, > > Alex > -- D. Deryl Downey "The bug which you would fright me with I seek" - William Shakespeare - The Winter's Tale, Act III, Scene II - A court of Justice. --------------050202020706040405030503 Content-Type: multipart/related; boundary="------------090702000409020903010606" --------------090702000409020903010606 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit In my config/database.yml I have the following:

development:
  adapter: <%= "jdbc" if defined?(JRUBY_PLATFORM) %>sqlite3
  database: db/dtf_development.sqlite3
  pool: 5
  timeout: 5000


In my spec/spec_helper I have the following (Need to change the YAML engine used under JRuby):

# Set the YAML engine for JRuby
if RUBY_PLATFORM == "java"
  ::YAML::ENGINE.yamler = 'psych'
end

When working with gems (as in writing them) use this in your gemspec for specifying a specific sqlite3 based on the platform:

  gem.add_dependency "sqlite3" if RUBY_PLATFORM == "ruby"

  gem.add_dependency "jdbc-sqlite3" if RUBY_PLATFORM == "java"
  #gem.add_dependency "activerecord-jdbcsqlite3-adapter" if RUBY_PLATFORM == "java"
  gem.add_dependency "jruby-openssl" if RUBY_PLATFORM == "java"


In these instances, I am adapting to change for use with JRuby. Modify as you need for the Windows platform.


January 3, 2013 9:04 PM
Try something like:

    if RUBY_PLATFORM =~ /(win|ming)/
      ...
    else
      ...
    end


January 3, 2013 6:59 AM

Hi all,

 

We use ruby as part of our development team tools for Windows and Mac machines.  This is maintained internally in an SVN repository where the platform-specific files are interleaved, i.e. the bin/ directory contains both a Windows ruby.exe and a Mac ruby executable.  This repository is packaged into installers so we can deploy to our dev team ensuring that everyone has the correct ruby version and gems.

 

New gems are installed on an administrator’s machine and SVN added to the gems folder (and the corresponding gemspec is added to the specifications folder).  Most of these are platform agnostic but we have a few that are Windows-only, e.g. qtbindings.

 

This was working fine until trying to get sqlite3 running on both PC and Mac.  The PC version was installed first (gems/sqlite3-1.3.6-x86-mingw32) and this worked fine.  The mingw32 version is PC only so I installed sqlite3 on an OSX machine which added the new gem to gems\sqlite3-1.3.6.

 

This new gem conflicts with the PC version, e.g. attempting to require via IRB on the Mac:

 

irb(main):001:0> require 'sqlite3'

LoadError: cannot load such file -- sqlite3/sqlite3_native

                from /Users/aallmont/nm/buildtools/ruby/1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'

                from /Users/aallmont/nm/buildtools/ruby/1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'

 

This error goes away if I remove the gems/sqlite3-1.3.6-x86-mingw32 folder on the Mac.  There is a similar error on the PC which goes away if I remove the gems/sqlite3-1.3.6-x86 folder, i.e. they are mutually exclusive.

 

I would like to only load gems/sqlite3-1.3.6-x86 when running on the Mac and only load gems/sqlite3-1.3.6-x86-mingw32 when running on the PC.  Is this possible?

 

Many thanks,

Alex

 


--
D. Deryl Downey
"The bug which you would fright me with I seek" - William Shakespeare - The Winter's Tale, Act III, Scene II - A court of Justice.


--------------090702000409020903010606 Content-Type: image/jpeg; x-apple-mail-type=stationery; name="postbox-contact.jpg" Content-Transfer-Encoding: base64 Content-ID: Content-Disposition: inline; filename="postbox-contact.jpg" /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgK CgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDAwQDBAgEBAgQCwkL EBAQEBAQEBAQEBAQEBAQEB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7N9O56+S5nRxc6eHzGCcY7S2cbem69TnrLVfFsHg/R/gnc2ls3j03GnyG3 0GWR49L0+GaJllupzhR8kTDapwxIAFQqlTkjRfxeXQ6fqeEVepmdN/uLNXl9qWukVv1OZ/tm 6/54P/32P8a77zPj/aR7Htd/4StPFvws8NW1wb601S6jsUsrmwuWiuNOuoYeHOOAyMrBkPBy QaqrTdSNluPBYuWCq86SlF6NPqjzbxV4B8U397oHxS+NWpSWa+BbqW51CG1neS3nt7cOYbqC BBhZZHZGYMTjAAxnFedKlPmU6vQ+nw2Ow/v4LAR1qKy02b3u+yR6d8ILbUYX1b4keKNIbT7j xZMLsJMwBsLKGILbRy+h2BnPo0mO1deGi7urJWv+R5ueV6cHTwFCV4U1v0cnuz53/snxd/0L Grf+AMv/AMTXRc8EvftB/wDJY/EP/X9/7SWrEzzjU/8AUTf9c/61D2NqH8RG78P/APkZfD3/ AGEbX/0ctV2Il8TP0ppkn//Z --------------090702000409020903010606 Content-Type: image/jpeg; x-apple-mail-type=stationery; name="compose-unknown-contact.jpg" Content-Transfer-Encoding: base64 Content-ID: Content-Disposition: inline; filename="compose-unknown-contact.jpg" /9j/4AAQSkZJRgABAQEARwBHAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEC AQEBAQEBAgICAgICAgICAgICAgICAgICAgICAgICAgICAgL/2wBDAQEBAQEBAQICAgICAgIC AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgL/wAAR CAAZABkDAREAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAABgcICQr/xAA0EAABAwMCAgUK BwAAAAAAAAACAQMEBQYRABITIQcUMUF2CBUXIjI2N0JRtVRWkZOV0dL/xAAYAQEAAwEAAAAA AAAAAAAAAAADAAEEAv/EACQRAAICAAQGAwAAAAAAAAAAAAABAhEDMrHREyExM0FxgfDx/9oA DAMBAAIRAxEAPwDuEt+gW/ULet6oVC3rfqNQqFv0OfPn1GhUqfOmzZtKZlS5UqZMaNwzNwiJ VIl7eXLCaZIGwBl3TY8epPx2+jy2ZNPjvkwc9uhW8j7nCPhvOsQliYIeS7cvCpp8o50qwrC4 v3lsNSDbdmTEhvs2tahxpfV3WnmbbozJEw/gwdadbYExVRXKEKoSdvJcaOSqxE7/AAiX0gXx +a69/JSf9alIlste0VzaNpeFrcT9KKymotyiaZ0KRCnzacoE7Kjzn4gi2KqUh3jqDHDHv4mR UfruTWlMzlVUKIVNp9GguEJnAh0+IZjyAiisgyRDnu5azS8miKqjOTVkKqS/psG37fo1Fbab eg25b8eZPeFJBBJSjMG5HjMeyihnaauZwe4OGiju13GAcpOwBeN+U8/IkGbsiS8b7ryogmbz hbyc9REROfZhERO5ETShjPtvpGqTUyLErytS4siSwx5x2tRH4hPOI0DkjZtaJtFxuVEbIUUi yeNujlBUJGbJN6nM/Cyf2Hf60YgjvKA+NPSP4gT7axpcPtr51YWJnYn9dnAQWl722p4ot37y zqnlfp6FrqbwawG8/9k= --------------090702000409020903010606-- --------------050202020706040405030503--