Make readme generator more flexible

This commit is contained in:
Dave Syer
2014-09-29 16:44:14 +01:00
parent b06a51fd6d
commit 238a57bbcf
2 changed files with 19 additions and 8 deletions

View File

@@ -3,8 +3,17 @@
base_dir = File.join(File.dirname(__FILE__),'../../..')
src_dir = File.join(base_dir, "/src/main/asciidoc")
require File.join(File.dirname(__FILE__), 'readme.rb')
require 'optparse'
options = {}
ARGV.length > 0 and options[:to_file] = ARGV[0]
input = "#{src_dir}/README.adoc"
SpringCloud::Build.render_file("#{src_dir}/README.adoc", options)
OptionParser.new do |o|
o.on('-o OUTPUT_FILE', 'Output file (default is stdout)') { |file| options[:to_file] = file unless file=='-' }
o.on('-h', '--help') { puts o; exit }
o.parse!
end
input = ARGV[0] if ARGV.length>0
SpringCloud::Build.render_file(input, options)

View File

@@ -1,3 +1,5 @@
require 'open-uri'
module SpringCloud
module Build
@@ -6,13 +8,13 @@ module SpringCloud
class << self
def process_include out, src, target, attrs
unless target.start_with?('/')
target = File.new(File.join(src, target))
else
target = File.new(target)
unless target.include?(':') || target.start_with?('/')
target = File.join(src, target)
end
target.each do |line|
self.process(out, File.dirname(target), line)
open(target) do |file|
file.each do |line|
self.process(out, File.dirname(target), line)
end
end
end