<commit_before>require 'boxcar/helpers'
require 'boxcar/command/base'
require 'httparty'
require 'json'

# Install Slackware packages
#
class Boxcar::Command::Package < Boxcar::Command::Base
  include Boxcar::Helpers

  def index
    validate_arguments!
  end

  def install
    name    = args[0]
    version = args[1]
    persist = args[3] == "--persist"

    response = HTTParty.get("#{addons_host}/packages/#{name}/#{version}")
    pkg = JSON.parse(response.body)

    if pkg.any?
      pkg = pkg.last
      url = mirror << pkg['path']
    else
      abort "No package #{name}"
    end

    `wget -q #{url}`
    `installpkg #{pkg.package_name}`
    if persist
      `mv #{pkg.package_name} /boot/extra/`
    else
      `rm #{pkg.package_name}`
    end
  end

protected

  def mirror
    'http://slackware.cs.utah.edu/pub/slackware'<commit_msg>Hash syntax not dot syntax<commit_after>require 'boxcar/helpers'
require 'boxcar/command/base'
require 'httparty'
require 'json'

# Install Slackware packages
#
class Boxcar::Command::Package < Boxcar::Command::Base
  include Boxcar::Helpers

  def index
    validate_arguments!
  end

  def install
    name    = args[0]
    version = args[1]
    persist = args[3] == "--persist"

    response = HTTParty.get("#{addons_host}/packages/#{name}/#{version}")
    pkg = JSON.parse(response.body)

    if pkg.any?
      pkg = pkg.last
      url = mirror << pkg['path']
    else
      abort "No package #{name}"
    end

    `wget -q #{url}`
    `installpkg #{pkg['package_name']}`
    if persist
      `mv #{pkg['package_name']} /boot/extra/`
    else
      `rm #{pkg['package_name']}`
    end
  end

protected

  def mirror
    'http://slackware.cs.utah.edu/pub/slackware'
{'fraction_non_alphanumeric': 0.1441073512252042, 'fraction_numerical': 0.003500583430571762, 'mean_word_length': 2.9516129032258065, 'pattern_counts': {'":': 0, '<': 9, '<?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': '1528605', 'n_tokens_mistral': 598, 'n_tokens_neox': 589, 'n_words': 133}