Loading initializers depending on platform (ruby, jruby)

27 views
Skip to first unread message

Wael

unread,
Apr 30, 2014, 8:39:32 AM4/30/14
to rubyonra...@googlegroups.com
Hey, 

Is there an automated way of loading initializers depending on whether you are currently using ruby or jruby? I have an internal gem that loads some jRuby tasks, but I fail to run them because other non-jruby initializers keep erroring out, understandably since they are not currently installed as jruby gems. 

Assuming the following gemfile: 

----------------
gem rails 

platform :ruby do
  ruby '2.1.0' if RUBY_ENGINE == 'ruby'
  gem A  # Not needed when running jruby
end

platform :jruby do
  ruby '1.9.3' if RUBY_ENGINE == 'jruby'
  gem 'internal_gem'
end
--------------

I won't be able to run anything provided by 'internal_gem' unless I move gem A to the jruby platform, which is not very nice because it would mean I will be doing it for every gem I add. 

Any ideas? 

Wael

unread,
May 5, 2014, 4:19:55 AM5/5/14
to rubyonra...@googlegroups.com
No ideas on this fellas? 

Hassan Schroeder

unread,
May 5, 2014, 3:12:15 PM5/5/14
to rubyonrails-talk
On Mon, May 5, 2014 at 1:19 AM, Wael <wael.kh...@gmail.com> wrote:
> No ideas on this fellas?

No idea what you're talking about...

> On Wednesday, April 30, 2014 2:39:32 PM UTC+2, Wael wrote:

>> platform :ruby do
>> ruby '2.1.0' if RUBY_ENGINE == 'ruby'
>> gem A # Not needed when running jruby
>> end
>>
>> platform :jruby do
>> ruby '1.9.3' if RUBY_ENGINE == 'jruby'
>> gem 'internal_gem'
>> end
>> --------------
>>
>> I won't be able to run anything provided by 'internal_gem' unless I move
>> gem A to the jruby platform

First you say 'gem A' isn't needed when running jruby, then you say
it is -- which is the actual case?

If you need a gem for all platforms, just include it normally (outside
the platform blocks).

Or please explain the problem more clearly...

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Reply all
Reply to author
Forward
0 new messages