method

add_by_io

add_by_io(io, file_type)
public

No documentation available.

# File railties/lib/rails/code_statistics_calculator.rb, line 62
    def add_by_io(io, file_type)
      patterns = PATTERNS[file_type] || {}

      comment_started = false

      while line = io.gets
        @lines += 1

        if comment_started
          if patterns[:end_block_comment] && patterns[:end_block_comment].match?(line)
            comment_started = false
          end
          next
        else
          if patterns[:begin_block_comment] && patterns[:begin_block_comment].match?(line)
            comment_started = true
            next
          end
        end

        @classes   += 1 if patterns[:class] && patterns[:class].match?(line)
        @methods   += 1 if patterns[:method] && patterns[:method].match?(line)
        if !line.match?(/^\s*$/) && (patterns[:line_comment].nil? || !line.match?(patterns[:line_comment]))
          @code_lines += 1
        end
      end
    end