Sha256: d2afcad8514e65a3420554b2e057b192f8fde5c96c759f41c6a85c2f1c8bc989

Contents?: true

Size: 664 Bytes

Versions: 1

Compression:

Stored size: 664 Bytes

Contents

require 'rubycritic/analysers/helpers/parser'

module RubyCritic
  class ModulesLocator
    def initialize(analysed_module)
      @analysed_module = analysed_module
    end

    def first_name
      names.first
    end

    def names
      names = node.get_module_names
      if names.empty?
        name_from_path
      else
        names
      end
    end

    private

    def node
      Parser.parse(content)
    end

    def content
      File.read(@analysed_module.path)
    end

    def name_from_path
      [file_name.split('_').map(&:capitalize).join]
    end

    def file_name
      @analysed_module.pathname.basename.sub_ext('').to_s
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubycritic-2.9.3 lib/rubycritic/analysers/helpers/modules_locator.rb