EY::Resolver

Resolves a set of query options to an Array of AppEnvironment (AppDeployment) that best match the query. At least one query parameter must be 'app_name' or 'remotes' or it raises EY::Resolver::UnconstrainedError (ArgumentError).

It works by first doing a pass asking for any AppEnvironments that have the query arguments as substrings, keeping only those that match all query params.

Next, if remotes were passed, and 'app_name' was not, it constrains by remotes using Gitable::URI's equivalent matching algorithm to restrict to only those with the right remote URIs (public and private repo URIs should match).

Lastly, it tries to discover better matches by scoring each match based on the number of exact matches it has. An exact match means the query param is exactly the full string of the matching attribute.

The results are all AppEnvironments that have the same top exact match score. It's possible for there to be more than one result that matches equally.

Example

query = {
  'account_name'     => 'ey',
  'app_name'         => 'app',
  'environment_name' => 'resolver',
  'remotes' => ['[email protected]:engineyard/app-env-resolver.git']
}
results = EY::Resolver.awsm_resolver(query, current_user).app_environments
results   # An Array of AppEnvironment (AppDeployment) models that best match the query.