class Elm::Rails::Sprockets::DependencyGraph

Public Instance Methods

each(&block) click to toggle source
# File lib/elm/rails/sprockets.rb, line 47
def each &block
  recurse File.read(filename), block
end

Private Instance Methods

import_regex() click to toggle source
# File lib/elm/rails/sprockets.rb, line 67
def import_regex
  # `import Quiz.Question exposing (..)`
  /^import\s+([^\s]+)/
end
recurse(source, block) click to toggle source
# File lib/elm/rails/sprockets.rb, line 53
def recurse source, block
  source.scan(import_regex) do |(module_name)|
    logical_name = module_name.gsub(".", "/")
    filepath = load_path + "/" + logical_name + ".elm"

    # If we don't find the dependency in our filesystem, assume it's because
    # it comes in through a third-party package rather than our sources.
    if File.file?(filepath)
      block.call logical_name
      recurse File.read(filepath), block
    end
  end
end