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.1'.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')
41 42 43 44 45 46 47 48 |
# File 'lib/packer/binary.rb', line 41 def method_missing(method, *args, &block) if method.to_s =~ /(\w+)/ puts "#{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
17 |
# File 'lib/packer/binary.rb', line 17 attr_writer :config |
Class Method Details
.config ⇒ Object
defines the @config class variable
22 23 24 |
# File 'lib/packer/binary.rb', line 22 def config @config ||= Configuration.new end |
.configure {|config| ... } ⇒ Object
Set the global settings. See the README for more information
27 28 29 |
# File 'lib/packer/binary.rb', line 27 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')
41 42 43 44 45 46 47 48 |
# File 'lib/packer/binary.rb', line 41 def method_missing(method, *args, &block) if method.to_s =~ /(\w+)/ puts "#{method.to_s.downcase} #{args.join(' ')}" Command.run("#{method.to_s.downcase} #{args.join(' ')}") else super end end |
.respond_to_missing?(method) ⇒ Boolean
50 51 52 |
# File 'lib/packer/binary.rb', line 50 def respond_to_missing?(method, *) method =~ /(\w+)/ || super end |