Class: VagrantPlugins::DevCommands::Registry
- Inherits:
-
Object
- Object
- VagrantPlugins::DevCommands::Registry
- Defined in:
- lib/vagrant/devcommands/registry.rb,
lib/vagrant/devcommands/registry/messager.rb,
lib/vagrant/devcommands/registry/resolver.rb,
lib/vagrant/devcommands/registry/validator.rb
Overview
Registry for definitions from the Commandfile
Defined Under Namespace
Classes: Messager, Resolver, Validator
Constant Summary collapse
- RESERVED_COMMANDS =
%w[completion-data help version].freeze
Instance Attribute Summary collapse
-
#chains ⇒ Object
Returns the value of attribute chains.
-
#command_aliases ⇒ Object
Returns the value of attribute command_aliases.
-
#commands ⇒ Object
Returns the value of attribute commands.
Instance Method Summary collapse
- #available?(name) ⇒ Boolean
-
#initialize(env) ⇒ Registry
constructor
A new instance of Registry.
- #read_commandfile(commandfile) ⇒ Object
- #reserved_command?(command) ⇒ Boolean
- #valid_chain?(chain) ⇒ Boolean
- #valid_command?(command) ⇒ Boolean
- #valid_command_alias?(name) ⇒ Boolean
Constructor Details
#initialize(env) ⇒ Registry
Returns a new instance of Registry.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/vagrant/devcommands/registry.rb', line 11 def initialize(env) @env = env = Registry::Messager.new(@env) @chains = {} @commands = {} @command_aliases = {} @duplicates = { 'chains' => [], 'commands' => [], 'command_aliases' => [] } end |
Instance Attribute Details
#chains ⇒ Object
Returns the value of attribute chains.
9 10 11 |
# File 'lib/vagrant/devcommands/registry.rb', line 9 def chains @chains end |
#command_aliases ⇒ Object
Returns the value of attribute command_aliases.
9 10 11 |
# File 'lib/vagrant/devcommands/registry.rb', line 9 def command_aliases @command_aliases end |
#commands ⇒ Object
Returns the value of attribute commands.
9 10 11 |
# File 'lib/vagrant/devcommands/registry.rb', line 9 def commands @commands end |
Instance Method Details
#available?(name) ⇒ Boolean
26 27 28 |
# File 'lib/vagrant/devcommands/registry.rb', line 26 def available?(name) valid_chain?(name) || valid_command?(name) || valid_command_alias?(name) end |
#read_commandfile(commandfile) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/vagrant/devcommands/registry.rb', line 30 def read_commandfile(commandfile) register(Commandfile::Reader.new(commandfile, @env).read) Registry::Resolver.new().resolve_naming_conflicts(self) Registry::Validator.new().validate_entries(self) end |
#reserved_command?(command) ⇒ Boolean
37 38 39 |
# File 'lib/vagrant/devcommands/registry.rb', line 37 def reserved_command?(command) RESERVED_COMMANDS.include?(command) end |
#valid_chain?(chain) ⇒ Boolean
41 42 43 |
# File 'lib/vagrant/devcommands/registry.rb', line 41 def valid_chain?(chain) @chains.include?(chain) end |
#valid_command?(command) ⇒ Boolean
45 46 47 |
# File 'lib/vagrant/devcommands/registry.rb', line 45 def valid_command?(command) @commands.include?(command) || reserved_command?(command) end |
#valid_command_alias?(name) ⇒ Boolean
49 50 51 |
# File 'lib/vagrant/devcommands/registry.rb', line 49 def valid_command_alias?(name) @command_aliases.include?(name) end |