lib/inch/cli/command/base_object.rb in inch-0.1.3 vs lib/inch/cli/command/base_object.rb in inch-0.1.4

- old
+ new

@@ -1,32 +1,45 @@ module Inch module CLI module Command + # Base class for Command objects concerned with clearly specified + # objects. + # + # Commands subclassing from this class are called with a list of object + # names (most commonly only one) in the form: + # + # $ inch COMMAND [paths] OBJECT_NAME [, OBJECT_NAME2, ...] [options] + # + # @abstract class BaseObject < Base attr_accessor :object, :objects def initialize super @ranges = Evaluation.new_score_ranges end - # Prepares the (list of) objects, parsing arguments and + # Prepares the given objects, parsing arguments and # running the source parser. # - # @param [Array<String>] args the list of arguments. + # @param *args [Array<String>] the list of arguments # @return [void] def prepare_objects(*args) @options.parse(args) @options.verify run_source_parser(@options.paths, @options.excluded) - self.objects = find_object_names(@options.object_names) + self.objects = find_objects_with_names(@options.object_names) self.object = @objects.first end private - def find_object_names(object_names) + # Returns all objects matching the given +object_names+ + # + # @param object_names [Array<String>] + # @return [Array<CodeObject::Proxy::Base>] + def find_objects_with_names(object_names) object_names.map do |object_name| if object = source_parser.find_object(object_name) object else source_parser.find_objects(object_name)