debian_codename 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/debian_codename.rb +32 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78b5e4e8d7b141d02e8986d7c7f6ced3a07a1c9dd8bd8f6fe75dcb96e892f74d
4
- data.tar.gz: c7cc6214ce8b243c32dfb2a1251b0a2497a03b754743858dee2271847cd69e37
3
+ metadata.gz: e20e9d4a61f0222b1c3a4550a5fc8f50af1ac73b446a2b0e20ffa96ab2377e00
4
+ data.tar.gz: dac229d1fccf6e6f63b11ea0fba3a2ada0d6eb1c3b41d90e5e24fa4fd1d00641
5
5
  SHA512:
6
- metadata.gz: d3dcb7ebd8093be1954581c4c1c261cc2f069f2f919faa92d401e26935f74125c24aa33d292c0eb9459bd1e30fe4d2dddfee48714c2fcad81324b44afd523152
7
- data.tar.gz: cbb9184b43e25989750f542692e027037ab087250b269e58d9825e6d6a98627ca9a133bef8ebc078ec91b9b4a9b70041cda66a68397f170b1c8116dfd9531269
6
+ metadata.gz: 0df33843a57febb6de376e308c068a8c54c5c6d27917b30f809d062fb6cee25944884037696b88acf6833af72f3f7afafd15ec42fdba2c1a927c0c7186232389
7
+ data.tar.gz: 1fa53b11dcf85c2c7fdc19b5caaf24e601403964db8b48db6831e8063e4e1b9ef5d0374fc5edfe954736b8b677a737562ae85286e796014e79e301f82d2f46b8
@@ -73,18 +73,45 @@ module DebianCodename
73
73
 
74
74
  module_function
75
75
 
76
- # Whether version number or codename is the user_search_string, return the matching
77
- # item.
76
+ # Convert from version string to codename and vice versa
78
77
  def fast_find(user_search_string)
79
78
  search_string = user_search_string.downcase
80
79
 
81
80
  [DEBIAN_CODENAMES, UBUNTU_CODENAMES].each do |code_catalog|
82
- return code_catalog[search_string][0] if code_catalog.key?(search_string)
81
+ return codename(code_catalog, search_string) if code_catalog.key?(search_string)
83
82
 
84
- key = code_catalog.find { |_key, value| value[0] == search_string }
85
- return key.first unless key.nil?
83
+ version_found = code_catalog.find { |_, value| value[0] == search_string }
84
+ return version_found.first unless version_found.nil?
86
85
  end
87
86
 
88
87
  raise DebianCodenameError, "No match for #{user_search_string}"
89
88
  end
89
+
90
+ # Return a canonical form (Hash with ':version' and ':codename' keys)
91
+ def find(user_search_string)
92
+ search_string = user_search_string.downcase
93
+
94
+ [DEBIAN_CODENAMES, UBUNTU_CODENAMES].each do |code_catalog|
95
+ if code_catalog.key?(search_string)
96
+ return {
97
+ version: search_string,
98
+ codename: codename(code_catalog, search_string)
99
+ }
100
+ end
101
+
102
+ version_found = code_catalog.find { |_, value| value[0] == search_string }
103
+ unless version_found.nil?
104
+ return {
105
+ version: version_found.first,
106
+ codename: search_string
107
+ }
108
+ end
109
+ end
110
+
111
+ raise DebianCodenameError, 'No match'
112
+ end
113
+
114
+ def codename(code_catalog, version_string)
115
+ code_catalog[version_string][0]
116
+ end
90
117
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debian_codename
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Release Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-05 00:00:00.000000000 Z
11
+ date: 2023-01-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Convert Debian/Ubuntu codenames to version numbers and vice-versa
14
14
  email: