Class: R10K::Environment::Name Private
- Inherits:
-
Object
- Object
- R10K::Environment::Name
- Defined in:
- lib/r10k/environment/name.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Handle environment name validation and modification.
Constant Summary collapse
- INVALID_CHARACTERS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%r[\W]
Instance Attribute Summary collapse
- #name ⇒ Object readonly private
Instance Method Summary collapse
-
#correct? ⇒ Boolean
private
Should the environment name have invalid characters removed?.
-
#dirname ⇒ String
private
The directory name for the environment, modified as necessary to remove invalid characters.
-
#initialize(name, opts) ⇒ Name
constructor
private
A new instance of Name.
- #valid? ⇒ Boolean private
- #validate? ⇒ Boolean private
Constructor Details
#initialize(name, opts) ⇒ Name
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Name.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/r10k/environment/name.rb', line 14 def initialize(name, opts) @name = name @opts = opts @source = opts[:source] @prefix = opts[:prefix] @invalid = opts[:invalid] case @invalid when 'correct_and_warn' @validate = true @correct = true when 'correct' @validate = false @correct = true when 'error' @validate = true @correct = false when NilClass @validate = opts[:validate] @correct = opts[:correct] end end |
Instance Attribute Details
#name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/r10k/environment/name.rb', line 10 def name @name end |
Instance Method Details
#correct? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Should the environment name have invalid characters removed?
39 40 41 |
# File 'lib/r10k/environment/name.rb', line 39 def correct? @correct end |
#dirname ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The directory name for the environment, modified as necessary to remove invalid characters.
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/r10k/environment/name.rb', line 59 def dirname dir = @name.dup prefix = derive_prefix(@source,@prefix) if @correct dir.gsub!(INVALID_CHARACTERS, '_') end "#{prefix}#{dir}" end |
#valid? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 50 51 52 53 |
# File 'lib/r10k/environment/name.rb', line 47 def valid? if @validate ! @name.match(INVALID_CHARACTERS) else true end end |
#validate? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 |
# File 'lib/r10k/environment/name.rb', line 43 def validate? @validate end |