Class: CodeWeb::TextReport

Inherits:
Object
  • Object
show all
Defined in:
lib/code_web/text_report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method_calls, class_map = {}, arg_regex = nil, out = STDOUT, options = {}) ⇒ TextReport

Returns a new instance of TextReport.



11
12
13
14
15
16
17
# File 'lib/code_web/text_report.rb', line 11

def initialize(method_calls, class_map={}, arg_regex=nil, out=STDOUT, options = {})
  @method_calls = method_calls
  @arg_regex = arg_regex
  @base_url = options[:base_url]
  @url_and_file = options[:url_and_file]
  @out = out
end

Instance Attribute Details

#:method_calls(: method_calls) ⇒ Array<MethodCall> (readonly)

list of all the method_Calls

Returns:



6
# File 'lib/code_web/text_report.rb', line 6

attr_accessor :method_calls

#arg_regexObject

Returns the value of attribute arg_regex.



7
8
9
# File 'lib/code_web/text_report.rb', line 7

def arg_regex
  @arg_regex
end

#base_urlObject

Returns the value of attribute base_url.



8
9
10
# File 'lib/code_web/text_report.rb', line 8

def base_url
  @base_url
end

#method_callsObject

Returns the value of attribute method_calls.



6
7
8
# File 'lib/code_web/text_report.rb', line 6

def method_calls
  @method_calls
end

Instance Method Details

#arg_regex?Boolean

Returns:

  • (Boolean)


9
# File 'lib/code_web/text_report.rb', line 9

def arg_regex? ; ! arg_regex.nil? ; end

#methods_by_nameObject



40
41
42
# File 'lib/code_web/text_report.rb', line 40

def methods_by_name
  MethodList.group_by(method_calls, :short_method_name)
end

#reportObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/code_web/text_report.rb', line 19

def report
  methods_by_name.each do |methods|
    @out.puts "---- #{methods.name} ----"
    methods.group_by(:signature, arg_regex).each do |methods_with_signature|
      if arg_regex?
        @out.puts " --> #{arg_regex.inspect}=#{methods_with_signature.name}"
      else
        @out.puts " --> #{methods_with_signature.name}"
      end
      methods_with_signature.each_with_index do |method, i|
        @out.puts
        @out.puts method.signature
        @out.puts "#{method.filename}:#{method.line}"
      end
      @out.puts
      @out.puts
    end
    @out.puts
  end
end