Class: RubocopTodoCorrector::CopUrlFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop_todo_corrector/cop_url_finder.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cop_name:, cop_source_path:, temporary_gemfile_path:) ⇒ CopUrlFinder

Returns a new instance of CopUrlFinder.



25
26
27
28
29
30
31
32
33
# File 'lib/rubocop_todo_corrector/cop_url_finder.rb', line 25

def initialize(
  cop_name:,
  cop_source_path:,
  temporary_gemfile_path:
)
  @cop_name = cop_name
  @cop_source_path = cop_source_path
  @temporary_gemfile_path = temporary_gemfile_path
end

Class Method Details

.call(cop_name:, cop_source_path:, temporary_gemfile_path:) ⇒ String

Parameters:

  • cop_name (String)
  • cop_source_path (String)
  • temporary_gemfile_path (String)

Returns:

  • (String)


12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rubocop_todo_corrector/cop_url_finder.rb', line 12

def call(
  cop_name:,
  cop_source_path:,
  temporary_gemfile_path:
)
  new(
    cop_name:,
    cop_source_path:,
    temporary_gemfile_path:
  ).call
end

Instance Method Details

#callString

Returns:

  • (String)


36
37
38
39
40
41
42
43
44
# File 'lib/rubocop_todo_corrector/cop_url_finder.rb', line 36

def call
  if !captured_url.empty?
    captured_url
  elsif gem_name
    "https://www.rubydoc.info/gems/#{gem_name}/RuboCop/Cop/#{@cop_name}"
  else
    "https://www.google.com/search?q=rubocop+#{::URI.encode_www_form_component(@cop_name.inspect)}"
  end
end