<commit_before>
def rails_deployment_name( app_name )
  "#{app_name}-rails.yml"
end

def rack_deployment_name( app_name )
  "#{app_name}-rack.yml"
end

def rails_deployment(app_name, root, context_path)
  deployment_descriptor = {
    'application' => {
      'RAILS_ROOT'=>root,
      'RAILS_ENV'=>( defined?( RAILS_ENV ) ? RAILS_ENV : 'development' ),
    },
    'web' => {
      'context'=> context_path[0,1] != '/'? %Q(/#{context_path}) : context_path
    }
  }

  [ rails_deployment_name( app_name ), deployment_descriptor ]
end

def rack_deployment(app_name, root, context_path)
  deployment_descriptor = { 
    'application' => {
      'RACK_ROOT'=>root,
      'RACK_ENV'=>( defined?( RACK_ENV ) ? RACK_ENV : 'development' ),
    },
    'web' => {
      'context'=> context_path[0,1] != '/'? %Q(/#{context_path}) : context_path
    }
  }

  [ rack_deployment_name( app_name ), deployment_descriptor ]
end

def rails?(root)
  File.exist?( File.join( root, 'config', 'environment.rb' ) )
end

def rack?(root)
  File.exist?( File.join( root, 'config.ru' ) )
end

def deployment(app_name, root, context_path)
  if ( rails?( root ) )
    return rails_deployment( app_name, root, context_path )
  elsif ( rack?( root ) )
    return rack_deployment( app_name, root, context_path )
  end
end

def deployment_name(app_name, root )
  if ( rails?( root ) )
    return rails_deployment_name( app_name )
  elsif ( rack?( root ) )
    return rack_deployment_name( app_name )
  end
end

namespace :torquebox do

  desc "Deploy the app in the current directory"
  task :deploy, :context_path, :needs =>['torquebox:check'] do |t, args|
    args.with_defaults(:context_path => '/')
    app_name = File.basename( Dir.pwd )
    deployment_name, deployment_descriptor = deployment( app_name, Dir.pwd, args[:context_path] )
    JBoss::RakeUtils.deploy_yaml( deployment_name, deployment_descriptor )
    puts "Deployed #{deployment_name}"
  end

  desc "Undeploy the app in the current directory"
  task :undeploy=>['torquebox:check'] do
    app_name = File.basename( Dir.pwd )
    JBoss::RakeUtils.undeploy( deployment_name( app_name, Dir.pwd ) )
    puts "Undeployed #{deployment_name}"
  end

  if ( rails?( Dir.pwd ) )
    desc "Create (if needed) and deploy as application archive"
    namespace :deploy do
      task :archive=>[ 'torquebox:archive' ] do
        archive_name = File.basename( Dir.pwd ) + '.rails'
        src = "#{Dir.pwd}/#{archive_name}"
        FileUtils.cp( src, JBoss::RakeUtils.deploy_dir )
        puts "Deployed #{archive_name}"
      end
    end
    namespace :undeploy do
      task :archive do
        archive_name = File.basename( Dir.pwd ) + '.rails'
        FileUtils.rm_f( File.join( JBoss::RakeUtils.deploy_dir, archive_name ) )
        puts "Undeployed #{archive_name}"
      end
    end
  end
 
end

<commit_msg>Fixing TORQUE-125. Ah, the wonders of aliased local variables and method names!<commit_after>
def rails_deployment_name( app_name )
  "#{app_name}-rails.yml"
end

def rack_deployment_name( app_name )
  "#{app_name}-rack.yml"
end

def rails_deployment(app_name, root, context_path)
  deployment_descriptor = {
    'application' => {
      'RAILS_ROOT'=>root,
      'RAILS_ENV'=>( defined?( RAILS_ENV ) ? RAILS_ENV : 'development' ),
    },
    'web' => {
      'context'=> context_path[0,1] != '/'? %Q(/#{context_path}) : context_path
    }
  }

  [ rails_deployment_name( app_name ), deployment_descriptor ]
end

def rack_deployment(app_name, root, context_path)
  deployment_descriptor = { 
    'application' => {
      'RACK_ROOT'=>root,
      'RACK_ENV'=>( defined?( RACK_ENV ) ? RACK_ENV : 'development' ),
    },
    'web' => {
      'context'=> context_path[0,1] != '/'? %Q(/#{context_path}) : context_path
    }
  }

  [ rack_deployment_name( app_name ), deployment_descriptor ]
end

def rails?(root)
  File.exist?( File.join( root, 'config', 'environment.rb' ) )
end

def rack?(root)
  File.exist?( File.join( root, 'config.ru' ) )
end

def deployment(app_name, root, context_path)
  if ( rails?( root ) )
    return rails_deployment( app_name, root, context_path )
  elsif ( rack?( root ) )
    return rack_deployment( app_name, root, context_path )
  end
end

def deployment_name(app_name, root )
  if ( rails?( root ) )
    return rails_deployment_name( app_name )
  elsif ( rack?( root ) )
    return rack_deployment_name( app_name )
  end
end

namespace :torquebox do

  desc "Deploy the app in the current directory"
  task :deploy, :context_path, :needs =>['torquebox:check'] do |t, args|
    args.with_defaults(:context_path => '/')
    app_name = File.basename( Dir.pwd )
    deployment_name, deployment_descriptor = deployment( app_name, Dir.pwd, args[:context_path] )
    JBoss::RakeUtils.deploy_yaml( deployment_name, deployment_descriptor )
    puts "Deployed #{deployment_name}"
  end

  desc "Undeploy the app in the current directory"
  task :undeploy=>['torquebox:check'] do
    app_name = File.basename( Dir.pwd )
    deployment_name = deployment_name( app_name, Dir.pwd )
    JBoss::RakeUtils.undeploy( deployment_name )
    puts "Undeployed #{deployment_name}"
  end

  if ( rails?( Dir.pwd ) )
    desc "Create (if needed) and deploy as application archive"
    namespace :deploy do
      task :archive=>[ 'torquebox:archive' ] do
        archive_name = File.basename( Dir.pwd ) + '.rails'
        src = "#{Dir.pwd}/#{archive_name}"
        FileUtils.cp( src, JBoss::RakeUtils.deploy_dir )
        puts "Deployed #{archive_name}"
      end
    end
    namespace :undeploy do
      task :archive do
        archive_name = File.basename( Dir.pwd ) + '.rails'
        FileUtils.rm_f( File.join( JBoss::RakeUtils.deploy_dir, archive_name ) )
        puts "Undeployed #{archive_name}"
      end
    end
  end
 
end


{'fraction_non_alphanumeric': 0.13244459833795014, 'fraction_numerical': 0.001904432132963989, 'mean_word_length': 3.552403467297084, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, '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': '2366217', 'n_tokens_mistral': 2047, 'n_tokens_neox': 2019, 'n_words': 451}