Skip to content

Commit 1f28420

Browse files
committed
feat: add Distro::Ubuntu module, add is_lts?
Update name Add license Fix README part
1 parent 2044a2b commit 1f28420

File tree

9 files changed

+455
-10
lines changed

9 files changed

+455
-10
lines changed

LICENSE

+373
Large diffs are not rendered by default.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ Build workflow for rootfs images, Ubuntu openSUSE and more
88

99
Install the gem and add to the application's Gemfile by executing:
1010

11-
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
11+
$ bundle add rootfs
1212

1313
If bundler is not being used to manage dependencies, install the gem by executing:
1414

15-
$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
15+
$ gem install rootfs
1616

1717
## Usage
1818

lib/rootfs.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# frozen_string_literal: true
22

33
require_relative "rootfs/version"
4+
require_relative "rootfs/distro/ubuntu"
45

5-
module Rootfs
6-
class Error < StandardError; end
7-
# Your code goes here...
6+
module RootFS
7+
extend RootFS::Distro::Ubuntu
88
end

lib/rootfs/distro/ubuntu.rb

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# frozen_string_literal: true
2+
3+
module RootFS
4+
module Distro
5+
module Ubuntu
6+
# https://ubuntu.com/download
7+
8+
# https://wiki.ubuntu.com/Releases
9+
# https://cloud-images.ubuntu.com/
10+
CODENAME_VERSION = {
11+
lunar: "23.04",
12+
kinetic: "22.10",
13+
jammy: "22.04",
14+
focal: "20.04",
15+
bionic: "18.04",
16+
xenial: "16.04",
17+
trusty: "14.04"
18+
}
19+
20+
LTS = {
21+
jammy: "22.04",
22+
focal: "20.04",
23+
bionic: "18.04",
24+
xenial: "16.04",
25+
trusty: "14.04"
26+
}
27+
28+
EDITION_RELEASE_URL = {
29+
Desktop: "http://cdimage.ubuntu.com/releases/",
30+
Server: "http://cdimage.ubuntu.com/releases/",
31+
Base: "http://cdimage.ubuntu.com/ubuntu-base/releases/",
32+
Cloud: "https://cloud-images.ubuntu.com/releases/",
33+
Minimal: "https://cloud-images.ubuntu.com/minimal/releases/"
34+
}
35+
36+
EDITION_DAILY_URL = {
37+
Desktop: "http://cdimage.ubuntu.com/",
38+
Server: "http://cdimage.ubuntu.com/ubuntu-server/",
39+
Base: "http://cdimage.ubuntu.com/ubuntu-base/",
40+
Cloud: "https://cloud-images.ubuntu.com/",
41+
Minimal: "https://cloud-images.ubuntu.com/minimal/daily/"
42+
}
43+
44+
def is_lts?(any)
45+
str = any.to_s
46+
LTS.each do |code, ver|
47+
return true if str == code.to_s
48+
return true if str.start_with?(ver)
49+
end
50+
false
51+
end
52+
end
53+
end
54+
end

lib/rootfs/distro/ubuntu_test.rb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "ubuntu"
4+
5+
class MyClass
6+
include RootFS::Distro::Ubuntu
7+
end
8+
9+
u = MyClass.new
10+
11+
p u.is_lts?("20.04.5")

lib/rootfs/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

3-
module Rootfs
3+
module RootFS
44
VERSION = "0.0.1.pre"
55
end

rootfs.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ require_relative "lib/rootfs/version"
44

55
Gem::Specification.new do |spec|
66
spec.name = "rootfs"
7-
spec.version = Rootfs::VERSION
7+
spec.version = RootFS::VERSION
88
spec.authors = ["initdc"]
99
spec.email = ["[email protected]"]
1010

spec/distro/ubuntu_spec.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe RootFS do
4+
it "does something useful" do
5+
expect(RootFS.is_lts?(20.04)).to eq(true)
6+
end
7+
end

spec/rootfs_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# frozen_string_literal: true
22

3-
RSpec.describe Rootfs do
3+
RSpec.describe RootFS do
44
it "has a version number" do
5-
expect(Rootfs::VERSION).not_to be nil
5+
expect(RootFS::VERSION).not_to be nil
66
end
77

88
it "does something useful" do
9-
expect(false).to eq(true)
9+
expect(true).to eq(true)
1010
end
1111
end

0 commit comments

Comments
 (0)