Skip to content

Instantly share code, notes, and snippets.

@dimanon
Created April 8, 2012 12:05
Show Gist options
  • Save dimanon/2336875 to your computer and use it in GitHub Desktop.
Save dimanon/2336875 to your computer and use it in GitHub Desktop.
require 'fileutils'
class Directory
attr :blog_root
def initialize(dir)
@blog_root = File.expand_path(dir)
@dirname = @blog_root.split('/').last
@gem_root = File.expand_path('../..',__FILE__)
end
def copy_dir(*name)
name.each do |d|
puts "Copying #{d} dir"
FileUtils.cp_r(File.join(@gem_root, 'lib', 'site', d), @blog_root)
end
end
def create_blog_root
puts "Creating directory #{@blog_root}"
FileUtils.mkdir_p(File.join(@blog_root, 'articles'))
FileUtils.mkdir_p(File.join(@blog_root, 'pages'))
end
def create_git
puts "Creating git repo"
system "git init"
system "git add . && git commit -m 'Initial commit'"
end
def create_heroku
puts "Creating heroku app"
if system "heroku create #{@dirname} --stack bamboo-mri-1.9.2"
puts "Pushing to heroku - in 5 seconds"
sleep 5
if system 'git push heroku master'
puts "Your app now lives at http://#{@dirname}.heroku.com"
else
puts "Failed to push to heroku!"
end
else
puts "ERROR: Failed to create heroku app"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment