class NumberStation::CLI

Public Instance Methods

convert_to_phonetic(message) click to toggle source
# File lib/number_station/cli.rb, line 78
def convert_to_phonetic(message)
  NumberStation::ConfigReader.read_config()

  intro_path = options[:intro]
  message_path = message
  outro_path = options[:outro]
  mp3_path = options[:mp3]
  NumberStation.log.debug "intro_path: #{intro_path}" if options[:intro]
  NumberStation.log.debug "message_path: #{message_path}"
  NumberStation.log.debug "outro_path: #{outro_path}" if options[:outro]
  NumberStation.log.debug "mp3_path: #{mp3_path}" if options[:mp3]

  output = ""
  output += NumberStation.to_phonetic(intro_path) if options[:intro]
  output += NumberStation.to_phonetic(message_path)
  output += NumberStation.to_phonetic(outro_path) if options[:outro]
  NumberStation.log.info "output: #{output}"

  if options[:mp3]
    NumberStation.log.debug "Generating mp3 output: #{mp3_path}"
    NumberStation.write_mp3(output, mp3_path)
  end
  return output
end
create_config() click to toggle source
# File lib/number_station/cli.rb, line 37
def create_config()
  NumberStation::ConfigReader.read_config()
  config_file_path = File.join(File.dirname(__FILE__), "../../config/conf.json")

  if options[:path]
    path = options[:path]
    unless File.file?(File.join(path, "/conf.json"))
      #write config to path
      NumberStation.log.debug "Copying sample config to #{path}"
      FileUtils.cp(config_file_path, path)
    else
      NumberStation.log.debug "File already exists at #{File.join(path, "/conf.json")}"
    end
  else
    path = Dir.pwd
    unless File.file?(File.join(path, "/conf.json"))
      #write config to local directory the binary was called from
      NumberStation.log.debug "Copying sample config to #{path}"
      FileUtils.cp(config_file_path, path)
    else
      NumberStation.log.debug "File already exists at #{File.join(path, "/conf.json")}"
    end
  end
end
decrypt_message(message) click to toggle source
# File lib/number_station/cli.rb, line 175
def decrypt_message(message)
  NumberStation::ConfigReader.read_config()
  NumberStation.log.debug "decrypt_message"

  message_data = File.read(message)
  numpad = options[:numpad]
  padpath = options[:padpath]

  NumberStation.log.debug "message: #{message}"
  NumberStation.log.debug "numpad: #{numpad}" if options[:numpad]
  NumberStation.log.debug "padpath: #{padpath}" if options[:padpath]

  decrypt_m = NumberStation.decrypt_message(message_data, padpath, numpad)
  NumberStation.log.debug "decrypted_message: #{decrypt_m}"
end
encrypt_message(message) click to toggle source
# File lib/number_station/cli.rb, line 146
def encrypt_message(message)
  NumberStation::ConfigReader.read_config()
  NumberStation.log.debug "encrypt_message"

  message_data = File.read(message)
  numpad = options[:numpad]
  padpath = options[:padpath]

  NumberStation.log.debug "message: #{message}" if options[:message]
  NumberStation.log.debug "numpad: #{numpad}" if options[:numpad]
  NumberStation.log.debug "padpath: #{padpath}" if options[:padpath]

  enc_m = NumberStation.encrypt_message(message_data, padpath, numpad)
  NumberStation.log.debug "encrypted_message: #{enc_m}"
end
make_one_time_pad() click to toggle source
# File lib/number_station/cli.rb, line 119
def make_one_time_pad()
  NumberStation::ConfigReader.read_config()
  NumberStation.log.debug "make_one_time_pad"

  length = options[:length]
  numpads = options[:numpads]
  path = options[:path]
  NumberStation.log.debug "length: #{length}" if options[:length]
  NumberStation.log.debug "numpads: #{numpads}" if options[:numpads]
  NumberStation.log.debug "path: #{path}" if options[:path]

  NumberStation.make_otp(path, length, numpads)
end
version() click to toggle source
# File lib/number_station/cli.rb, line 197
def version()
  NumberStation::ConfigReader.read_config()
  NumberStation.log.debug "Version: #{NumberStation::VERSION}"
end