Skip to content

Commit

Permalink
Renamed from gitscrub to githug
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Rennie committed Mar 14, 2012
1 parent f2b4231 commit 1621f85
Show file tree
Hide file tree
Showing 79 changed files with 143 additions and 144 deletions.
20 changes: 10 additions & 10 deletions README.md
@@ -1,37 +1,37 @@
#Gitscrub
#Githug
Git Your Game On

##About
Gitscrub 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.
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 Gitscrub
To install Githug

gem install gitscrub
gem install githug

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

##Commands

Gitscrub has 3 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](https://github.com/Gazler/gitscrub/contributors) by doing the following:
Get yourself on the [contributors list](https://github.com/Gazler/githug/contributors) by doing the following:

* Fork the repository
* Make a level using the DSL (covered below)
* Add your level to the LEVELS array inside `lib/gitscrub/level.rb` in a position that makes sense (the "commit" level after the "add" and "init" levels for example)
* 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

##DSL

Gitscrub has a DSL for writing levels
Githug has a DSL for writing levels

An example level:

Expand Down Expand Up @@ -83,7 +83,7 @@ This will copy the contents of a repository specified in the levels folder for y
* cd "yourlevel"
* git init
* some git stuff
* **important** rename ".git" to ".gitscrub" so it does not get treated as a submodule
* **important** rename ".git" to ".githug" so it does not get treated as a submodule
* cd "../"
* git add "yourlevel"

Expand Down
4 changes: 4 additions & 0 deletions bin/githug
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require 'githug/cli'

Githug::CLI.start
4 changes: 0 additions & 4 deletions bin/gitscrub

This file was deleted.

8 changes: 4 additions & 4 deletions gitscrub.gemspec → githug.gemspec
@@ -1,17 +1,17 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "gitscrub/version"
require "githug/version"

Gem::Specification.new do |s|
s.name = "gitscrub"
s.version = Gitscrub::VERSION
s.name = "githug"
s.version = Githug::VERSION
s.authors = ["Gary Rennie"]
s.email = ["webmaster@gazler.com"]
s.homepage = ""
s.summary = %q{An interactive way to learn git.}
s.description = %q{An interactive way to learn git.}

s.rubyforge_project = "gitscrub"
s.rubyforge_project = "githug"

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions levels/contribute.rb
Expand Up @@ -2,10 +2,10 @@
description "Contribute to this repository by making a pull request on Github"

solution do
location = "/tmp/gitscrub"
location = "/tmp/githug"
FileUtils.rm_rf(location)
puts "Cloning repository to #{location}"
`git clone git@github.com:Gazler/gitscrub.git #{location}`
`git clone git@github.com:Gazler/githug.git #{location}`

contributor = false

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions lib/githug.rb
@@ -0,0 +1,11 @@
require 'grit'
require "githug/version"

require 'githug/ui'
require 'githug/game'
require 'githug/profile'
require 'githug/level'
require 'githug/repository'

Githug::UI.in_stream = STDIN
Githug::UI.out_stream = STDOUT
20 changes: 10 additions & 10 deletions lib/gitscrub/cli.rb → lib/githug/cli.rb
@@ -1,6 +1,6 @@
require 'thor'
require 'gitscrub'
module Gitscrub
require 'githug'
module Githug
class CLI < Thor


Expand All @@ -9,7 +9,7 @@ class CLI < Thor
desc :play, "Initialize the game"

def play
UI.word_box("Gitscrub")
UI.word_box("Githug")
make_directory
game = Game.new
game.play_level
Expand All @@ -27,7 +27,7 @@ def hint

def reset
if level = load_level
UI.word_box("Gitscrub")
UI.word_box("Githug")
UI.puts("resetting level")
level.setup_level
level.full_description
Expand All @@ -43,15 +43,15 @@ def load_level


def make_directory
if File.exists?("./git_scrub")
UI.puts "Please change into the git_scrub directory"
if File.exists?("./git_hug")
UI.puts "Please change into the git_hug directory"
exit
end

unless File.basename(Dir.pwd) == "git_scrub"
if UI.ask("No gitscrub directory found, do you wish to create one?")
Dir.mkdir("./git_scrub")
Dir.chdir("git_scrub")
unless File.basename(Dir.pwd) == "git_hug"
if UI.ask("No githug directory found, do you wish to create one?")
Dir.mkdir("./git_hug")
Dir.chdir("git_hug")
File.open(".gitignore", "w") do |file|
file.write(".profile.yml")
end
Expand Down
4 changes: 2 additions & 2 deletions lib/gitscrub/game.rb → lib/githug/game.rb
@@ -1,4 +1,4 @@
module Gitscrub
module Githug
class Game

attr_accessor :profile
Expand All @@ -10,7 +10,7 @@ def initialize
def play_level
solve = true
if profile.level == 0
UI.puts("Welcome to Gitscrub")
UI.puts("Welcome to Githug")
solve = false
level_bump
else
Expand Down
6 changes: 3 additions & 3 deletions lib/gitscrub/level.rb → lib/githug/level.rb
@@ -1,4 +1,4 @@
module Gitscrub
module Githug
class Level
include UI

Expand All @@ -23,7 +23,7 @@ def load(level_no)

def init_from_level
FileUtils.cp_r("#{level_path}/.", ".")
FileUtils.mv(".gitscrub", ".git")
FileUtils.mv(".githug", ".git")
end

def difficulty(num)
Expand Down Expand Up @@ -72,7 +72,7 @@ def solve


def show_hint
UI.word_box("Gitscrub")
UI.word_box("Githug")
if @hint
@hint.call
else
Expand Down
2 changes: 1 addition & 1 deletion lib/gitscrub/profile.rb → lib/githug/profile.rb
@@ -1,5 +1,5 @@
require 'yaml'
module Gitscrub
module Githug
class Profile
PROFILE_FILE = ".profile.yml"

Expand Down
4 changes: 2 additions & 2 deletions lib/gitscrub/repository.rb → lib/githug/repository.rb
@@ -1,4 +1,4 @@
module Gitscrub
module Githug
class Repository

attr_accessor :grit
Expand All @@ -11,7 +11,7 @@ def initialize(location = ".")

def reset
dont_delete = ["..", ".", ".gitignore", ".profile.yml"]
if File.basename(Dir.pwd) == "git_scrub"
if File.basename(Dir.pwd) == "git_hug"
Dir.entries(Dir.pwd).each do |file|
FileUtils.rm_rf(file) unless dont_delete.include?(file)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/gitscrub/ui.rb → lib/githug/ui.rb
@@ -1,4 +1,4 @@
module Gitscrub
module Githug
module UI

@@out_stream
Expand Down
3 changes: 3 additions & 0 deletions lib/githug/version.rb
@@ -0,0 +1,3 @@
module Githug
VERSION = "0.0.9"
end
11 changes: 0 additions & 11 deletions lib/gitscrub.rb

This file was deleted.

3 changes: 0 additions & 3 deletions lib/gitscrub/version.rb

This file was deleted.

38 changes: 19 additions & 19 deletions spec/gitscrub/cli_spec.rb → spec/githug/cli_spec.rb
@@ -1,42 +1,42 @@
require 'spec_helper'
require 'gitscrub/cli'
require 'githug/cli'

describe Gitscrub::CLI do
describe Githug::CLI do

before(:each) do
game = mock.as_null_object
@cli = Gitscrub::CLI.new
Gitscrub::Game.stub(:new).and_return(game)
@cli = Githug::CLI.new
Githug::Game.stub(:new).and_return(game)
end

it "should print the logo" do
Gitscrub::UI.should_receive(:word_box).with("Gitscrub")
Githug::UI.should_receive(:word_box).with("Githug")
@cli.stub(:make_directory)
@cli.play
end

it "should create a directory if one does not exist" do
Gitscrub::UI.stub(:ask).and_return(true)
Dir.should_receive(:mkdir).with("./git_scrub")
Dir.should_receive(:chdir).with("git_scrub")
Githug::UI.stub(:ask).and_return(true)
Dir.should_receive(:mkdir).with("./git_hug")
Dir.should_receive(:chdir).with("git_hug")
File.should_receive(:open).with(".gitignore", "w").and_return(true)
@cli.make_directory
end

it "should not make a directory if you are in the game directory" do
Dir.stub(:pwd).and_return("/home/git_scrub")
Gitscrub::UI.should_not_receive(:ask)
Dir.stub(:pwd).and_return("/home/git_hug")
Githug::UI.should_not_receive(:ask)
@cli.make_directory
end

it "should exit if the user selects no" do
Gitscrub::UI.stub(:ask).and_return(false)
Githug::UI.stub(:ask).and_return(false)
lambda {@cli.make_directory}.should raise_error(SystemExit)
end

it "should prompt to change into the directory if it exists" do
File.stub(:exists?).and_return(true)
Gitscrub::UI.should_receive(:puts).with("Please change into the git_scrub directory")
Githug::UI.should_receive(:puts).with("Please change into the git_hug directory")
lambda {@cli.make_directory}.should raise_error(SystemExit)
end

Expand All @@ -45,8 +45,8 @@
@level = mock
@profile = mock
@profile.stub(:level).and_return(1)
Gitscrub::Profile.stub(:load).and_return(@profile)
Gitscrub::Level.stub(:load).and_return(@level)
Githug::Profile.stub(:load).and_return(@profile)
Githug::Level.stub(:load).and_return(@level)
end

it "should call the hint method on the level" do
Expand All @@ -60,17 +60,17 @@
it "should reset the current level" do
@level.should_receive(:setup_level)
@level.should_receive(:full_description)
Gitscrub::UI.should_receive(:word_box).with("Gitscrub")
Gitscrub::UI.should_receive(:puts).with("resetting level")
Githug::UI.should_receive(:word_box).with("Githug")
Githug::UI.should_receive(:puts).with("resetting level")
@cli.reset
end

it "should not reset if the level cannot be loaded" do
Gitscrub::Level.stub(:load).and_return(false)
Githug::Level.stub(:load).and_return(false)
@level.should_not_receive(:setup_level)
@level.should_not_receive(:full_description)
Gitscrub::UI.should_not_receive(:word_box).with("Gitscrub")
Gitscrub::UI.should_not_receive(:puts).with("resetting level")
Githug::UI.should_not_receive(:word_box).with("Githug")
Githug::UI.should_not_receive(:puts).with("resetting level")
@cli.reset
end
end
Expand Down
16 changes: 8 additions & 8 deletions spec/gitscrub/game_spec.rb → spec/githug/game_spec.rb
@@ -1,18 +1,18 @@
require 'spec_helper'

describe Gitscrub::Game do
describe Githug::Game do

before(:each) do
@profile = mock
Gitscrub::Profile.stub(:new).and_return(@profile)
@game = Gitscrub::Game.new
Githug::Profile.stub(:new).and_return(@profile)
@game = Githug::Game.new
@profile.stub(:level).and_return(1)
@profile.stub(:save)
@level = mock
@level.stub(:full_description)
@level.stub(:setup_level)
Gitscrub::UI.stub(:puts)
Gitscrub::Level.stub(:load).and_return(@level)
Githug::UI.stub(:puts)
Githug::Level.stub(:load).and_return(@level)
end

it "should have a profile" do
Expand All @@ -23,21 +23,21 @@
@level.should_not_receive(:solve)
@profile.stub(:level).and_return(0)
@profile.should_receive(:save)
Gitscrub::UI.should_receive(:puts).with("Welcome to Gitscrub")
Githug::UI.should_receive(:puts).with("Welcome to Githug")
@profile.should_receive(:level=).with(1)
@game.play_level
end

it "should echo congratulations if the level is solved" do
@level.stub(:solve).and_return(true)
@profile.should_receive(:level=).with(2)
Gitscrub::UI.should_receive(:success).with("Congratulations, you have solved the level")
Githug::UI.should_receive(:success).with("Congratulations, you have solved the level")
@game.play_level
end

it "should echo congratulations if the level is solved" do
@level.stub(:solve).and_return(false)
Gitscrub::UI.should_receive(:error).with("Sorry, this solution is not quite right!")
Githug::UI.should_receive(:error).with("Sorry, this solution is not quite right!")
@game.play_level
end

Expand Down

0 comments on commit 1621f85

Please sign in to comment.