lib/adiwg/mdtranslator.rb in adiwg-mdtranslator-0.8.2 vs lib/adiwg/mdtranslator.rb in adiwg-mdtranslator-0.8.5

- old
+ new

@@ -7,10 +7,12 @@ # Stan Smith 2014-07-21 added ADIWG namespace # Stan Smith 2014-07-21 added validation of json structure # Stan Smith 2014-07-23 moved all validations to readers/adiwg/adiwg_validator.rb # ... each reader will have it's own validator # Stan Smith 2014-09-26 added processing of minor release numbers +# Stan Smith 2014-10-10 added method to return path to readers and writers +# Stan Smith 2014-10-11 added methods to return content of readme files # add main directories to load_path $LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'mdtranslator')) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'mdtranslator/internal')) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'mdtranslator/readers')) @@ -88,9 +90,38 @@ def self.reader_module(moduleName, version) dir = File.join($response[:readerName], 'modules_' + version) file = File.join(dir, moduleName) return file + end + + # return path to readers and writers + def self.path_to_resources + File.join(File.dirname(File.expand_path(__FILE__)),'mdtranslator') + end + + # return reader readme text + def self.get_reader_readme(reader) + readmeText = 'No text found' + path = File.join(path_to_resources, 'readers', reader, 'readme.md') + if File.exist?(path) + file = File.open(path, 'r') + readmeText = file.read + file.close + end + return readmeText + end + + # return writer readme text + def self.get_writer_readme(writer) + readmeText = 'No text found' + path = File.join(path_to_resources, 'writers', writer, 'readme.md') + if File.exist?(path) + file = File.open(path, 'r') + readmeText = file.read + file.close + end + return readmeText end end end