Class: R10K::Source::Git::BranchName Private

Inherits:
Object
  • Object
show all
Defined in:
lib/r10k/source/git.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.

Since:

  • 1.3.0

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.

Since:

  • 1.3.0

%r[\W]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, opts) ⇒ BranchName

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 BranchName.

Since:

  • 1.3.0



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/r10k/source/git.rb', line 145

def initialize(name, opts)
  @name = name
  @opts = opts

  @prefix = opts[:prefix]
  @sourcename = opts[:sourcename]
  @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

#nameObject (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.

Since:

  • 1.3.0



141
142
143
# File 'lib/r10k/source/git.rb', line 141

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.

Returns:

  • (Boolean)

Since:

  • 1.3.0



169
# File 'lib/r10k/source/git.rb', line 169

def correct?; @correct end

#dirnameObject

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.

Since:

  • 1.3.0



180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/r10k/source/git.rb', line 180

def dirname
  dir = @name.dup

  if @prefix
    dir = "#{@sourcename}_#{dir}"
  end

  if @correct
    dir.gsub!(INVALID_CHARACTERS, '_')
  end

  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.

Returns:

  • (Boolean)

Since:

  • 1.3.0



172
173
174
175
176
177
178
# File 'lib/r10k/source/git.rb', line 172

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.

Returns:

  • (Boolean)

Since:

  • 1.3.0



170
# File 'lib/r10k/source/git.rb', line 170

def validate?; @validate end