lib/calamum/doc_parser.rb in calamum-1.1.0 vs lib/calamum/doc_parser.rb in calamum-1.2.0

- old
+ new

@@ -11,20 +11,31 @@ end def get_name @definition['name'] end - + def get_version @definition['version'] end - + def get_description @definition['description'] end def get_resources - Calamum::Config[:sort]? @definition['resources'].sort : @definition['resources'] + resources = @definition['resources'].kind_of?(String) ? get_seperate_resources : @definition['resources'] + Calamum::Config[:sort]? resources.sort : resources + end + + def get_seperate_resources + extension = File.extname(Calamum::Config[:source]) + path = File.expand_path("#{@definition['resources']}", File.dirname(Calamum::Config[:source])) + case extension + when '.json' then Dir["#{path}/*#{extension}"].map { |f| Yajl.load File.read(f) }.flatten.reduce({}, :merge) + when '.yml' then Dir["#{path}/*#{extension}"].map { |f| YAML.load File.read(f) }.flatten.reduce({}, :merge) + else raise 'unknown source file extension' + end end def load_resources get_resources.each do |name, methods| list = []