require 'rake/task' desc 'Generate Gemfile from Gemfile.rb' task :gemfile do confroot = ENV['confroot'] || File.expand_path('~/.mikutter') gemfile = File.open('./Gemfile.rb').read.sub('confroot',confroot) file = File.open('./Gemfile', 'w') file.write(gemfile) file.close end desc 'install gems' task install: :gemfile do command = ["bundle", "install"] command = command + ['--path', ENV['gem_dir']] if ENV['gem_dir'] system command.join(' ') end desc 'run mikutter' task :run do log = system 'bundle exec ruby mikutter.rb' puts 'cannot run mikutter! please exec "rake gemfile and rake install"' unless log end task :default => :run