Skip to content

Instantly share code, notes, and snippets.

@JoeyButler
Created July 9, 2012 04:20
Show Gist options
  • Save JoeyButler/3074195 to your computer and use it in GitHub Desktop.
Save JoeyButler/3074195 to your computer and use it in GitHub Desktop.
Mini Thor app to create a new ruby project
#!/usr/bin/env ruby
class App < Thor
include Thor::Actions
desc "create", "creates folder with project name include the gemfile and rvm gemset"
def create(name)
Dir.mkdir name
template "templates/generic_gemfile.erb", "#{name}/Gemfile"
`echo 'rvm use 1.9.3-p125@#{name} --create' > #{name}/.rvmrc`
end
# Used internally by thor. I have no idea why it doesn't have this by default.
def self.source_root
File.dirname(__FILE__)
end
end

thor install app_create.thor Make sure that the templates__generic_gemfile.erb is renamed and moved to ~/.thor/templates/generic_gemfile.erb

Then you can run thor list to verify that the script was installed successfully. If the command appears in the output, you should be good to run thor app:create APP_NAME.

source 'https://rubygems.org'
group :development do
gem 'pry'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment