diff --git a/Rakefile b/Rakefile index 774924481..e60dc8ed1 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,7 @@ require 'rubygems' require 'bundler/setup' require 'date' +require 'fog' ############################################################################# # @@ -130,3 +131,35 @@ task :validate do exit! end end + +task :docs do + # build the docs locally + sh "jekyll docs docs/_site" + + # connect to storage provider and write files to versioned 'folder' + Fog.credential = :geemus + storage = Fog::Storage.new(:provider => 'AWS') + directory = storage.directories.new(:key => 'fog.io') + for file_path in Dir.glob('docs/_site/**/*') + next if File.directory?(file_path) + file_name = file_path.gsub('docs/_site/', '') + key = '' << version << '/' << file_name + Formatador.redisplay(' ' * 80) # clear last line + Formatador.redisplay('Uploading ' << key) + directory.files.create( + :body => File.open(file_path), + :key => key, + :public => true + ) + end + + # write base index with redirect to new version + directory.files.create( + :body => '', + :content_type => 'text/html', + :key => 'index.html', + :public => true + ) + + Formatador.display_line +end