Module: Terraform::Binary
- Defined in:
- lib/terraform/binary.rb,
lib/terraform/binary/command.rb,
lib/terraform/binary/helpers.rb,
lib/terraform/binary/version.rb,
lib/terraform/binary/compressor.rb,
lib/terraform/binary/executable.rb
Overview
The Binary namespace handles sub-commands using #method_missing metaprogramming as well as the global configuration object
Defined Under Namespace
Modules: Command, Helpers Classes: Compressor, Configuration, Executable
Constant Summary collapse
- VERSION =
Gem Version
'1.0.1'.freeze
- TERRAFORM_VERSION =
The version number of the Terraform binary to download and use
'1.1.2'.freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
writeonly
Sets the attribute config.
Class Method Summary collapse
-
.config ⇒ Object
defines the @config class variable.
-
.configure {|config| ... } ⇒ Object
Set the global settings.
-
.method_missing(method, *args, &block) ⇒ Object
This method maps Terraform::Binary method calls to Terraform sub-commands Ex.
- .respond_to_missing?(method) ⇒ Boolean
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
if the method is an invalid sub-command or if the command fails you will get a Terraform::Binary::Command::CommandFailure exception
This method maps Terraform::Binary method calls to Terraform sub-commands
Ex. to run terraform plan -machine-readable test/dir
:
Terraform::Binary.plan('-machine-readable test/dir')
42 43 44 45 46 47 48 49 |
# File 'lib/terraform/binary.rb', line 42 def method_missing(method, *args, &block) if method.to_s =~ /(\w+)/ Terraform::Binary::Helpers.debug("#{method.to_s.downcase} #{args.join(' ')}") Command.run("#{method.to_s.downcase} #{args.join(' ')}") else super end end |
Instance Attribute Details
#config=(value) ⇒ Object
Sets the attribute config
18 |
# File 'lib/terraform/binary.rb', line 18 attr_writer :config |
Class Method Details
.config ⇒ Object
defines the @config class variable
23 24 25 |
# File 'lib/terraform/binary.rb', line 23 def config @config ||= Configuration.new end |
.configure {|config| ... } ⇒ Object
Set the global settings. See the README for more information
28 29 30 |
# File 'lib/terraform/binary.rb', line 28 def configure yield(config) end |
.method_missing(method, *args, &block) ⇒ Object
if the method is an invalid sub-command or if the command fails you will get a Terraform::Binary::Command::CommandFailure exception
This method maps Terraform::Binary method calls to Terraform sub-commands
Ex. to run terraform plan -machine-readable test/dir
:
Terraform::Binary.plan('-machine-readable test/dir')
42 43 44 45 46 47 48 49 |
# File 'lib/terraform/binary.rb', line 42 def method_missing(method, *args, &block) if method.to_s =~ /(\w+)/ Terraform::Binary::Helpers.debug("#{method.to_s.downcase} #{args.join(' ')}") Command.run("#{method.to_s.downcase} #{args.join(' ')}") else super end end |
.respond_to_missing?(method) ⇒ Boolean
51 52 53 |
# File 'lib/terraform/binary.rb', line 51 def respond_to_missing?(method, *) method =~ /(\w+)/ || super end |