Sha256: 2ee3b83d917509657635c046a0d1234d3874440e54ba525dc872e6e1fb7afc35

Contents?: true

Size: 1.01 KB

Versions: 43

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Bolt
  class PAL
    class YamlPlan
      class Step
        class Script < Step
          def self.allowed_keys
            super + Set['script', 'parameters', 'arguments']
          end

          def self.required_keys
            Set['targets']
          end

          def initialize(step_body)
            super
            @script = step_body['script']
            @parameters = step_body.fetch('parameters', {})
            @arguments = step_body.fetch('arguments', [])
          end

          def transpile
            code = String.new("  ")
            code << "$#{@name} = " if @name

            options = @parameters.dup
            options['arguments'] = @arguments unless @arguments.empty?

            fn = 'run_script'
            args = [@script, @targets]
            args << @description if @description
            args << options unless options.empty?

            code << function_call(fn, args)

            code << "\n"
          end
        end
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
bolt-3.1.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-3.0.1 lib/bolt/pal/yaml_plan/step/script.rb
bolt-3.0.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.44.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.42.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.40.2 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.40.1 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.38.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.37.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.36.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.35.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.34.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.33.2 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.33.1 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.32.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.31.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.30.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.29.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.28.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.27.0 lib/bolt/pal/yaml_plan/step/script.rb