Skip to content

Commit

Permalink
basic setup
Browse files Browse the repository at this point in the history
  • Loading branch information
bellmyer committed Feb 26, 2011
0 parents commit 17b0219
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 0 deletions.
Empty file added .gitignore
Empty file.
22 changes: 22 additions & 0 deletions README
@@ -0,0 +1,22 @@
This will set you up with basic automated testing for code retreat
practice using Conway's Game of Life. It will create a "code_retreat"
gemset, install the needed gems, and set the gemset as your default
whenever you enter the working directory.

Set it up by rvm use-ing your chosen ruby version, then running this
on the command line:

ruby setup.rb

When you want to start over, reset like this:

ruby reset.rb

This will remove all your code changes.

If you have the screencapture application installed, this will
take a screenshot every time you save your file, so you can look
back fondly on your work :) These will be saved in the "screencaptures"
directory as png files you can later turn into a slideshow if you want.

screenshots are timestamped, and not erased when you reset.
17 changes: 17 additions & 0 deletions life.example
@@ -0,0 +1,17 @@
#!/usr/bin/ruby

require 'test/unit'
require 'rubygems'
require 'redgreen'
require 'fsevent'
require 'dust'

# code goes here


# tests go here
class LifeTest < Test::Unit::TestCase
test "should do something" do
assert true
end
end
13 changes: 13 additions & 0 deletions life.watchr
@@ -0,0 +1,13 @@
# get screencapture command, if available
screencapture = File.exists?('.screencapture') ?
File.open('.screencapture', 'r'){|f| f.read} :
nil

watch('life.rb') do |md|
system './life.rb'

if screencapture
timestamp = Time.now.to_s.split(/\s+/)[1].gsub(/:/, '')
system "#{screencapture} -x screencaptures/#{timestamp}.png"
end
end
10 changes: 10 additions & 0 deletions reset.rb
@@ -0,0 +1,10 @@
#!/usr/bin/ruby

def run command
puts command
puts `#{command}`
end

# reset life.rb
run "cp life.example life.rb"

61 changes: 61 additions & 0 deletions setup.rb
@@ -0,0 +1,61 @@
#!/usr/bin/ruby

def run command
puts command
puts `#{command}`
end

# require ruby version as a parameter. otherwise, print usage
ruby_version = `rvm-prompt`.chomp

if ruby_version == ''
puts <<USAGE
You need to be in rvm first, then re-run this command.
USAGE

exit 0
else
ruby_version = ruby_version.split(/@/).first
end

# gemset command string
gemset_command = "rvm use #{ruby_version}@code_retreat"

# setup gemset
run "rvm use #{ruby_version} && rvm gemset create code_retreat && #{gemset_command}"

# automatically use this gemset when we enter this directory
File.open('.rvmrc', 'w'){|f| f.write gemset_command}

# download the required gems
['dust', 'redgreen', 'ruby-fsevent', 'watchr'].each do |gem_name|
run "gem install #{gem_name} --no-rdoc --no-ri"
end

# reset life.rb
run "cp life.example life.rb"

# try to get screencapture app
screencapture = `whereis screencapture`.chomp
screencapture_message = ""
unless screencapture == ""
File.open('.screencapture', 'w'){|f| f.write screencapture}
system "mkdir screencaptures"

screencapture_message = "Every save will take a snapshot of your progress,\n which you can find in the screencaptures directory!\n"
end

# print instructions
puts <<INSTRUCTIONS
--------------------
Great! Now run watcher like so:
watchr life.watchr
And start adding your code to life.rb in your favorite editor.
Your tests will run automatically every time you save the file.
#{screencapture_message}
Enjoy :)
--------------------
INSTRUCTIONS

0 comments on commit 17b0219

Please sign in to comment.