forked from twoism/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruby_project
executable file
·55 lines (41 loc) · 1.14 KB
/
ruby_project
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
#!/usr/bin/env ruby
puts "Project Name:"
@project_name = gets().chomp
@dirs = %w{lib spec}
@files = %w{README.md .rspec Guardfile .gitignore spec/helper.rb}
@dirs.each {|dir| `mkdir #{dir}` }
@files.each{|file| `touch #{file}` }
GIT_IGNORE = <<-TEXT
*.swp
*.swo
*.orig
.DS_Store
TEXT
SPEC_OPTS = <<-TEXT
--colour
--format progress
TEXT
GUARDFILE = %q[
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('spec/helper.rb') { "spec" }
end
]
SPEC_HELPER = <<-RUBY
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
RSpec.configure do |config|
end
RUBY
File.open('Guardfile','w') {|f| f.write GUARDFILE }
File.open('.gitignore','w') {|f| f.write GIT_IGNORE }
File.open('.rspec','w') {|f| f.write SPEC_OPTS }
File.open('spec/helper.rb','w') {|f| f.write SPEC_HELPER }
p `rvm --rvmrc 1.9.2@#{@project_name}`
`cd .. && cd -`
p `gem install rspec guard-rspec`
puts "done."