Sha256: dbb26fa1415ea6fb6720326a400086e15c0ce2c95ad43eb863924b90a099449f

Contents?: true

Size: 907 Bytes

Versions: 71

Compression:

Stored size: 907 Bytes

Contents

module HammerCLIForeman


  class DependencyResolver

    def action_dependencies(action, options={})
      options[:only_required] = (options[:only_required] == true)
      options[:recursive] = !(options[:recursive] == false)

      resolve_for_action(action, [], options)
    end

    def resource_dependencies(resource, options={})
      action_dependencies(resource.action(:index), options)
    end

    protected

    def resolve_for_action(action, resources_found, options)
      IdParamsFilter.new(:only_required => options[:only_required]).for_action(action).each do |param|
        res = HammerCLIForeman.param_to_resource(param.name)
        if res and !resources_found.map(&:name).include?(res.name)
          resources_found << res
          resolve_for_action(res.action(:index), resources_found, options) if options[:recursive]
        end
      end
      resources_found
    end

  end

end

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
hammer_cli_foreman-3.13.0 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-3.12.0 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-3.10.0 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-3.9.0 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-3.8.0 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-3.7.0 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-3.5.1 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-3.6.0 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-3.5.0 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-3.4.0 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-3.3.0 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-3.2.0 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-2.5.2 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-3.1.0 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-3.0.0 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-2.5.1 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-2.5.0 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-2.3.2 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-2.4.0 lib/hammer_cli_foreman/dependency_resolver.rb
hammer_cli_foreman-2.3.1 lib/hammer_cli_foreman/dependency_resolver.rb