lib/ratch/manager.rb in ratch-0.4.0 vs lib/ratch/manager.rb in ratch-0.4.1

- old
+ new

@@ -1,34 +1,53 @@ - module Ratch class Manager - def toolset_directory - File.join(File.dirname(__FILE__), 'toolset') + # Return master toolset directory. If toolset if given then + # return that toolsets directory. + + def toolset_directory(toolset=nil) + if toolset + File.join(File.dirname(__FILE__), 'toolset', toolset) + else + File.join(File.dirname(__FILE__), 'toolset') + end end - # + # List toolsets. - def toolset + def toolsets files = [] Dir.chdir(toolset_directory) do - files = Dir.glob('**/*') + files = Dir.glob('*/').map{ |d| d.chomp('/') } end files end - # + # List tools for a give toolset. - def tool?(fname) - file = File.join(toolset_directory, fname) - if File.exist?(file) - file - else - false + def tools(toolset=nil) + files = [] + direc = toolset ? File.join(toolset_directory, toolset) : toolset_directory + Dir.chdir(direc) do + files = Dir.glob('**/*') - Dir.glob('**/*/').map{ |d| d.chomp('/') } end + files end + # Verify a toolset exists? + + def toolset?(toolset) + path = File.join(toolset_directory, toolset) + File.exist?(path) ? path : false + end + + # Verify a tool exists for a given toolset. + + def tool?(toolset, batchfile) + path = File.join(toolset_directory, toolset, batchfile) + File.exist?(path) ? path : false + end + end end -