On Thu, Mar 27, 2008 at 10:19 PM, Shane Witbeck <[EMAIL PROTECTED]>
wrote:

> How about using the RUBY_PLATFORM constant?
>
> def fu_windows?
>      /mswin|mingw|bccwin|wince|emx|java/ =~ RUBY_PLATFORM
> end


Thanks.  I'm using Gem.win_platform? which does the exact same thing, to
handle Windows specific stuff.  I was more interested in the equivalent of
which.

The over grown Rakefile has a lot of tasks that are only necessary for
making releases, some have 3rd party dependencies, and I don't want those to
get in the way of doing things like rake install or rake doc.  There's a few
checks, but they seem to work on Unix and break with a bang on Windows.

So far what I came up with is:

def which(name)
  if Gem.win_platform?
    path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path|
path.gsub('\\', '/') }.map { |path| "#{path}/#{name}.{exe,bat,com}" }
  else
    path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path|
"#{path}/#{name}" }
  end
  FileList[path].existing.first
end

You can find it Java is installed by running which('java').  It seems to
work nicely, but I'm not sure how complete it is.

Assaf


>
> Found that little GEM here:
> http://headius.blogspot.com/2006/03/ruby-in-rough.html
>
>
>
> On Thu, Mar 27, 2008 at 9:09 PM, Assaf Arkin <[EMAIL PROTECTED]> wrote:
> > Fixed in trunk now.
> >  Do you have an idea how to check if an executable exists on Windows?
>  The
> >  way we check for it right now will still show a, potentially confusing,
> >  warning on the console.
> >
> >  Assaf
> >
> >  On Thu, Mar 27, 2008 at 12:02 PM, Shane Witbeck <
> [EMAIL PROTECTED]>
> >  wrote:
> >
> >
> >
> >  > C:\projects\buildr>rake install
> >  > (in C:/projects/buildr)
> >  > Please run rake setup to install the Allison RDoc template
> >  > Please run rake setup to install the Docter document generation
> library
> >  > rake aborted!
> >  > No such file or directory - prince --version
> >  > c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:2153:in
> >  > `raw_load_rakefile'
> >  > (See full trace by running task with --trace)
> >  >
> >  > C:\projects\buildr>rake setup
> >  > (in C:/projects/buildr)
> >  > Please run rake setup to install the Allison RDoc template
> >  > Please run rake setup to install the Docter document generation
> library
> >  > rake aborted!
> >  > No such file or directory - prince --version
> >  > c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:2153:in
> >  > `raw_load_rakefile'
> >  > (See full trace by running task with --trace)
> >  >
> >  > C:\projects\buildr>
> >  >
> >  > --
> >  > -Shane
> >  >
> >
>
>
>
> --
> -Shane
>

Reply via email to