mirror of
https://github.com/inspec/inspec
synced 2024-11-22 20:53:11 +00:00
rename contents -> content
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
parent
5a8bcf2b93
commit
84102b89de
13 changed files with 24 additions and 24 deletions
|
@ -31,13 +31,13 @@ class ApacheConf < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def filter_comments data
|
||||
contents = ""
|
||||
content = ""
|
||||
data.each_line do |line|
|
||||
if (!line.match(/^\s*#/)) then
|
||||
contents << line
|
||||
content << line
|
||||
end
|
||||
end
|
||||
return contents
|
||||
return content
|
||||
end
|
||||
|
||||
def read_content
|
||||
|
@ -50,7 +50,7 @@ class ApacheConf < Vulcano.resource(1)
|
|||
return skip_resource "Can't find file \"#{@conf_path}\""
|
||||
end
|
||||
|
||||
raw_conf = file.contents
|
||||
raw_conf = file.content
|
||||
if raw_conf.empty? && file.size > 0
|
||||
return skip_resource("Can't read file \"#{@conf_path}\"")
|
||||
end
|
||||
|
@ -102,6 +102,6 @@ class ApacheConf < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def read_file(path)
|
||||
@files_contents[path] ||= @vulcano.file(path).contents
|
||||
@files_contents[path] ||= @vulcano.file(path).content
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ class AuditDaemonConf < Vulcano.resource(1)
|
|||
return skip_resource "Can't find file \"#{@conf_path}\""
|
||||
end
|
||||
|
||||
@content = file.contents
|
||||
@content = file.content
|
||||
if @content.empty? && file.size > 0
|
||||
return skip_resource "Can't read file \"#{@conf_path}\""
|
||||
end
|
||||
|
|
|
@ -57,8 +57,8 @@ class EtcGroup < Vulcano.resource(1)
|
|||
private
|
||||
|
||||
def parse(path)
|
||||
@contents = @vulcano.file(path).contents
|
||||
@contents.split("\n").map do |line|
|
||||
@content = @vulcano.file(path).content
|
||||
@content.split("\n").map do |line|
|
||||
line.split(':')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ class InetdConf < Vulcano.resource(1)
|
|||
if !file.is_file?
|
||||
return skip_resource "Can't find file \"#{@conf_path}\""
|
||||
end
|
||||
@content = file.contents
|
||||
@content = file.content
|
||||
if @content.empty? && file.size > 0
|
||||
return skip_resource "Can't read file \"#{@conf_path}\""
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ class LimitsConf < Vulcano.resource(1)
|
|||
if !file.is_file?
|
||||
return skip_resource "Can't find file \"#{@conf_path}\""
|
||||
end
|
||||
@content = file.contents
|
||||
@content = file.content
|
||||
if @content.empty? && file.size > 0
|
||||
return skip_resource "Can't read file \"#{@conf_path}\""
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ class LoginDef < Vulcano.resource(1)
|
|||
if !file.is_file?
|
||||
return skip_resource "Can't find file \"#{@conf_path}\""
|
||||
end
|
||||
@content = file.contents
|
||||
@content = file.content
|
||||
if @content.empty? && file.size > 0
|
||||
return skip_resource "Can't read file \"#{@conf_path}\""
|
||||
end
|
||||
|
|
|
@ -92,6 +92,6 @@ class MysqlConf < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def read_file(path)
|
||||
@files_contents[path] ||= @vulcano.file(path).contents
|
||||
@files_contents[path] ||= @vulcano.file(path).content
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ class NtpConf < Vulcano.resource(1)
|
|||
if !@vulcano.file(@conf_path).is_file?
|
||||
return skip_resource "Can't find file \"#{@conf_path}\""
|
||||
end
|
||||
@content = @vulcano.file(@conf_path).contents
|
||||
@content = @vulcano.file(@conf_path).content
|
||||
if @content.empty? && @vulcano.file(@conf_path).size > 0
|
||||
return skip_resource "Can't read file \"#{@conf_path}\""
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@ class PConfig < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def read_file(path)
|
||||
@files_contents[path] ||= @vulcano.file(path).contents
|
||||
@files_contents[path] ||= @vulcano.file(path).content
|
||||
end
|
||||
|
||||
def read_content
|
||||
|
|
|
@ -18,7 +18,7 @@ class Passwd < Vulcano.resource(1)
|
|||
|
||||
def initialize(path = nil, uid: nil)
|
||||
@path = path || '/etc/passwd'
|
||||
@content = @vulcano.file(@path).contents
|
||||
@content = @vulcano.file(@path).content
|
||||
@parsed = parse(@content)
|
||||
end
|
||||
|
||||
|
|
|
@ -70,6 +70,6 @@ class PostgresConf < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def read_file(path)
|
||||
@files_contents[path] ||= @vulcano.file(path).contents
|
||||
@files_contents[path] ||= @vulcano.file(path).content
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ class SshConf < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def content
|
||||
@conf.contents
|
||||
@conf.content
|
||||
end
|
||||
|
||||
def params *opts
|
||||
|
@ -44,12 +44,12 @@ class SshConf < Vulcano.resource(1)
|
|||
return skip_resource "Can't find file \"#{@conf_path}\""
|
||||
end
|
||||
|
||||
if @conf.contents.empty? && @conf.size > 0
|
||||
if @conf.content.empty? && @conf.size > 0
|
||||
return skip_resource "Can't read file \"#{@conf_path}\""
|
||||
end
|
||||
|
||||
# parse the file
|
||||
@params = SimpleConfig.new(@conf.contents,
|
||||
@params = SimpleConfig.new(@conf.content,
|
||||
assignment_re: /^\s*(\S+?)\s+(.*?)\s*$/,
|
||||
multiple_values: false
|
||||
).params
|
||||
|
|
|
@ -8,13 +8,13 @@ module Vulcano::Backend::Mock
|
|||
@exists = (rand < 0.8) ? true : false
|
||||
@is_file = (@exists && rand < 0.7) ? true : false
|
||||
@size = 0
|
||||
@contents = ''
|
||||
@content = ''
|
||||
if @exists && @is_file
|
||||
@size = ( rand ** 3 * 1000 ).to_i
|
||||
@size = 0 if rand < 0.2
|
||||
end
|
||||
if @size > 0
|
||||
@contents = (0...50).map { ('a'..'z').to_a[rand(26)] }.join
|
||||
@content = (0...50).map { ('a'..'z').to_a[rand(26)] }.join
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -23,9 +23,9 @@ module Vulcano::Backend::Mock
|
|||
@size
|
||||
end
|
||||
|
||||
def contents
|
||||
puts "----> get file #{@path} contents: #{@contents}"
|
||||
@contents
|
||||
def content
|
||||
puts "----> get file #{@path} content: #{@content}"
|
||||
@content
|
||||
end
|
||||
|
||||
def is_file?
|
||||
|
|
Loading…
Reference in a new issue