Skip to content

Commit

Permalink
removed trailing spaces in project
Browse files Browse the repository at this point in the history
  • Loading branch information
Al Snow committed Dec 2, 2012
1 parent 4cd59f9 commit fa98cf2
Show file tree
Hide file tree
Showing 23 changed files with 86 additions and 86 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ 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.

All methods called on `repo` are sent to the [grit gem](https://github.com/mojombo/grit) if the method does not exist, and you can use that for most git related commands (`repo.add`, `repo.commit`, etc.)
Expand Down
2 changes: 1 addition & 1 deletion levels/blame/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Config
def initialize(name, password = nil, options = {})
@name = name
@password = password || "i<3evil"

if options[:downcase]
@name.downcase!
end
Expand Down
2 changes: 1 addition & 1 deletion levels/branch_at.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
difficulty 3
description "You forgot to branch at the previous commit and made a commit on top of it. Create branch 'test_branch' at the commit before the last"
description "You forgot to branch at the previous commit and made a commit on top of it. Create branch 'test_branch' at the commit before the last"

setup do
repo.init
Expand Down
2 changes: 1 addition & 1 deletion levels/commit_amend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Reset config - see issue #74
file = File.open(".git/config", "w") do |file|
file.puts("[format]")
file.puts(" pretty = medium")
file.puts(" pretty = medium")
end
repo.commits.length == 1 && Grit::CommitStats.find_all(repo, repo.commits.first.sha).first[1].files.length == 2
end
Expand Down
4 changes: 2 additions & 2 deletions levels/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
solution do

valid = false
name = request("What is your name?")

name = request("What is your name?")
email = request("What is your email?")
config_name = repo.config["user.name"]
config_email = repo.config["user.email"]
Expand Down
2 changes: 1 addition & 1 deletion levels/ignore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
solution do

valid = false


File.open(".gitignore", "r") do |file|
while line = file.gets
Expand Down
4 changes: 2 additions & 2 deletions levels/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

setup do
repo.init
file = File.new("newfile.rb", "w")
file = File.new("newfile.rb", "w")
repo.add("newfile.rb")
repo.commit_all("THIS IS THE COMMIT YOU ARE LOOKING FOR!")
end

solution do
repo.commits.last.id_abbrev == request("What are the first 7 characters of the hash of the most recent commit?")
repo.commits.last.id_abbrev == request("What are the first 7 characters of the hash of the most recent commit?")
end

hint do
Expand Down
2 changes: 1 addition & 1 deletion levels/merge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
end

solution do
File.exists?("file1") && File.exists?("file2")
File.exists?("file1") && File.exists?("file2")
end

hint do
Expand Down
8 changes: 4 additions & 4 deletions levels/merge_squash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
File.open("file3", 'a') { |f| f << "and awesomer!\n" }
repo.add "file3"
repo.commit_all "Time"

repo.git.native :checkout, {}, 'master'

FileUtils.touch "file2"
repo.add "file2"
repo.commit_all "Second commit"
Expand All @@ -33,13 +33,13 @@

# Check the number of commits in the repo (should be 4 - including initial .gitignore).
result = false unless repo.commits.size == 3

# Check if changes from all the commits from long-feature-branch are included.
file = File.open('file3')
result = false unless file.readline =~ /some feature/
result = false unless file.readline =~ /getting awesomer/
result = false unless file.readline =~ /and awesomer!/

result
end

Expand Down
2 changes: 1 addition & 1 deletion levels/rm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup do
repo.init
file = File.new("deleteme.rb", "w")
file = File.new("deleteme.rb", "w")
file.close
repo.add("deleteme.rb")
repo.commit_all("Added a temp file")
Expand Down
2 changes: 1 addition & 1 deletion levels/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

solution do

name = request("What is the full file name of the untracked file?")
name = request("What is the full file name of the untracked file?")

if name != "database.yml"
return false
Expand Down
4 changes: 2 additions & 2 deletions lib/githug/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def play
def test(path)
UI.word_box("Githug")
make_directory
level = Level.load_from_file(path)
level = Level.load_from_file(path)
game = Game.new
game.test_level(level, options[:errors])
end
Expand Down Expand Up @@ -61,7 +61,7 @@ def load_level


def make_directory
if File.exists?("./git_hug")
if File.exists?("./git_hug")
UI.puts "Please change into the git_hug directory"
exit
end
Expand Down
2 changes: 1 addition & 1 deletion lib/githug/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def play_level
else
level = Level.load(profile.level)
if solve && level
if level.solve
if level.solve
UI.success "Congratulations, you have solved the level"
level_bump
else
Expand Down
6 changes: 3 additions & 3 deletions lib/githug/level.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class Level
"find_old_branch", "revert", "restore", "conflict", "contribute"]

attr_accessor :level_no, :level_path

class << self

def load(level_name)
path = "#{File.dirname(__FILE__)}/../../levels/#{level_name}.rb"
setup(path)
Expand Down Expand Up @@ -57,7 +57,7 @@ def solution(&block)
end

def setup(&block)
@setup = block
@setup = block
end

def hint(&hint)
Expand Down
2 changes: 1 addition & 1 deletion lib/githug/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def load
:current_attempts => 0,
:current_hint_index => 0,
:current_levels => [],
:completed_levels => []
:completed_levels => []
}

settings.merge! YAML::load(File.open(PROFILE_FILE)) if File.exists?(PROFILE_FILE)
Expand Down
6 changes: 3 additions & 3 deletions lib/githug/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Githug
class Repository

attr_accessor :grit

def initialize(location = ".")
@grit = Grit::Repo.new(location)
rescue Grit::InvalidGitRepositoryError
Expand All @@ -13,7 +13,7 @@ def reset
dont_delete = ["..", ".", ".profile.yml"]
if File.basename(Dir.pwd) == "git_hug"
Dir.entries(Dir.pwd).each do |file|
FileUtils.rm_rf(file) unless dont_delete.include?(file)
FileUtils.rm_rf(file) unless dont_delete.include?(file)
end
end
create_gitignore
Expand All @@ -37,7 +37,7 @@ def init(location = ".")
end

def method_missing(method, *args, &block)
if @grit && @grit.respond_to?(method)
if @grit && @grit.respond_to?(method)
return @grit.send(method, *args, &block)
end
super
Expand Down
4 changes: 2 additions & 2 deletions lib/githug/ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module UI
@@in_stream = STDIN

class << self

def out_stream=(out)
@@out_stream = out
end
Expand Down Expand Up @@ -45,7 +45,7 @@ def request(msg)
print("#{msg} ")
gets.chomp
end

def ask(msg)
request("#{msg} [yn] ") == 'y'
end
Expand Down
22 changes: 11 additions & 11 deletions spec/githug/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'githug/cli'

describe Githug::CLI do

before(:each) do
game = mock.as_null_object
@cli = Githug::CLI.new
Expand All @@ -11,12 +11,12 @@

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

it "should create a directory if one does not exist" do
Githug::UI.stub(:ask).and_return(true)
Githug::UI.stub(:ask).and_return(true)
Dir.should_receive(:mkdir).with("./git_hug")
Dir.should_receive(:chdir).with("git_hug")
@cli.make_directory
Expand All @@ -25,16 +25,16 @@
it "should not make a directory if you are in the game directory" do
Dir.stub(:pwd).and_return("/home/git_hug")
Githug::UI.should_not_receive(:ask)
@cli.make_directory
@cli.make_directory
end

it "should exit if the user selects no" do
Githug::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)
File.stub(:exists?).and_return(true)
Githug::UI.should_receive(:puts).with("Please change into the git_hug directory")
lambda {@cli.make_directory}.should raise_error(SystemExit)
end
Expand All @@ -44,7 +44,7 @@
level = mock
game = mock
@cli.stub(:make_directory)
Githug::Level.should_receive(:load_from_file).with("/foo/bar/test/level.rb").and_return(level)
Githug::Level.should_receive(:load_from_file).with("/foo/bar/test/level.rb").and_return(level)
Githug::Game.stub(:new).and_return(game)
game.should_receive(:test_level).with(level, anything)
@cli.test("/foo/bar/test/level.rb")
Expand All @@ -67,8 +67,8 @@
end

describe "reset" do


it "should reset the current level" do
@level.should_receive(:setup_level)
@level.should_receive(:full_description)
Expand All @@ -92,8 +92,8 @@
Githug::UI.should_receive(:puts).with("resetting level")
@cli.reset("/foo/bar/level.rb")
end
end
end

end

end
12 changes: 6 additions & 6 deletions spec/githug/game_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe Githug::Game do

before(:each) do
@profile = mock.as_null_object
Githug::Profile.stub(:new).and_return(@profile)
Expand Down Expand Up @@ -64,13 +64,13 @@

describe "test_level" do
it "Should output Valid solution if the solution is valid" do
@level.stub(:solve).and_return(true)
@level.stub(:solve).and_return(true)
Githug::UI.should_receive(:success).with("Valid solution")
@game.test_level(@level)
end

it "Should output Invalid solution if the solution is invalid" do
@level.stub(:solve).and_return(false)
@level.stub(:solve).and_return(false)
Githug::UI.should_receive(:error).with("Invalid solution")
@game.test_level(@level)
end
Expand All @@ -88,9 +88,9 @@
end

it "should call setup_level for the next level" do
@level.should_receive(:setup_level)
@level.should_receive(:setup_level)
@profile.stub(:level=)
@game.level_bump
end

end
Loading

0 comments on commit fa98cf2

Please sign in to comment.