Sha256: b492dabdea99ebcdec6355b56e9d42d571b91002be30be518a964049146c053c

Contents?: true

Size: 940 Bytes

Versions: 1

Compression:

Stored size: 940 Bytes

Contents

module Reek
  module CLI
    #
    # CLI Input utility
    #
    module Input
      def sources
        if no_source_files_given?
          if input_was_piped?
            source_from_pipe
          else
            working_directory_as_source
          end
        else
          sources_from_argv
        end
      end

      private

      def input_was_piped?
        !$stdin.tty?
      end

      def no_source_files_given?
        # At this point we have deleted all options from @argv. The only remaining entries
        # are paths to the source files. If @argv is empty, this means that no files were given.
        @argv.empty?
      end

      def working_directory_as_source
        Source::SourceLocator.new(['.']).all_sources
      end

      def sources_from_argv
        Source::SourceLocator.new(@argv).all_sources
      end

      def source_from_pipe
        [Source::SourceCode.from($stdin)]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reek-2.1.0 lib/reek/cli/input.rb