Sha256: 085b40e8c3dd388d21f0126ecf654bd703aae5cb3f9acc7ccd3276610829f82a

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

difficulty 1
description "There are some files in this repository, how many of the files will be committed?"

setup do
  repo.init

  #Modified files
  %w{rubyfile4.rb rubyfile5.rb}.each do |file|
    FileUtils.touch(file)
    repo.add(file)
  end
  repo.commit_all "Commit"

  #Staged file
  File.open("rubyfile4.rb", 'w') { |f| f << "#Changes" }
  repo.add("rubyfile4.rb")

  #Not staged file
  File.open("rubyfile5.rb", 'w') { |f| f << "#Changes" }

  #Changes to be committed
  %w{rubyfile1.rb}.each do |file|
    FileUtils.touch(file)
    repo.add(file)
  end  

  #Untrached files
  %w{rubyfile6.rb rubyfile7.rb}.each do |file|
    FileUtils.touch(file)
  end
end

solution do
  numberOfFilesThereWillBeCommit = request("How many changes are going to be committed?")

  isInteger = !!(numberOfFilesThereWillBeCommit =~ /^[-+]?[0-9]+$/)

  if !isInteger
    return false
  end

  if numberOfFilesThereWillBeCommit.to_i == 2
    return true
  end

  return false
end

hint do
  puts "You are looking for a command to identify the status of the repository."
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
githug-0.5.0 levels/number_of_files_committed.rb
githug-0.4.8 levels/number_of_files_committed.rb
githug-0.4.7 levels/number_of_files_committed.rb
githug-0.4.6 levels/number_of_files_committed.rb
githug-0.4.5 levels/number_of_files_committed.rb
githug-0.4.4 levels/number_of_files_committed.rb
githug-0.4.3 levels/number_of_files_committed.rb
githug-0.4.2 levels/number_of_files_committed.rb