lib/speckle/cli/environment.rb in speckle-0.1.18 vs lib/speckle/cli/environment.rb in speckle-0.1.19

- old
+ new

@@ -2,10 +2,11 @@ module CLI require 'optparse' require 'ostruct' + require 'find' class Environment include Loader def load(args) @@ -92,11 +93,11 @@ end opts.on('-v', '--verbose', 'Display verbose output') do options.verbose = true end - + opts.on('-D', '--debug', 'Display debug output') do options.verbose = true options.debug = true end @@ -138,16 +139,32 @@ rescue OptionParser::ParseError => e options.error = e options.action = :show_parser_error end + if action_needs_args?(options.action) and options.libs.nil? + options.libs = build_riml_path(['lib', 'spec']) + end + options end def action_needs_args?(action) [:compile_and_test, :compile, :test].include? action end - end + def build_riml_path(dirs, pattern = /.*\.riml$/, spec_pattern = /.*_spec\.riml$/) + libs = [] + dirs.each do |dir| + Find.find(dir) do |path| + if path =~ pattern && path !~ spec_pattern + libs << File.dirname(path) + end + end + end + + libs.uniq.join(':') + end + end end end