Sha256: ed53ed9a0bbbff43dd79be2786acfff3f86e8a02f9ea48c34e2937f87fefd988

Contents?: true

Size: 1.33 KB

Versions: 22

Compression:

Stored size: 1.33 KB

Contents

#encoding: utf-8

require 'fileutils'
#require 'init'

module DataFiles

  def self.prepare
    data_path = File.join(ENV['HOME'], '.shunkuntype','training_data.txt')

    create_file_if_not_exists(data_path)
  end

  def self.create_file_if_not_exists(path)
    create_file_path(path)

    return if File::exists?(path)
    create_data_files
  end

  def self.create_file_path(path)
    FileUtils.mkdir_p File.dirname(path)
  end

  def self.create_data_files
    if File::exist?("./speed_data.txt") then
      system "mv ./speed_data.txt #{Shunkuntype::SPEED_FILE}"
      print "moving ./speed_data.txt #{Shunkuntype::SPEED_FILE}.\n"
    end
    if File::exist?("./training_data.txt") then
      system "mv ./training_data.txt #{Shunkuntype::TRAIN_FILE}"
      print "moving ./training_data.txt #{Shunkuntype::TRAIN_FILE}.\n"
    end
    if File::exist?(Shunkuntype::SPEED_FILE) then
      print "#{Shunkuntype::SPEED_FILE} exits.\n"
    else
      File::open(Shunkuntype::SPEED_FILE,'a')
      print "make #{Shunkuntype::SPEED_FILE}\n"
    end
    if File::exist?(Shunkuntype::TRAIN_FILE) then
      print "#{Shunkuntype::TRAIN_FILE} exits.\n"
    else
      File::open(Shunkuntype::TRAIN_FILE,'a')
      print "make #{Shunkuntype::TRAIN_FILE}\n"
    end
  end
  private_class_method :create_file_if_not_exists, :create_file_path, :create_data_files
end

Version data entries

22 entries across 13 versions & 1 rubygems

Version Path
shunkuntype-1.0.15 lib/shunkuntype/#db.rb#
shunkuntype-1.0.15 lib/shunkuntype/db.rb
shunkuntype-1.0.14 lib/shunkuntype/db.rb
shunkuntype-1.0.14 lib/shunkuntype/#db.rb#
shunkuntype-1.0.13 lib/shunkuntype/#db.rb#
shunkuntype-1.0.13 lib/shunkuntype/db.rb
shunkuntype-1.0.12 lib/shunkuntype/#db.rb#
shunkuntype-1.0.12 lib/shunkuntype/db.rb
shunkuntype-1.0.11 lib/shunkuntype/#db.rb#
shunkuntype-1.0.11 lib/shunkuntype/db.rb
shunkuntype-1.0.10 lib/shunkuntype/#db.rb#
shunkuntype-1.0.10 lib/shunkuntype/db.rb
shunkuntype-1.0.9 lib/shunkuntype/db.rb
shunkuntype-1.0.9 lib/shunkuntype/#db.rb#
shunkuntype-1.0.7 lib/shunkuntype/#db.rb#
shunkuntype-1.0.7 lib/shunkuntype/db.rb
shunkuntype-1.0.6 lib/shunkuntype/db.rb
shunkuntype-1.0.6 lib/shunkuntype/#db.rb#
shunkuntype-1.0.5 lib/shunkuntype/db.rb
shunkuntype-1.0.4 lib/shunkuntype/db.rb