Sha256: cfd69d279d1775f1f5e67b074e37b7a3741fbda7bdcb5cb3e8814114e4996acf

Contents?: true

Size: 911 Bytes

Versions: 13

Compression:

Stored size: 911 Bytes

Contents

require 'lino'

module RubyTerraform
  module Commands
    class Base
      attr_reader :binary

      def initialize(binary: nil)
        @binary = binary || RubyTerraform.configuration.binary
      end

      def stdin
        ''
      end

      def stdout
        STDOUT
      end

      def stderr
        STDERR
      end

      def execute(opts = {})
        builder = instantiate_builder

        do_before(opts)
        configure_command(builder, opts)
          .build
          .execute(
              stdin: stdin,
              stdout: stdout,
              stderr: stderr)
        do_after(opts)
      end

      def instantiate_builder
        Lino::CommandLineBuilder
            .for_command(binary)
            .with_option_separator('=')
      end

      def do_before(opts)
      end

      def configure_command(builder, opts)
      end

      def do_after(opts)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ruby-terraform-0.12.0 lib/ruby_terraform/commands/base.rb
ruby-terraform-0.11.2 lib/ruby_terraform/commands/base.rb
ruby-terraform-0.11.0 lib/ruby_terraform/commands/base.rb
ruby-terraform-0.10.0 lib/ruby_terraform/commands/base.rb
ruby-terraform-0.9.0 lib/ruby_terraform/commands/base.rb
ruby-terraform-0.8.0 lib/ruby_terraform/commands/base.rb
ruby-terraform-0.7.0 lib/ruby_terraform/commands/base.rb
ruby-terraform-0.6.0 lib/ruby_terraform/commands/base.rb
ruby-terraform-0.5.1 lib/ruby_terraform/commands/base.rb
ruby-terraform-0.5.0 lib/ruby_terraform/commands/base.rb
ruby-terraform-0.4.0 lib/ruby_terraform/commands/base.rb
ruby-terraform-0.3.0 lib/ruby_terraform/commands/base.rb
ruby-terraform-0.2.0 lib/ruby_terraform/commands/base.rb