Module: RuboCop::Code0::ZeroTrack::FileHelpers

Instance Method Summary collapse

Instance Method Details

#basename(node) ⇒ Object



11
12
13
# File 'lib/rubocop/code0/zero_track/file_helpers.rb', line 11

def basename(node)
  File.basename(filepath(node))
end

#dirname(node) ⇒ Object



7
8
9
# File 'lib/rubocop/code0/zero_track/file_helpers.rb', line 7

def dirname(node)
  File.dirname(filepath(node))
end

#filepath(node) ⇒ Object



15
16
17
# File 'lib/rubocop/code0/zero_track/file_helpers.rb', line 15

def filepath(node)
  node.location.expression.source_buffer.name
end

#in_migration?(node) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/rubocop/code0/zero_track/file_helpers.rb', line 19

def in_migration?(node)
  dirname(node).end_with?('db/migrate')
end