Class: Bibliothecary::Parsers::Julia

Inherits:
Object
  • Object
show all
Defined in:
lib/bibliothecary/parsers/julia.rb

Constant Summary collapse

PLATFORM_NAME =
'julia'

Class Method Summary collapse

Class Method Details

.analyse(folder_path, file_list) ⇒ Object



14
15
16
# File 'lib/bibliothecary/parsers/julia.rb', line 14

def self.analyse(folder_path, file_list)
  [analyse_json(folder_path, file_list)]
end

.analyse_json(folder_path, file_list) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bibliothecary/parsers/julia.rb', line 18

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)
  }
rescue
  []
end

.parse(filename, file_contents) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/bibliothecary/parsers/julia.rb', line 6

def self.parse(filename, file_contents)
  if filename.match(/^REQUIRE$/i)
    parse_require(file_contents)
  else
    []
  end
end

.parse_require(manifest) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/bibliothecary/parsers/julia.rb', line 33

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