Sha256: 788cf7cbeda1d2603a30f77da23ef58cd2096bd85249d80c5b48aa21779c4eca

Contents?: true

Size: 1.01 KB

Versions: 35

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['target']
          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, @target]
            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

35 entries across 35 versions & 1 rubygems

Version Path
bolt-2.5.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.4.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.3.1 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.3.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.2.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.1.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.0.1 lib/bolt/pal/yaml_plan/step/script.rb
bolt-2.0.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-1.49.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-1.48.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-1.47.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-1.45.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-1.44.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-1.43.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-1.42.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-1.41.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-1.40.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-1.39.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-1.38.0 lib/bolt/pal/yaml_plan/step/script.rb
bolt-1.37.0 lib/bolt/pal/yaml_plan/step/script.rb