Skip to content

Commit

Permalink
Cache Elm versions of package versions.
Browse files Browse the repository at this point in the history
Fixes #42
  • Loading branch information
gdotdesign committed Sep 15, 2017
1 parent 110ed44 commit 14de1ed
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/elm_install/git_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ def copy_to(version, directory)
nil
end

Contract String => String
# Returns the supported Elm version the given ref.
#
# @param ref [String] The ref
#
# @return [Array] The version
def elm_version_of(ref)
@@elm_versions ||= {}
@@elm_versions[url] ||= {}
@@elm_versions[url][ref] ||= identifier.elm_version(fetch(ref))
end

Contract ArrayOf[Solve::Constraint], String => ArrayOf[Semverse::Version]
# Returns the available versions for a repository
#
Expand Down Expand Up @@ -101,7 +113,7 @@ def matching_versions(constraints, elm_version)
repository
.versions
.select do |version|
identifier.elm_version(fetch(version.to_s)) == elm_version &&
elm_version_of(version.to_s) == elm_version &&
constraints.all? { |constraint| constraint.satisfies?(version) }
end
.sort
Expand Down

0 comments on commit 14de1ed

Please sign in to comment.