Coder Social home page Coder Social logo

githug's Introduction

#Githug Git Your Game On

##About Githug is designed to give you a practical way of learning git. It has a series of levels, each utilizing git commands to ensure a correct answer.

##Installation To install Githug

gem install githug

After the gem is installed, you can run githug where you will be prompted to create a directory.

##Commands

Githug has 3 commands:

  • play - This is the default command and it will check your solution for the current level.
  • hint - Gives you a hint (if available) for the current level
  • reset - Reset the current level

##Contributing

Get yourself on the contributors list by doing the following:

  • Fork the repository
  • Make a level in the levels directory (covered below)
  • Add your level to the LEVELS array inside lib/githug/level.rb in a position that makes sense (the "commit" level after the "add" and "init" levels for example)
  • Make sure your level works (covered below)
  • Submit a pull request

##Todo List

  • A better way of returning from the solution block
  • A follow up to the level, more information on a specific command, etc.
  • More levels!

##Writing Levels

Githug has a DSL for writing levels

An example level:

difficulty 1
description "There is a file in your folder called README, you should add it to your staging area"

setup do
  repo.init
  FileUtils.touch("README")
end

solution do
  return false unless repo.status.files.keys.include?("README")
  return false if repo.status.files["README"].untracked
  true
end

hint do
  puts "You can type `git` in your shell to get a list of available git commands"
end

difficulty, description and solution are required.

note Because solution is a Proc, you cannot prematurely return out of it and as a result, must put an implicit return on the last line of the solution block.

solution do
  solved = false
  solved = true if repo.valid?
  solved
end

By default, setup will remove all files from the game folder. You do not need to include a setup method if you don't want an initial git repository (if you are testing git init or only checking an answer.)

You can call repo.init to initialize an empty repository with a .gitignore file. It takes a single parameter of false if you want to skip the initial commit of the .gitignore file.

All methods called on repo are sent to the grit gem if the method does not exist, and you can use that for most git related commands (repo.add, repo.commit, etc.)

Another method exists called init_from_level and it is used like so:

setup do
  init_from_level
end

This will copy the contents of a repository specified in the levels folder for your level. For example, if your level is called "merge" then it will copy the contents of the "merge" folder. it is recommended that you do the following steps:

  • mkdir "yourlevel"
  • cd "yourlevel"
  • git init
  • some git stuff
  • important rename ".git" to ".githug" so it does not get treated as a submodule
  • cd "../"
  • git add "yourlevel"

After doing this, your level should be able to copy the contents from that git repository and use those for your level. You can see the "blame" level for an example of this.

githug's People

Contributors

ocannings avatar rmasters avatar toastwaffle avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.