Class: Elm::Dependencies

Inherits:
Object
  • Object
show all
Includes:
Contracts::Builtin, Contracts::Core
Defined in:
lib/elm/dependencies.rb

Overview

Get files in dependencies from an Elm file or code

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_content(content) ⇒ Object



42
43
44
45
# File 'lib/elm/dependencies.rb', line 42

def self.from_content(content)
  dep = new.init content
  only_existing_files dep.dependencies
end

.from_file(file) ⇒ Object



35
36
37
38
39
# File 'lib/elm/dependencies.rb', line 35

def self.from_file(file)
  # Error if not exists
  dep = new.init File.read(file), [File.dirname(file)]
  only_existing_files dep.dependencies
end

.only_existing_files(dependencies) ⇒ Object



48
49
50
# File 'lib/elm/dependencies.rb', line 48

def self.only_existing_files(dependencies)
  dependencies
end

Instance Method Details

#dependenciesObject



70
71
72
# File 'lib/elm/dependencies.rb', line 70

def dependencies
  extract_dependencies(@content).uniq
end

#init(content, dirs) ⇒ Object



53
54
55
56
57
# File 'lib/elm/dependencies.rb', line 53

def init(content)
  init content, find_dirs

  self
end