<commit_before>require 'mharris_ext'
require 'grit'
require 'ostruct'
require 'json'
require 'optparse'
require 'andand'

module ProjectGroup
  class << self
    def ec(cmd)
      MharrisExt.ec cmd, silent: true
    end
  end
end

module ProjectGroup
  class << self
    def load!
      %w(plugin single repo group command config sublime_project run_tests git_tasks reach).each do |f|
        load File.dirname(__FILE__) + "/project_group/#{f}.rb"
      end

      %w(string_ext).each do |f|
        load File.dirname(__FILE__) + "/project_group/ext/#{f}.rb"
      end
    end

    def register_plugin(name,ops={},&b)
      obj = if ops.kind_of?(Hash)
        ops[:obj] || b
      elsif !ops
        raise 'bad'
      else
        ops
      end

      ops.delete(:obj)

      Plugins.instance.add(name,obj,ops)
    end
  end
end

def do_until_success(message=nil,&b)
  loop do
    begin
      res = b[]
      return res
    rescue => exp
      puts exp.message
      puts "#{message} Enter to Continue:"
      STDIN.gets
    end
  end
end

ProjectGroup.load!

ProjectGroup.register_plugin("reach", use_group: true) do |proj,ops|
  cmd = ops[:remaining_args].join(" ")
  #RC.cmd "cd #{proj.path} && #{cmd}"
  do_until_success(proj.short_name) do
    proj.eci cmd
  end
end

ProjectGroup.register_plugin("gt", use_group: true) do |proj,ops|
  if proj.repo.changes?
    proj.eci "gittower -s"
    puts "Enter to Continue:"
    STDIN.gets
  end
  proj.eci "git push origin master:master"
end

ProjectGroup.register_plugin("tasks", use_group: true) do |proj,ops|
  #names = ops[:group].singles.map { |x| x.short_name } + ['define_task']
  #local = names.join(",")
  #cmd = "/code/orig/local_exec/bin/local_exec --addl mongoid_gem_config,define_task --local #{local} list_rake_tasks"
  cmd = "bundle exec list_rake_tasks"
  proj.eci(cmd, silent: true).split("\n").each do |task|
    puts "TASK #{proj.short_name}:#{task}"
  end<commit_msg>ignore dep only in gt<commit_after>require 'mharris_ext'
require 'grit'
require 'ostruct'
require 'json'
require 'optparse'
require 'andand'

module ProjectGroup
  class << self
    def ec(cmd)
      MharrisExt.ec cmd, silent: true
    end
  end
end

module ProjectGroup
  class << self
    def load!
      %w(plugin single repo group command config sublime_project run_tests git_tasks reach).each do |f|
        load File.dirname(__FILE__) + "/project_group/#{f}.rb"
      end

      %w(string_ext).each do |f|
        load File.dirname(__FILE__) + "/project_group/ext/#{f}.rb"
      end
    end

    def register_plugin(name,ops={},&b)
      obj = if ops.kind_of?(Hash)
        ops[:obj] || b
      elsif !ops
        raise 'bad'
      else
        ops
      end

      ops.delete(:obj)

      Plugins.instance.add(name,obj,ops)
    end
  end
end

def do_until_success(message=nil,&b)
  loop do
    begin
      res = b[]
      return res
    rescue => exp
      puts exp.message
      puts "#{message} Enter to Continue:"
      STDIN.gets
    end
  end
end

ProjectGroup.load!

ProjectGroup.register_plugin("reach", use_group: true) do |proj,ops|
  cmd = ops[:remaining_args].join(" ")
  #RC.cmd "cd #{proj.path} && #{cmd}"
  do_until_success(proj.short_name) do
    proj.eci cmd
  end
end

ProjectGroup.register_plugin("gt", use_group: true) do |proj,ops|
  if proj.repo.changes? && !proj.repo.only_dep_changes?
    proj.eci "gittower -s"
    puts "Enter to Continue:"
    STDIN.gets
  end
  proj.eci "git push origin master:master"
end

ProjectGroup.register_plugin("tasks", use_group: true) do |proj,ops|
  #names = ops[:group].singles.map { |x| x.short_name } + ['define_task']
  #local = names.join(",")
  #cmd = "/code/orig/local_exec/bin/local_exec --addl mongoid_gem_config,define_task --local #{local} list_rake_tasks"
  cmd = "bundle exec list_rake_tasks"
  proj.eci(cmd, silent: true).split("\n").each do |task|
    puts "TASK #{proj.short_name}:#{task}"
  end
{'fraction_non_alphanumeric': 0.13108038914490527, 'fraction_numerical': 0.0, 'mean_word_length': 3.0571131879543096, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, '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': '2930661', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1377, 'n_words': 340}