linux-lxc 0.0.2 → 0.0.3
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/version.rb +1 -1
- data/lib/linux/lxc.rb +19 -3
- data/test/linux_lxc_test.rb +14 -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: 82ff20f84dbc82af06e82c9d4552ea82ae4bfad6
|
4
|
+
data.tar.gz: d755aeed9611f57d05f246aaa5f7094577644d6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3046a5c9392832e513d9f3ebcc3d8c5fa33cc709bfbbe50434d770b44495f7550a5422e338c0e5b4da33c5e51cd6c96c6a71215bc72d51bb69f1641d9cc88287
|
7
|
+
data.tar.gz: 494d5420748539d109ef1e05769e4492d838ebfb24099247a2845537e00bf106c83f5f1a6f64fb63a1cbdedc0add8f73a730965f608e143c5dc0d9a94d4321b8
|
data/lib/linux/lxc/version.rb
CHANGED
data/lib/linux/lxc.rb
CHANGED
@@ -8,7 +8,7 @@ module Linux
|
|
8
8
|
attr_accessor :value
|
9
9
|
def initialize(lxc, key, value)
|
10
10
|
@lxc = lxc
|
11
|
-
@line = lxc.lines.add(self).length
|
11
|
+
@line = lxc && lxc.lines.add(self).length
|
12
12
|
@key = key
|
13
13
|
@value = value
|
14
14
|
end
|
@@ -32,8 +32,6 @@ module Linux
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
attr_reader :index, :lines
|
36
|
-
attr_accessor :file
|
37
35
|
|
38
36
|
class Lines
|
39
37
|
def initialize
|
@@ -75,6 +73,9 @@ module Linux
|
|
75
73
|
end
|
76
74
|
end
|
77
75
|
|
76
|
+
attr_reader :index, :lines
|
77
|
+
attr_accessor :file
|
78
|
+
|
78
79
|
def initialize(file, index = {})
|
79
80
|
@file = file
|
80
81
|
@lines = Lines.new
|
@@ -119,6 +120,21 @@ module Linux
|
|
119
120
|
end
|
120
121
|
end
|
121
122
|
|
123
|
+
def all_lines(&block)
|
124
|
+
@lines.each do |line|
|
125
|
+
block.call(line)
|
126
|
+
if line.value.instance_of?(Lxc)
|
127
|
+
line.value.all_lines(&block)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def files
|
133
|
+
ret = [Line.new(nil, "lxc.include", self)]
|
134
|
+
all_lines {|line| line.value.instance_of?(Lxc) && (ret << line) }
|
135
|
+
ret
|
136
|
+
end
|
137
|
+
|
122
138
|
def write
|
123
139
|
File.open(file, 'w') do |f|
|
124
140
|
@lines.each do |line|
|
data/test/linux_lxc_test.rb
CHANGED
@@ -177,6 +177,20 @@ SAMPLE
|
|
177
177
|
|
178
178
|
end
|
179
179
|
|
180
|
+
def test_lines
|
181
|
+
lxc = Linux::Lxc.parse(@lxc_config)
|
182
|
+
cnt = 0
|
183
|
+
lxc.all_lines{|line| cnt+=1 }
|
184
|
+
assert_equal cnt, 92
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_files
|
188
|
+
lxc = Linux::Lxc.parse(@lxc_config)
|
189
|
+
assert_equal lxc.files[0].value.file, @lxc_config
|
190
|
+
assert_equal File.basename(lxc.files[1].value.file), "ubuntu.common.conf"
|
191
|
+
assert_equal lxc.files.length, 2
|
192
|
+
end
|
193
|
+
|
180
194
|
def test_write
|
181
195
|
lxc = Linux::Lxc.parse(@lxc_config)
|
182
196
|
lxc.file = "#{@lxc_config}.new"
|
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.0.
|
4
|
+
version: 0.0.3
|
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-09-
|
11
|
+
date: 2015-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Parse the output of ip addr on a linux system
|
14
14
|
email:
|