From 237ff7df5518a51a02b62b71502139a097c34697 Mon Sep 17 00:00:00 2001 From: Adam Sanderson Date: Sat, 1 Jan 2011 13:20:47 -0700 Subject: [PATCH] Add rvm sources directory if available. --- lib/qwandry/configuration.rb | 9 ++++++++- lib/qwandry/configuration/default.rb | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/qwandry/configuration.rb b/lib/qwandry/configuration.rb index 9607688..b529b34 100644 --- a/lib/qwandry/configuration.rb +++ b/lib/qwandry/configuration.rb @@ -14,9 +14,16 @@ module Qwandry builders[name] << block end + # Registers a configuration is a specific binary is available. If `binary` is not specified, + # it is assumed to be the same as the configuration name. def register_if_present name, binary=nil, &block binary ||= name - register(name, &block) if system("which #{binary}") + register(name, &block) if present? binary + end + + # Returns true if binary `name` is present. + def present? name + system("which #{name}", STDOUT=>"/dev/null") end # Sets the default configuration to launch, if no `configurations` are passed diff --git a/lib/qwandry/configuration/default.rb b/lib/qwandry/configuration/default.rb index da7538a..47ae9fb 100644 --- a/lib/qwandry/configuration/default.rb +++ b/lib/qwandry/configuration/default.rb @@ -52,6 +52,16 @@ register_if_present :node do add node_paths end +# If we can figure out where the user's ruby source directory is, add it. +register_if_present :ruby_src, :rvm do + # If present, use the current rvm's ruby source, this will probably be MRI + # though you never know. We could later try to be smarter about jruby, etc. + path = File.join(ENV['rvm_src_path'], ENV['rvm_ruby_string']) + + # Add the sources, use a LibraryRepository to bundle .h and .c files + add path, :reject=>/\.(o|a|dylib)$/, :class=>Qwandry::LibraryRepository +end + # Qwandry is a ruby app after all, so activate ruby and gem by default. Other defaults can be set # with a custom init.rb default :ruby, :gem \ No newline at end of file