Loading lib/jsduck/process/importer.rb +19 −1 Original line number Diff line number Diff line Loading @@ -28,9 +28,11 @@ module JsDuck # Reads in data from all .json files in directory def read(ver) ensure_correct_format(ver[:path]) # Map list of files into pairs of (classname, members-hash) pairs = Util::Parallel.map(Dir[ver[:path] + "/*.json"]) do |filename| JsDuck::Logger.log("Importing #{ver[:version]}", filename) Logger.log("Importing #{ver[:version]}", filename) json = Util::Json.read(filename) [json["name"], members_id_index(json)] end Loading @@ -39,6 +41,22 @@ module JsDuck return Hash[ pairs ] end def ensure_correct_format(path) # Read first JSON file in import dir json = Util::Json.read(Dir[path + "/*.json"].first) unless correct_format?(json) Logger.fatal("Bad format for importing: #{path}") Logger.fatal("Export format changed in 5.0.0 beta 2.") Logger.fatal("Maybe you forgot to re-generate the exports with new JSDuck.") exit(1) end end def correct_format?(json) json["members"].is_a?(Array) end # creates index of all class members def members_id_index(json) index = {} Loading Loading
lib/jsduck/process/importer.rb +19 −1 Original line number Diff line number Diff line Loading @@ -28,9 +28,11 @@ module JsDuck # Reads in data from all .json files in directory def read(ver) ensure_correct_format(ver[:path]) # Map list of files into pairs of (classname, members-hash) pairs = Util::Parallel.map(Dir[ver[:path] + "/*.json"]) do |filename| JsDuck::Logger.log("Importing #{ver[:version]}", filename) Logger.log("Importing #{ver[:version]}", filename) json = Util::Json.read(filename) [json["name"], members_id_index(json)] end Loading @@ -39,6 +41,22 @@ module JsDuck return Hash[ pairs ] end def ensure_correct_format(path) # Read first JSON file in import dir json = Util::Json.read(Dir[path + "/*.json"].first) unless correct_format?(json) Logger.fatal("Bad format for importing: #{path}") Logger.fatal("Export format changed in 5.0.0 beta 2.") Logger.fatal("Maybe you forgot to re-generate the exports with new JSDuck.") exit(1) end end def correct_format?(json) json["members"].is_a?(Array) end # creates index of all class members def members_id_index(json) index = {} Loading