Module: Packer::Binary
- Defined in:
- lib/packer/binary.rb,
lib/packer/binary/command.rb,
lib/packer/binary/helpers.rb,
lib/packer/binary/version.rb,
lib/packer/binary/compressor.rb,
lib/packer/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
'0.2.3'.freeze
- PACKER_VERSION =
The version number of the Packer binary to download and use
'1.0.4'.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 Packer::Binary method calls to Packer sub-commands Ex.
- .respond_to_missing?(method) ⇒ Boolean
-
.Version ⇒ Object
deprecated
Deprecated.
Use #method_missing dynamic method handling for binary sub-commands
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 Packer::Binary::Command::CommandFailure exception
This method maps Packer::Binary method calls to Packer sub-commands
Ex. to run packer build test.json -machine-readable
:
Packer::Binary.build('test.json -machine-readable')
42 43 44 45 46 47 48 49 |
# File 'lib/packer/binary.rb', line 42 def method_missing(method, *args, &block) if method.to_s =~ /(\w+)/ Packer::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/packer/binary.rb', line 18 attr_writer :config |
Class Method Details
.config ⇒ Object
defines the @config class variable
23 24 25 |
# File 'lib/packer/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/packer/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 Packer::Binary::Command::CommandFailure exception
This method maps Packer::Binary method calls to Packer sub-commands
Ex. to run packer build test.json -machine-readable
:
Packer::Binary.build('test.json -machine-readable')
42 43 44 45 46 47 48 49 |
# File 'lib/packer/binary.rb', line 42 def method_missing(method, *args, &block) if method.to_s =~ /(\w+)/ Packer::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/packer/binary.rb', line 51 def respond_to_missing?(method, *) method =~ /(\w+)/ || super end |