lib/retest/options.rb in retest-1.0.0 vs lib/retest/options.rb in retest-1.1.0
- old
+ new
@@ -109,74 +109,34 @@
def self.command(args)
new(args).command
end
- def initialize(args = [], output_stream: STDOUT, setup: Setup)
+ def initialize(args = [])
self.args = args
- @output_stream = output_stream
- @setup = setup
end
- def command
- return params[:command] if params[:command]
-
- if params[:rspec] then rspec_command
- elsif params[:rake] then rake_command
- elsif params[:rails] then rails_command
- elsif params[:ruby] then ruby_command
- elsif params[:auto] then default_command
- else default_command
- end
- end
-
def args=(args)
@args = args
parse args
end
def help?
params[:help]
end
- private
-
def full_suite?
params[:all]
end
- def default_command
- choose_command @setup.type, command_for(@setup.type)
+ def auto?
+ return true if no_options_passed?
+ params[:auto]
end
- def command_for(type)
- case type
- when :rspec then rspec_command
- when :rails then rails_command
- when :rake then rake_command
- when :ruby then ruby_command
- else ruby_command
- end
- end
+ private
- def choose_command(type, command)
- @output_stream.puts "Setup identified: [#{type.upcase}]. Using command: '#{command}'"
- command
- end
-
- def rspec_command
- full_suite? ? ALL_RSPEC_COMMAND : RSPEC_COMMAND
- end
-
- def rails_command
- full_suite? ? ALL_RAILS_COMMAND : RAILS_COMMAND
- end
-
- def rake_command
- full_suite? ? ALL_RAKE_COMMAND : RAKE_COMMAND
- end
-
- def ruby_command
- RUBY_COMMAND
+ def no_options_passed?
+ params.to_h.values.compact.uniq == [false]
end
end
end
\ No newline at end of file