Class: KCommercial::KCPipeline::ReleaseBranch

Inherits:
Object
  • Object
show all
Defined in:
lib/KCommercialPipeline/core/version_pipeline/release_branches.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ReleaseBranch

Returns a new instance of ReleaseBranch.



146
147
148
149
# File 'lib/KCommercialPipeline/core/version_pipeline/release_branches.rb', line 146

def initialize(name)
   @name = name
   init_version
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



145
146
147
# File 'lib/KCommercialPipeline/core/version_pipeline/release_branches.rb', line 145

def code
  @code
end

#is_releaseObject (readonly)

Returns the value of attribute is_release.



144
145
146
# File 'lib/KCommercialPipeline/core/version_pipeline/release_branches.rb', line 144

def is_release
  @is_release
end

#majorObject (readonly)

Returns the value of attribute major.



141
142
143
# File 'lib/KCommercialPipeline/core/version_pipeline/release_branches.rb', line 141

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



142
143
144
# File 'lib/KCommercialPipeline/core/version_pipeline/release_branches.rb', line 142

def minor
  @minor
end

#nameObject

拉分支名



140
141
142
# File 'lib/KCommercialPipeline/core/version_pipeline/release_branches.rb', line 140

def name
  @name
end

#patchObject (readonly)

Returns the value of attribute patch.



143
144
145
# File 'lib/KCommercialPipeline/core/version_pipeline/release_branches.rb', line 143

def patch
  @patch
end

#versionObject (readonly)

Returns the value of attribute version.



138
139
140
# File 'lib/KCommercialPipeline/core/version_pipeline/release_branches.rb', line 138

def version
  @version
end

Instance Method Details

#init_versionObject



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/KCommercialPipeline/core/version_pipeline/release_branches.rb', line 151

def init_version
   reg = /#{KimConfig.configs["common_regulars"]["release_branch_regular"]}/
   reg = Regexp.new('^(origin/)?release/RB_\d(\.\d+)+$') unless reg
   unless @name.empty?
      match_data = reg.match(@name)
      if match_data.nil?
         @is_release = false
         @code = 0
         return
      end
      @is_release = true

      version = match_data.to_s.match(/\d+(.\d+)+/).to_s
      numers = version.split(".")
      if numers.length > 1
         @major = numers[0]
         @minor = numers[1]
      end

      if numers.length > 2
         @patch = numers[2] || 0
      end
      @code = @major.to_i * 1000000 + @minor.to_i * 1000+ @patch.to_i
   else
      @is_release = false
      @code = 0
   end
end