Skip to content

Instantly share code, notes, and snippets.

@rottmanj
Created November 25, 2013 00:03
Show Gist options
  • Save rottmanj/7634262 to your computer and use it in GitHub Desktop.
Save rottmanj/7634262 to your computer and use it in GitHub Desktop.
Apiary rake task. Combines all .apib files into a single file so that it can be consumed by apiary.
namespace :docs do
namespace :apiary do
task :build do
File.delete("#{Rails.root}/docs/apiary/blueprint.apib") if File.exist?("#{Rails.root}/docs/apiary/blueprint.apib")
header = File.open("#{Rails.root}/docs/apiary/header.apib")
File.open("#{Rails.root}/docs/apiary/blueprint.apib", 'a') do |file|
file.write(header.read)
header.close
file.close
end
Dir.foreach("#{Rails.root}/docs/apiary") do | blueprint |
next if blueprint == '.' or blueprint == '..' or blueprint == "header.apib" or blueprint == "blueprint.apib"
segment = File.open("#{Rails.root}/docs/apiary/#{blueprint}")
File.open("#{Rails.root}/docs/apiary/blueprint.apib", 'a') do |file|
file.write("#{segment.read} \n\n")
segment.close
file.close
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment