lib/bibliothecary/parsers/julia.rb in bibliothecary-0.10.0 vs lib/bibliothecary/parsers/julia.rb in bibliothecary-0.11.0
- old
+ new
@@ -1,44 +1,88 @@
# REQUIRE
+module Bibliothecary
+ module Parsers
+ class Julia
+ PLATFORM_NAME = 'julia'
+
+ def self.parse(filename, file_contents)
+ if filename.match(/^REQUIRE$/i)
+ parse_require(file_contents)
+ else
+ []
+ end
+ end
+
+ def self.analyse(folder_path, file_list)
+ [analyse_json(folder_path, file_list),
+ analyse_yaml(folder_path, file_list)]
+ end
+
+ def self.analyse_json(folder_path, file_list)
+ path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^REQUIRE$/i) }
+ return unless path
+
+ manifest = File.open(path).read
+
+ {
+ platform: PLATFORM_NAME,
+ path: path,
+ dependencies: parse_require(manifest)
+ }
+ end
+
+ def self.parse_require(manifest)
+ manifest.split("\n").map do |line|
+ match = line.split(/\s/)
+ {
+ name: match[0],
+ requirement: match[1] || '*',
+ type: 'runtime'
+ }
+ end
+ end
+ end
+ end
+end