<commit_before>module ::Bond
  module Actions
    def alias_constants(input)
      fetch_constants = proc {|klass, klass_alias| klass.constants.grep(/^#{klass_alias}/i).map {|f| klass.const_get(f)} }
      fetch_string_constants = proc {|klass, klass_alias|
        klass.constants.grep(/^#{klass_alias}/i).map {|f|
          (val = klass.const_get(f)) && val.is_a?(Module) ? val.to_s : "#{klass}::#{f}"
        }
      }

      index = 1
      aliases = input.split(":")
      aliases.inject([Object]) do |completions,a|
        completions = completions.select {|e| e.is_a?(Module) }.map {|klass|
          aliases.size != index ? fetch_constants.call(klass, a) : fetch_string_constants.call(klass, a)
        }.flatten
        index += 1; completions
      end
    end

    def my_constants(input)
      receiver = input.matched[2]
      candidates = current_eval("#{receiver}.constants")
      candidates.grep(/^#{Regexp.escape(input.matched[5])}/).map {|e| receiver + "::" + e}
    end
  end
end

module Completion
  def self.included(mod)
    begin LocalGem.local_require 'bond'; rescue; require 'bond' end
  end

  def self.after_included
    Bond.reset
    Bond.debrief :debug=>true, :default_search=>:underscore
    require 'bond/completion'
    Bond.recomplete(:anywhere=>/((((::)?[A-Z][^:.\(]*)+)::?([^:.]*))$/, :action=>:my_constants, :search=>false)
    # place it before symbols
    #Bond.complete(:on=>/((([a-z][^:.\(]*)+):)+$/, :search=>false, :action=>:alias_constants, :place=>5)
    Bond.complete(:method=>"reload") {|e| $" }
    Bond.complete(:method=>/ll|bl|rl/) {|e|
      (Boson::Runner.all_libraries + Boson::Runner.all_libraries.map {|e| File.basename e }).uniq
    }
    Bond.complete(:method=>'r', :action=>:method_require, :search=>false)
    Bond.complete(:method=>'bc') {|e| Boson.commands.map {|e| e.name} }
    Bond.complete(:on=>/ENV\[["'](\S*)$/, :search=>false) {|e| ENV.keys.grep(/^#{Regexp.escape(e.matched[1])}/i) }
  end

  # Toggles object completion between all methods and just the object's class methods
  def toggle_object_complete
    if @object_complete
      Bond.recomplete(:object=>'Object', :place=>:last)
      Bond.recomplete(:object=>'Object', :on=>/([^.\s]+)\.([^.\s]*)$/, :place=>:last)
    else
      non_inherited_methods = proc {|e|
        e.object.is_a?(Module) ? e.object.methods(false) : e.object.class.instance_methods(false)
      }
      Bond.recomplete(:object=>'Object', :place=>:last, &non_inherited_methods)
      Bond.recomplete(:object=>'Object', :on=>/([^.\s]+)\.([^.\s]*)$/, :place=>:last, &non_inherited_methods)
    end
    @object_complete = !@object_complete
  end
end
<commit_msg>moved most of bond config to bondrc<commit_after>module Completion
  def self.included(mod)
    begin LocalGem.local_require 'bond'; rescue; require 'bond' end
  end

  def self.after_included
    Bond.reset
    Bond.load do
      complete(:method=>"reload") {|e| $" }
      complete(:method=>/ll|bl|rl/) {|e|
        (Boson::Runner.all_libraries + Boson::Runner.all_libraries.map {|e| File.basename e }).uniq
      }
      complete(:method=>'r', :action=>:method_require, :search=>false)
      complete(:method=>'bc') {|e| Boson.commands.map {|e| e.name} }
    end
  end

  # Toggles object completion between all methods and just the object's class methods
  def toggle_object_complete
    if @object_complete
      Bond.recomplete(:object=>'Object', :place=>:last)
      Bond.recomplete(:object=>'Object', :on=>/([^.\s]+)\.([^.\s]*)$/, :place=>:last)
    else
      non_inherited_methods = proc {|e|
        e.object.is_a?(Module) ? e.object.methods(false) : e.object.class.instance_methods(false)
      }
      Bond.recomplete(:object=>'Object', :place=>:last, &non_inherited_methods)
      Bond.recomplete(:object=>'Object', :on=>/([^.\s]+)\.([^.\s]*)$/, :place=>:last, &non_inherited_methods)
    end
    @object_complete = !@object_complete
  end
end

{'fraction_non_alphanumeric': 0.1963738508682329, 'fraction_numerical': 0.0015321756894790602, 'mean_word_length': 3.6854066985645932, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 46, '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': '2121868', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1411, 'n_words': 239}