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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fe1bf7762531084aa64d739d830692e7fcecf3a
4
- data.tar.gz: a5d0069c27df95bc06b6f7d9d00e1d52a62b7d7e
3
+ metadata.gz: 82ff20f84dbc82af06e82c9d4552ea82ae4bfad6
4
+ data.tar.gz: d755aeed9611f57d05f246aaa5f7094577644d6d
5
5
  SHA512:
6
- metadata.gz: 1fa95c148a460561a821951ff434b94add69d757033a98cca9d6d93c38fe615c1e998dae35b2560b63d587dd7bc832dccb38ba3b08dd9a75b668a982b315dc96
7
- data.tar.gz: 9a558c103146ba683a53c78d157577f69d82cd11b5cd735cbf8b5c8f63be219a86178505f1ac043bd5e87ffc3a9ca56218b99e51ef2d314e1b09b94791d284cb
6
+ metadata.gz: 3046a5c9392832e513d9f3ebcc3d8c5fa33cc709bfbbe50434d770b44495f7550a5422e338c0e5b4da33c5e51cd6c96c6a71215bc72d51bb69f1641d9cc88287
7
+ data.tar.gz: 494d5420748539d109ef1e05769e4492d838ebfb24099247a2845537e00bf106c83f5f1a6f64fb63a1cbdedc0add8f73a730965f608e143c5dc0d9a94d4321b8
@@ -1,5 +1,5 @@
1
1
  module Linux
2
2
  class Lxc
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
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|
@@ -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.2
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-22 00:00:00.000000000 Z
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: