Sha256: 0fbc49da7e217c7d139450bed8d8a5315c28b5d5d75d7999e5eeaf6cc0ecd378

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 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}"] = 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

8 entries across 8 versions & 1 rubygems

Version Path
inferno_core-0.6.1 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.6.0 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.5.4 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.5.3 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.5.2 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.5.1 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.5.0 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.44 lib/inferno/utils/preset_template_generator.rb