-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.rb
More file actions
executable file
·61 lines (46 loc) · 1.49 KB
/
setup.rb
File metadata and controls
executable file
·61 lines (46 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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