lib/helpers/string.rb in overview-0.0.4.17 vs lib/helpers/string.rb in overview-0.0.5.pre.22

- old
+ new

@@ -1,10 +1,19 @@ class String def increment_version - short_version_parts = self.split('.') - last_digit = short_version_parts.last.to_i + 1 + array = self.split('.') + digits = 0 + index_of_last_digit = 0 + array.each_with_index {|x, i| + if x.is_number? then + digits += 1 + index_of_last_digit = i + end + break if (digits==3 || i==array.count-1) && x.is_number? + } + array[index_of_last_digit] = (array[index_of_last_digit].to_i + 1).to_s $stdout.puts 'Incrementing version...' - "#{short_version_parts.first(short_version_parts.length-1).join(".")}.#{last_digit}" + array.join('.') end def increment_version! replace increment_version end def is_number? \ No newline at end of file