linux-lxc 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/linux/lxc/line.rb +2 -1
- data/lib/linux/lxc/lines.rb +4 -0
- data/lib/linux/lxc/version.rb +1 -1
- data/lib/linux/lxc.rb +17 -1
- data/test/linux_lxc_test.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c561e17dc08b0113ac3e405952735e7e525ed368
|
4
|
+
data.tar.gz: f26d4595440b473efa4a1e3f22c0d3cf6afcdf68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e48d4c369c63a3a4f208208bb904b7d2af9fc09dcddef6af904d20fa6e982df3b1f65907780c21faeae18332399596aee1384e961ab8368446666778c346057
|
7
|
+
data.tar.gz: c6db6179afede394feaa37c85bbac3bb253c0badd7a10b05d4fd68b01c3db92e703d1cf851a1d63b3e94c9cd36ac00965b410a21ce16577c8c6c21fa65d655de
|
data/lib/linux/lxc/line.rb
CHANGED
data/lib/linux/lxc/lines.rb
CHANGED
data/lib/linux/lxc/version.rb
CHANGED
data/lib/linux/lxc.rb
CHANGED
@@ -7,12 +7,28 @@ require_relative 'lxc/index'
|
|
7
7
|
|
8
8
|
module Linux
|
9
9
|
module Lxc
|
10
|
+
def self.numeric_prefix_order(data)
|
11
|
+
data.sort do |a,b|
|
12
|
+
a_m = a.match(/^(\d+)(.*)$/)
|
13
|
+
b_m = b.match(/^(\d+)(.*)$/)
|
14
|
+
if a_m && b_m
|
15
|
+
ret = a_m[1].to_i <=> b_m[1].to_i
|
16
|
+
if ret == 0
|
17
|
+
ret = a_m[2] <=> b_m[2]
|
18
|
+
end
|
19
|
+
ret
|
20
|
+
else
|
21
|
+
a <=> b
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
10
26
|
def self.parse(file, index = Index.new)
|
11
27
|
if ::File.directory?(file)
|
12
28
|
fname = file
|
13
29
|
entries = ::Dir.glob(::File.join(file, '*.conf')).select { |f| ::File.file?(f) }
|
14
30
|
dir = index.get_directory(fname)
|
15
|
-
entries.each do |entry|
|
31
|
+
numeric_prefix_order(entries).each do |entry|
|
16
32
|
dir.add_file(entry).parse
|
17
33
|
end
|
18
34
|
return dir
|
data/test/linux_lxc_test.rb
CHANGED
@@ -203,6 +203,7 @@ SAMPLE
|
|
203
203
|
assert_equal lxc.get('#').length, 43
|
204
204
|
lxc.get('lxc.network').comment!
|
205
205
|
assert_equal lxc.get('#').length, 47
|
206
|
+
assert_equal lxc.get('#')[45].to_s, '# lxc.network.link = lxcbr0'
|
206
207
|
assert_equal lxc.get('lxc.network'), nil
|
207
208
|
lxc.index.files.values.each do |file|
|
208
209
|
file.real_fname = ::File.join(::File.dirname(file.file), "-.#{::File.basename(file.file)}")
|
@@ -290,4 +291,12 @@ SAMPLE
|
|
290
291
|
assert_equal lxc_read.get('lxc.network.hwaddr').first.file, lxc.file
|
291
292
|
assert_equal lxc_read.get('lxc.network.hwaddr').first.line, 18
|
292
293
|
end
|
294
|
+
|
295
|
+
def test_numeric_prefix_order
|
296
|
+
assert_equal Linux::Lxc.numeric_prefix_order(["100_a", "1_b", "34d"]), ["1_b","34d","100_a"]
|
297
|
+
assert_equal Linux::Lxc.numeric_prefix_order(["1_c", "1_a", "1a"]), ["1_a","1_c","1a"]
|
298
|
+
assert_equal Linux::Lxc.numeric_prefix_order(["000100_a", "000001_b", "034d"]), ["000001_b","034d","000100_a"]
|
299
|
+
assert_equal Linux::Lxc.numeric_prefix_order(["foo","100_a", "000001_b", "bar", "34d"]), ["000001_b","34d","100_a","bar", "foo"]
|
300
|
+
assert_equal Linux::Lxc.numeric_prefix_order(["foo","yyy", "bar"]), ["bar", "foo", "yyy"]
|
301
|
+
end
|
293
302
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linux-lxc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Meno Abels
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Parse the output of ip addr on a linux system
|
14
14
|
email:
|