Sha256: fb06c78466c4217e5cdc5ef7e51ed5fb88717b24dd62d73ee173691f849361da

Contents?: true

Size: 1.04 KB

Versions: 22

Compression:

Stored size: 1.04 KB

Contents

module Kuroko2
  module Workflow
    module Task
      class Env < Base

        def execute
          if option
            env = token.context['ENV'] || {}
            env.merge!(parse_option(option))

            token.context['ENV'] = env
          end

          :next
        end

        def validate
          parse_option(option)
        end

        private
        def parse_option(option)
          env = {}

          scanner = StringScanner.new(option)
          until scanner.eos?
            case
            when scanner.scan(/(\w+)="((?:\\"|.)*?)"/)
              env[scanner[1]] = scanner[2].gsub(/\\"/, '"')
            when scanner.scan(/(\w+)='((?:\\'|.)*?)'/)
              env[scanner[1]] = scanner[2].gsub(/\\'/, "'")
            when scanner.scan(/(\w+)=(\S+)/)
              env[scanner[1]] = scanner[2]
            when scanner.scan(/\s+/)
            else
              raise Workflow::AssertionError, "Syntax error option value of env: #{option}"
            end
          end

          env
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
kuroko2-0.8.0 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.7.0 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.6.0 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.5.2 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.5.1 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.5.0 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.4.6 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.4.5 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.4.4 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.4.3 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.4.2 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.4.1 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.4.0 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.3.4 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.3.3 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.3.2 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.3.1 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.3.0 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.2.3 lib/autoload/kuroko2/workflow/task/env.rb
kuroko2-0.2.2 lib/autoload/kuroko2/workflow/task/env.rb