Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #36 from alphagov/windows_support

Introduce support for different operating systems.
  • Loading branch information...
commit 3194b8fffd2e1081748db483b04cfa9cb2896e73 2 parents df9926c + 93695a9
@bjeanes authored
View
7 lib/ghost/store/hosts_file_store.rb
@@ -2,6 +2,7 @@
require 'ghost/host'
require 'ghost/tokenized_file'
+require 'resolv'
module Ghost
module Store
@@ -10,11 +11,7 @@ module Store
class HostsFileStore
attr_accessor :path, :file
- # TODO: Support windows locations:
- # Windows 95/98/Me c:\windows\hosts
- # Windows NT/2000/XP Pro c:\winnt\system32\drivers\etc\hosts
- # Windows XP Home c:\windows\system32\drivers\etc\hosts
- def initialize(path = "/etc/hosts")
+ def initialize(path = Resolv::Hosts::DefaultFileName)
self.path = path
self.file = Ghost::TokenizedFile.new(path, "# ghost start", "# ghost end")
end
View
5 spec/ghost/store/hosts_file_store_spec.rb
@@ -34,7 +34,10 @@ def no_write
before { write(contents) }
it 'manages the default file of /etc/hosts when no file path is provided' do
- described_class.new.path.should == "/etc/hosts"
+ previous_hosts_location = Resolv::Hosts::DefaultFileName
+ Resolv::Hosts::DefaultFileName = "hosts_location"
+ described_class.new.path.should == "hosts_location"
+ Resolv::Hosts::DefaultFileName = previous_hosts_location
end
it 'manages the file at the provided path when given' do
Please sign in to comment.
Something went wrong with that request. Please try again.