gitlab-releases 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96b0b12edaa3ab669ff5b01e2a3ad8a699321aaec1fe1d8ba52be69db6de9e59
4
- data.tar.gz: b4e78d554defe39d5a06d4d10d92b4d48e55ef9371ffe7823a7090620a9f6a5f
3
+ metadata.gz: 1ee5944be724a7bf016c25ee0f56e31c4b270b8c812a9ce51abd87249aa4f587
4
+ data.tar.gz: 4c66c8ba98397bc550b4d0e80294805db8f15a8e97dfab6395de7c289a453ace
5
5
  SHA512:
6
- metadata.gz: 6e52f6976faa23b62f28edefe9fa660f138e7eb8bbd9e3b0b143152c1e727da934c73234ece5edf112151caf9020ae1da806fae5f5f64a5dbbe6a4f16fa9ca85
7
- data.tar.gz: 404e69849913a99274acbfc016af7f0f4beca48b5cd176f8bc9fd6d2d7c9fc7147c6fc3d1c542a5cc46ec5c63530bf467c4a2eae167b1fe4073347094ba4c5a7
6
+ metadata.gz: a01deb7460c318184f6f60c1ddfa63dd6cb69ea58055d3f30122701274ab3fa7d1fda235e84382be833a093e5fdecb951575cd29110f4113475179609be77fac
7
+ data.tar.gz: a91fad2b0ae7d3b341c3d536afa2ba05c095fbe9b4d6fc334f0a9aba839d03816e451016aebf7241841c04c8033fcd4f74d0307cf2e7676cc3cd4a68aa119eb7
data/CHANGELOG.md CHANGED
@@ -36,3 +36,7 @@
36
36
  ## [0.2.4] - 2023-11-03
37
37
 
38
38
  - Remove logic for static release date. All release dates will be calculated based on the third Thursday of the month.
39
+
40
+ ## [0.2.5] - 2023-11-23
41
+
42
+ - Add methods to calculate the current version of a given date (`#current_minor_for_date`) and the previous minors for a specific version (`#previous_minors`)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab-releases (0.2.3)
4
+ gitlab-releases (0.2.4)
5
5
  activesupport (~> 7.1)
6
6
  gitlab (~> 4.19.0)
7
7
  http (~> 5.1.0)
data/README.md CHANGED
@@ -12,7 +12,7 @@ Library to interact with GitLab releases and versions. The information is fetche
12
12
  Gemfile:
13
13
 
14
14
  ```
15
- gem 'gitlab-releases', '~> 0.2.4'
15
+ gem 'gitlab-releases', '~> 0.2.5'
16
16
  ```
17
17
 
18
18
  Install:
@@ -36,6 +36,9 @@ There are different methods available:
36
36
  * `current_version` - Returns the current GitLab minor version.
37
37
  * `next_versions` - Returns the next GitLab patch versions (for patch and security releases).
38
38
  * `previous_version` - Returns the return the latest patch of the previous minor version.
39
+ * `version_for_date` - Returns the active GitLab version for the given date
40
+ * `current_minor_for_date` - Returns the current GitLab minor for the given date
41
+ * `previous_minors` - Returns the previous minors for the given version
39
42
 
40
43
  To make use of it:
41
44
 
@@ -69,6 +72,12 @@ To make use of it:
69
72
  => ["16.5.2", "16.4.3", "16.3.7"]
70
73
  > GitlabReleases.previous_version
71
74
  => "16.4.2"
75
+ > GitlabReleases.version_for_date('2023-11-23')
76
+ => "16.7"
77
+ > GitlabReleases.current_minor_for_date('2023-11-23')
78
+ => "16.6"
79
+ > GitlabReleases.previous_minors
80
+ => ["16.6", "16.5", "16.4"]
72
81
  ```
73
82
 
74
83
  ## Contributing
@@ -75,8 +75,8 @@ class ReleaseVersions
75
75
 
76
76
  # Returns the scheduled major.minor for the given date
77
77
  def self.version_for_date(date)
78
- # Returns the release associated with the date by calling `releases_yaml` and fetching the
79
- # release whose date is greater than the given date.
78
+ # Returns the active release associated with the date by calling `releases_yaml` and fetching the
79
+ # release whose date is greater or equal than the given date.
80
80
  #
81
81
  # For example:
82
82
  #
@@ -99,6 +99,34 @@ class ReleaseVersions
99
99
  ReleaseVersion.new(row['version'])
100
100
  end
101
101
 
102
+ # Returns the current major.minor for the given date
103
+ def self.current_minor_for_date(date)
104
+ # Returns the current version associated with the date by calling `releases_yaml`
105
+ # and fetching the version whose release date is less or equal to the given date.
106
+ #
107
+ # For example:
108
+ #
109
+ # | Version | Date |
110
+ # |:--------|:---------------|
111
+ # | 16.3 | August 22nd |
112
+ # | 16.4 | September 22nd |
113
+ # | 16.5 | October 22nd |
114
+ # | 16.6 | November 16th |
115
+ # | 16.7 | December 21st |
116
+ #
117
+ # * For August 21st, the release should be 16.2
118
+ # * For August 22nd, the release should be 16.3
119
+ # * For August 23rd, the release should be 16.3
120
+ # * For November 17th, the release should be 16.6
121
+ return nil if releases_yaml.empty?
122
+
123
+ row = releases_yaml
124
+ .reverse
125
+ .detect { |release| date.to_date >= release['date'] }
126
+
127
+ ReleaseVersion.new(row['version'])
128
+ end
129
+
102
130
  # Returns the last patch of the previous minor version
103
131
  #
104
132
  # For example, if the current version is 16.4, then
@@ -114,6 +142,19 @@ class ReleaseVersions
114
142
  ::VersionSorter.sort(versions).uniq
115
143
  end
116
144
 
145
+ # Returns the previous major.minor versions of the major.minor version based on the
146
+ # releases.yml data
147
+ #
148
+ # For example:
149
+ # - If the current version is 16.7, the previous patch versions are 16.7, 16.6, and 16.5
150
+ # - If the current version is 17.1, the previous patch versions are 17.1, 16.11, and 16.10
151
+ def self.previous_minors(version)
152
+ versions = releases_yaml.map { |release| release['version'] }
153
+ .reverse
154
+
155
+ versions[versions.index(version), 3]
156
+ end
157
+
117
158
  def self.raw_versions
118
159
  ReleaseVersionClient.versions
119
160
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitlabReleases
4
- VERSION = "0.2.4"
4
+ VERSION = "0.2.5"
5
5
  end
@@ -33,6 +33,14 @@ module GitlabReleases
33
33
  ReleaseVersions.previous_version
34
34
  end
35
35
 
36
+ def self.current_minor_for_date(date)
37
+ ReleaseVersions.current_minor_for_date(date)
38
+ end
39
+
40
+ def self.previous_minors(version)
41
+ ReleaseVersions.previous_minors(version)
42
+ end
43
+
36
44
  def self.release_date
37
45
  ReleaseVersions.previous_release_date
38
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-releases
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mayra Cabrera
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-03 00:00:00.000000000 Z
11
+ date: 2023-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport