On Jan 20, 7:56 am, "rails.impaired" <resident.mo...@gmail.com> wrote: > I am working on a gem that has needs to set dependencies conditionally > when the gem is installed. I've done some digging around > > and it looks like i'm not alone in this need. > > http://stackoverflow.com/questions/4596606/rubygems-how-do-i-add-plat... > > # this is a long threadhttp://www.ruby-forum.com/topic/957999 > > The only way I can see to add dependencies to a gem is to use > add_dependency method within a Gem::Specifiction block in a .gemspec > file >
You can't use conditionals on gemspec because gemspec is serialized into YAML, which doesn't contain executable code. The recommendation is to generate the gemspec and change both platform and dependencies for each platform: gemspec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY end # here build the normal gem # Now for linux: gemspec.platform = "linux" gemspec.add_dependency ... # build the newer gemspec ... > > Ok. So, I have a bird's eye view of the process, however, that does > not change my desire to build a single gem and conditionally specify > dependencies for a range of OS targets. Well, is not possible, dependencies are defined for the gemspec, can't be defined for different platforms. Probably you can introduce a newer version of the gemspec for RubyGems 2.0... > > If anyone has a solution other than building multiple .gemspec files > for each target OS... I'm all ears!! Above example has been used in different projects, most of the time by #dup the gemspec and building it for each platform. -- Luis Lavena -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.