descope calls to global File

This is just for simplicity. I expect other users to make the same mistake when using it, so I would rather our tests crash if we have this type of conflict again and prevent it in the first place. Renaming File to FileResource should take care of all important places
This commit is contained in:
Dominik Richter 2016-03-09 10:39:07 +01:00
parent 844580074d
commit 24ffdf0478
5 changed files with 10 additions and 10 deletions

View file

@ -14,12 +14,12 @@ module Inspec::Resources
when 'ubuntu', 'debian'
@service = 'apache2'
@conf_dir = '/etc/apache2/'
@conf_path = ::File.join @conf_dir, 'apache2.conf'
@conf_path = File.join @conf_dir, 'apache2.conf'
@user = 'www-data'
else
@service = 'httpd'
@conf_dir = '/etc/httpd/'
@conf_path = ::File.join @conf_dir, '/conf/httpd.conf'
@conf_path = File.join @conf_dir, '/conf/httpd.conf'
@user = 'apache'
end
end

View file

@ -21,7 +21,7 @@ module Inspec::Resources
def initialize(conf_path = nil)
@conf_path = conf_path || inspec.apache.conf_path
@conf_dir = ::File.dirname(@conf_path)
@conf_dir = File.dirname(@conf_path)
@files_contents = {}
@content = nil
@params = nil
@ -105,7 +105,7 @@ module Inspec::Resources
includes = []
(include_files + include_files_optional).each do |f|
id = ::File.join(@conf_dir, f)
id = File.join(@conf_dir, f)
files = find_files(id, depth: 1, type: 'file')
includes.push(files) if files

View file

@ -89,7 +89,7 @@ module Inspec::Resources
to_read = to_read.drop(1)
# see if there is more stuff to include
dir = ::File.dirname(cur_file)
dir = File.dirname(cur_file)
to_read += include_files(dir, raw_conf).find_all do |fp|
not @files_contents.key? fp
end
@ -110,7 +110,7 @@ module Inspec::Resources
def abs_path(dir, f)
return f if f.start_with? '/'
::File.join(dir, f)
File.join(dir, f)
end
def read_file(path)

View file

@ -16,19 +16,19 @@ module Inspec::Resources
@data_dir = '/var/lib/postgresql'
@version = inspec.command('ls /etc/postgresql/').stdout.chomp
@conf_dir = "/etc/postgresql/#{@version}/main"
@conf_path = ::File.join @conf_dir, 'postgresql.conf'
@conf_path = File.join @conf_dir, 'postgresql.conf'
when 'arch'
@service = 'postgresql'
@data_dir = '/var/lib/postgres/data'
@conf_dir = '/var/lib/postgres/data'
@conf_path = ::File.join @conf_dir, 'postgresql.conf'
@conf_path = File.join @conf_dir, 'postgresql.conf'
else
@service = 'postgresql'
@data_dir = '/var/lib/postgresql'
@conf_dir = '/var/lib/pgsql/data'
@conf_path = ::File.join @conf_dir, 'postgresql.conf'
@conf_path = File.join @conf_dir, 'postgresql.conf'
end
end

View file

@ -22,7 +22,7 @@ module Inspec::Resources
def initialize(conf_path = nil)
@conf_path = conf_path || inspec.postgres.conf_path
@conf_dir = ::File.expand_path(::File.dirname(@conf_path))
@conf_dir = File.expand_path(File.dirname(@conf_path))
@files_contents = {}
@content = nil
@params = nil