<commit_before>module Looksee
  module ObjectMixin
    #
    # Shortcut for Looksee[self, *args].
    #
    def method_missing(name, *args)
      case name.to_s
      when /^ls$/
        # when in repl, p is no need.
        # but when no repl, p is need for output looksee result.
        if defined? Pry or defined? Irb
          Looksee[self, *args]
        else
          p Looksee[self, *args]
        end
      else
        super
      end
    end

    def self.rename(name)  # :nodoc:
      name = name[:ls] if name.is_a?(Hash)
      alias_method name, :ls
      remove_method :ls
    end
  end

  #
  # Rename the #ls method, added to every object. Example:
  #
  #     rename :_ls<commit_msg>Clean up ObjectMixin, update docs, don't print, define respond_to?.<commit_after>module Looksee
  module ObjectMixin
    #
    # Define #ls as a shortcut for Looksee[self, *args].
    #
    # This is defined via method_missing to be less intrusive. pry 0.10, e.g.,
    # relies on Object#ls not existing.
    #
    def method_missing(name, *args)
      if name == :ls
        Looksee[self, *args]
      else
        super
      end
    end

    def respond_to?(name, include_private=false)
      super || name == :ls
    end

    def self.rename(name)  # :nodoc:
      name = name[:ls] if name.is_a?(Hash)
      alias_method name, :ls
      remove_method :ls
    end
  end

  #
  # Rename the #ls method, added to every object. Example:
  #
  #     rename :_ls
{'fraction_non_alphanumeric': 0.0944558521560575, 'fraction_numerical': 0.002053388090349076, 'mean_word_length': 2.0269151138716355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5289222', 'n_tokens_mistral': 494, 'n_tokens_neox': 486, 'n_words': 155}