apache_config 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -11,6 +11,8 @@ module Apache
11
11
  SectionOpen = /^\s*<\s*(\w+)(?:\s+([^>]+)|\s*)>$/
12
12
  SectionClose = /^\s*<\/\s*(\w+)\s*>$/
13
13
 
14
+ attr_reader :path
15
+
14
16
  def initialize(path)
15
17
  @path = path
16
18
  @config = parse_config(path)
@@ -20,6 +22,12 @@ module Apache
20
22
  @config.children.map { |vh| VirtualHost.new(vh) }
21
23
  end
22
24
 
25
+ def save!
26
+ File.open(@path, 'w') do |f|
27
+ f.write to_config
28
+ end
29
+ end
30
+
23
31
  def to_config(root = nil, indent = "")
24
32
  element = root || @config
25
33
  content = ""
@@ -42,4 +42,12 @@ APACHE
42
42
 
43
43
  assert_match "ServerAlias www.example.com foo.be", config.to_config
44
44
  end
45
+
46
+ def test_saving
47
+ config = Apache::Config.new('/etc/apache2/example.conf')
48
+ config.virtual_hosts.first.aliases << 'foo.be'
49
+ config.save!
50
+
51
+ assert_match "ServerAlias www.example.com foo.be", File.read('/etc/apache2/example.conf')
52
+ end
45
53
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jan De Poorter