Created
November 25, 2013 00:03
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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