Guest User

Untitled

a guest
May 27th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. @app_name = File.basename(@root)
  2.  
  3. # Delete unnecessary files
  4. run "rm README"
  5. run "rm public/index.html"
  6. run "rm public/favicon.ico"
  7. run "rm public/robots.txt"
  8. run "rm public/images/rails.png"
  9. run "rm -f public/javascripts/*"
  10. run "rm config/database.yml"
  11.  
  12. # Set up git repository
  13. git :init
  14. git :add => '.'
  15.  
  16. # Create stub database.yml and database.yml.example
  17. file 'config/database.yml',
  18. %Q{
  19. development:
  20. adapter: mysql
  21. database: #{@app_name}_development
  22. username: root
  23. password:
  24. host: localhost
  25. encoding: utf8
  26.  
  27. test:
  28. adapter: mysql
  29. database: #{@app_name}_test
  30. username: root
  31. password:
  32. host: localhost
  33. encoding: utf8
  34. }
  35. run "cp config/database.yml config/database.yml.example"
  36.  
  37. # Set up .gitignore files
  38. run "touch tmp/.gitignore log/.gitignore vendor/.gitignore"
  39. run %{find . -type d -empty | grep -v "vendor" | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore}
  40. file '.gitignore', <<-END
  41. .DS_Store
  42. log/*.log
  43. tmp/**/*
  44. config/database.yml
  45. db/*.sqlite3
  46. vendor/rails
  47. vendor/bundle
  48. END
  49.  
  50. file 'Gemfile', %{
  51. source :rubygems
  52.  
  53. gem 'rails', '#{Rails::VERSION::STRING}'
  54. gem 'mysql'
  55.  
  56. group :development do
  57. gem 'ruby-debug'
  58. end
  59.  
  60. group :test do
  61. gem 'rspec'
  62. gem 'rspec-rails'
  63. end
  64. }.strip
  65.  
  66. append_file '/.gitignore', %{
  67. /.bundle
  68. }
  69.  
  70. append_file '/config/preinitializer.rb', %{
  71. begin
  72. require "rubygems"
  73. require "bundler"
  74. rescue LoadError
  75. raise "Could not load the bundler gem. Install it with `gem install bundler`."
  76. end
  77.  
  78. if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
  79. raise RuntimeError, "Your bundler version is too old." +
  80. "Run `gem install bundler` to upgrade."
  81. end
  82.  
  83. begin
  84. # Set up load paths for all bundled gems
  85. ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
  86. Bundler.setup
  87. rescue Bundler::GemNotFound
  88. raise RuntimeError, "Bundler couldn't find some gems." +
  89. "Did you run `bundle install`?"
  90. end
  91. }.strip
  92.  
  93. gsub_file 'config/boot.rb', "Rails.boot!", %{
  94.  
  95. class Rails::Boot
  96. def run
  97. load_initializer
  98.  
  99. Rails::Initializer.class_eval do
  100. def load_gems
  101. @bundler_loaded ||= Bundler.require :default, Rails.env
  102. end
  103. end
  104.  
  105. Rails::Initializer.run(:set_load_path)
  106. end
  107. end
  108.  
  109. Rails.boot!
  110. }
  111.  
  112. # Prepare for BDD
  113. generate("rspec")
  114. generate("cucumber")
  115.  
  116. # Commit all work so far to the repository
  117. git :add => '.'
  118. git :commit => "-a -m 'First commit'"
  119.  
  120. run 'bundle install vendor/bundle --disable-shared-gems'
  121.  
  122. puts "Now you're all set up."
  123. puts "Please go on, write some features, and make them pass."
Add Comment
Please, Sign In to add comment