Class: DoubleDoc::Client
- Inherits:
-
Object
- Object
- DoubleDoc::Client
- Defined in:
- lib/double_doc/client.rb
Instance Attribute Summary collapse
-
#md_sources ⇒ Object
readonly
Returns the value of attribute md_sources.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(md_sources, options = {}) ⇒ Client
constructor
A new instance of Client.
- #process ⇒ Object
Constructor Details
#initialize(md_sources, options = {}) ⇒ Client
Returns a new instance of Client.
8 9 10 11 |
# File 'lib/double_doc/client.rb', line 8 def initialize(md_sources, = {}) @md_sources = [md_sources].flatten = end |
Instance Attribute Details
#md_sources ⇒ Object (readonly)
Returns the value of attribute md_sources.
6 7 8 |
# File 'lib/double_doc/client.rb', line 6 def md_sources @md_sources end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/double_doc/client.rb', line 6 def end |
Instance Method Details
#process ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/double_doc/client.rb', line 13 def process sources = md_sources.map do |source| if source.to_s =~ /\*/ import_handler.load_paths.map do |path| Dir.glob(File.join(path, source)) end else import_handler.find_file(source).path end end.flatten.uniq generated_md_files = [] md_dst = Pathname.new([:md_destination]) system('mkdir', '-p', md_dst.to_s) sources.each do |src| next if File.directory?(src) dst = md_dst + File.basename(src) puts "#{src} -> #{dst}" unless [:quiet] if src.to_s =~ /\.md$/ body = import_handler.resolve_imports(File.new(src)) else body = File.read(src) end File.open(dst, 'w') do |out| out.write(body) end generated_md_files << dst end args = [:args] || {} html_dst = Pathname.new([:html_destination]) if [:html_destination] if html_dst || args[:html_destination] html_generator = DoubleDoc::HtmlGenerator.new(generated_md_files, .merge(args)) html_generator.generate end sources end |