Sha256: 62a95428f6df619043696a4a2a5ff979c6eee2bf72cd72235dfc264abab891e1

Contents?: true

Size: 1.07 KB

Versions: 34

Compression:

Stored size: 1.07 KB

Contents

module Inferno
  module Utils
    class PresetTemplateGenerator
      attr_accessor :runnable

      def initialize(runnable)
        self.runnable = runnable
      end

      def available_inputs
        @available_inputs ||= runnable.available_inputs.transform_values(&:to_hash)
      end

      def inputs
        # The rubocop rule is disabled because `each_value` returns the hash,
        # while `values.each` will return the array of values. We want the array
        # of values here.
        available_inputs.values.map do |original_input|
          {}.tap do |input|
            input[:name] = original_input.delete(:name)
            input[:value] = (original_input.delete(:default) if original_input.key? :default)
            original_input.each { |key, value| input["_#{key}".to_sym] = value }
          end
        end
      end

      def metadata
        {
          title: "Preset for #{runnable.title}",
          id: nil
        }.merge(runnable.reference_hash)
      end

      def generate
        metadata.merge(
          inputs:
        )
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
inferno_core-0.4.43 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.42 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.41 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.40 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.39 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.38 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.35 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.34 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.33 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.32 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.31 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.30 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.29 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.28 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.27 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.26 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.25 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.24 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.23 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.22 lib/inferno/utils/preset_template_generator.rb