Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 17b0219
Showing
6 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,10 @@ | |||
#!/usr/bin/ruby | |||
|
|||
def run command | |||
puts command | |||
puts `#{command}` | |||
end | |||
|
|||
# reset life.rb | |||
run "cp life.example life.rb" | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |