bake-gem 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 307b46bb648004706745207f0c6d53fcd1a30b8c2bfed945b57f23a2d65685d8
4
- data.tar.gz: 3ed9dee4422cf593efe9ca45a92b1db0e55f2cf4d863f8e38d1b46fa5ce7b2cc
3
+ metadata.gz: 436620eb899794e3709390307a7d665798d1808b2cdded1a151c005db9c3f55d
4
+ data.tar.gz: c438bf0f5436b9eb5935661d8d9b4b4241050f7d5dfd4f0da086a4fe9ff48e04
5
5
  SHA512:
6
- metadata.gz: 3984cc693ce4a547ab0c880a396738b5c9f74c16bf604b8c56494ad7aafe9d68f8b2468a52c52d816532c290a6828b4236a0274f535842850ecf38d7f166cc7a
7
- data.tar.gz: dffb5ba0adff68a801aa29a0cb76275cee66d3218227e2333ffc2dae98da546a86faef310ba11b0045dd447a4bbb08fc7ad53711ff036e6948d9b424fb1756f5
6
+ metadata.gz: 3bb4833a86116ebdcfb5949f5d8960473ded2595ad0fbd3d533988a79fb8158535c43ffeeb1755e5ac657a2f884f863f99c3d4dca562a2efc2f2c8b53abe8735
7
+ data.tar.gz: 5821fefb80eac7a536e54c0f4df700ff0d800938bd72e4ad4c364f1262878247a68922ae70474bfc57a44821efad2ae7cf394ae19abef5fe12d0a9038887f2dd
checksums.yaml.gz.sig CHANGED
Binary file
@@ -32,12 +32,10 @@ def increment(bump, message: "Bump version.")
32
32
  gemspec = helper.gemspec
33
33
 
34
34
  helper.update_version(bump) do |version|
35
- version_string = version.join('.')
36
-
37
- Console.logger.info(self) {"Updated version to #{version_string}"}
35
+ Console.logger.info(self) {"Updated version: #{version}"}
38
36
 
39
37
  # Ensure that any subsequent tasks use the correct version!
40
- gemspec.version = ::Gem::Version.new(version_string)
38
+ gemspec.version = version.join
41
39
 
42
40
  after_increment(version)
43
41
  end
@@ -11,6 +11,64 @@ require_relative 'shell'
11
11
 
12
12
  module Bake
13
13
  module Gem
14
+ class Version
15
+ LINE_PATTERN = /VERSION = ['"](?<version>(?<parts>\d+\.\d+\.\d+)(-(?<suffix>.*?))?)['"]/
16
+
17
+ # If the line contains a version constant, update it using the provided block.
18
+ def self.update_version(line)
19
+ if match = line.match(LINE_PATTERN)
20
+ parts = match[:parts].split(/\./).map(&:to_i)
21
+ suffix = match[:suffix]
22
+
23
+ version = self.new(parts, suffix)
24
+
25
+ yield version
26
+
27
+ line.sub!(match[:version], version.join)
28
+ end
29
+ end
30
+
31
+ def initialize(parts, suffix)
32
+ @parts = parts
33
+ @suffix = suffix
34
+ end
35
+
36
+ def release?
37
+ @suffix.nil?
38
+ end
39
+
40
+ # Join all parts together to form a version string.
41
+ def join
42
+ if @suffix
43
+ return "#{@parts.join('.')}-#{@suffix}"
44
+ else
45
+ return @parts.join('.')
46
+ end
47
+ end
48
+
49
+ # The version string with a "v" prefix.
50
+ def to_s
51
+ "v#{join}"
52
+ end
53
+
54
+ def increment(bump)
55
+ bump.each_with_index do |increment, index|
56
+ if index > @parts.size
57
+ @suffix = bump[index..-1].join('.')
58
+ break
59
+ end
60
+
61
+ if increment == 1
62
+ @parts[index] += 1
63
+ elsif increment == 0
64
+ @parts[index] = 0
65
+ end
66
+ end
67
+
68
+ return self
69
+ end
70
+ end
71
+
14
72
  class Helper
15
73
  include Shell
16
74
 
@@ -26,36 +84,25 @@ module Bake
26
84
  @gemspec&.files.grep(/lib(.*?)\/version.rb/).first
27
85
  end
28
86
 
29
- VERSION_PATTERN = /VERSION = ['"](?<value>\d+\.\d+\.\d+)(?<pre>.*?)['"]/
30
-
31
87
  def update_version(bump, version_path = self.version_path)
32
88
  return false unless version_path
33
89
 
34
90
  lines = File.readlines(version_path)
35
- version = nil
91
+ new_version = nil
36
92
 
37
93
  lines.each do |line|
38
- if match = line.match(VERSION_PATTERN)
39
- version = match[:value].split(/\./).map(&:to_i)
40
- bump.each_with_index do |increment, index|
41
- if increment == 1
42
- version[index] += 1
43
- elsif increment == 0
44
- version[index] = 0
45
- end
46
- end
47
-
48
- line.sub!(match[:value], version.join('.'))
94
+ Version.update_version(line) do |version|
95
+ new_version = version.increment(bump)
49
96
  end
50
97
  end
51
98
 
52
- if version
99
+ if new_version
100
+ File.write(version_path, lines.join)
101
+
53
102
  if block_given?
54
- yield version
103
+ yield new_version
55
104
  end
56
105
 
57
- File.write(version_path, lines.join)
58
-
59
106
  return version_path
60
107
  end
61
108
  end
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Bake
7
7
  module Gem
8
- VERSION = "0.9.0"
8
+ VERSION = "0.10.0"
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bake-gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -37,7 +37,7 @@ cert_chain:
37
37
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
38
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
39
  -----END CERTIFICATE-----
40
- date: 2024-08-22 00:00:00.000000000 Z
40
+ date: 2024-08-23 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: console
metadata.gz.sig CHANGED
Binary file