Module: RuboCop::Cop::GemspecHelp

Overview

Common functionality for checking gem declarations.

Instance Method Summary collapse

Instance Method Details

#assignment_method_declarations(node) ⇒ Object



30
31
32
33
# File 'lib/rubocop/cop/mixin/gemspec_help.rb', line 30

def_node_search :assignment_method_declarations, "(send\n  (lvar {#match_block_variable_name? :_1 :it}) _ ...)\n"

#gem_specification(node) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/rubocop/cop/mixin/gemspec_help.rb', line 20

def_node_search :gem_specification, "(block\n  (send\n    (const\n      (const {cbase nil?} :Gem) :Specification) :new)\n  (args\n    (arg $_)) ...)\n"

#gem_specification?(node) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/rubocop/cop/mixin/gemspec_help.rb', line 10

def_node_matcher :gem_specification?, "(block\n  (send\n    (const\n      (const {cbase nil?} :Gem) :Specification) :new)\n  (args\n    (arg $_)) ...)\n"

#indexed_assignment_method_declarations(node) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/rubocop/cop/mixin/gemspec_help.rb', line 36

def_node_search :indexed_assignment_method_declarations, "(send\n  (send (lvar {#match_block_variable_name? :_1 :it}) _)\n  :[]=\n  literal?\n  _\n)\n"

#match_block_variable_name?(receiver_name) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
49
# File 'lib/rubocop/cop/mixin/gemspec_help.rb', line 45

def match_block_variable_name?(receiver_name)
  gem_specification(processed_source.ast) do |block_variable_name|
    return block_variable_name == receiver_name
  end
end