Sha256: 8a2d9a3405f130b71c76986d8cc5b52bee81b1b921559922721e3ff35dfdf0d6

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

class Common
  def restore(file: String, workshop_dir: String)
  restore_file = ""
    line = File.open("#{workshop_dir}/lib/answer.rb") do |f|
      1.times {
        f.gets
      }
      restore_file = f.gets
    end
    restore_file.gsub!(" ", "")
    restore_file.delete!("#")
    Dir::chdir("#{workshop_dir}/restore"){
      file_count = Dir.glob("*.rb").count
      # restore_file.insert(-5, "[#{file_count}]")
      restore_file.insert(0, "[#{file_count}]")
    }
    system "touch #{workshop_dir}/restore/#{restore_file}"
    system "cp #{workshop_dir}/lib/workplace.rb #{workshop_dir}/restore/#{restore_file}"
  end

  def time_check(start_time: Time)
    end_time = Time.now
    elapsed_time = end_time - start_time - 1
    return elapsed_time
  end

  def instruct_print
    puts "continue >>> [RET]"
    puts "stop >>> 'exit' + [RET]"
    puts "check answer >>> 'answer' + [RET]"
  end

  def init_mk_files(gem_dir: String, workshop_dir: String)
    if Dir.exist?(workshop_dir) != true then
      FileUtils.mkdir_p(workshop_dir)
      system("cp -R #{gem_dir}/workshop/* #{workshop_dir}")
      system("cd #{workshop_dir} && mv emacs.d .emacs.d")
      system("cd #{workshop_dir} && mv rspec .rspec")
      system("cd #{workshop_dir} && mv rubocop.yml .rubocop.yml")
    end
  end

  def get_app_ver(app_name: String)
    app_vers = Open3.capture3("gem list #{app_name}")
    latest_ver = app_vers[0].chomp.gsub(' (', '-').gsub(')','')
    return latest_ver
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby_learner-1.1.10 lib/ruby_learner/common.rb
ruby_learner-1.1.9 lib/ruby_learner/common.rb