mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
File.exists? is deprecated in ruby 2.1
See: http://ruby-doc.org/core-2.1.0/File.html#method-c-exists-3F Same for Dir: http://ruby-doc.org/core-2.1.0/Dir.html#method-c-exists-3F Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
parent
824945fefa
commit
0b7eb60028
6 changed files with 10 additions and 10 deletions
|
@ -12,7 +12,7 @@ module Vulcano::Resources
|
|||
end
|
||||
|
||||
%w{
|
||||
type exists? file? block_device? character_device? socket? directory?
|
||||
type exist? file? block_device? character_device? socket? directory?
|
||||
symlink? pipe? mode mode? owner owned_by? group grouped_into? link_target
|
||||
linked_to? content mtime size selinux_label mounted? immutable?
|
||||
product_version file_version version? md5sum sha256sum
|
||||
|
|
|
@ -96,7 +96,7 @@ module Vulcano::Backends
|
|||
end
|
||||
|
||||
%w{
|
||||
exists? file? socket? directory? symlink? pipe?
|
||||
exist? file? socket? directory? symlink? pipe?
|
||||
}.each do |m|
|
||||
define_method m.to_sym do
|
||||
::File.method(m.to_sym).call(@path)
|
||||
|
|
|
@ -63,11 +63,11 @@ module Vulcano::Backends
|
|||
def initialize(_runtime, path)
|
||||
@path = path
|
||||
# mock dataset
|
||||
@exists = (rand < 0.8) ? true : false
|
||||
@is_file = (@exists && rand < 0.7) ? true : false
|
||||
@exist = (rand < 0.8) ? true : false
|
||||
@is_file = (@exist && rand < 0.7) ? true : false
|
||||
@size = 0
|
||||
@content = ''
|
||||
if @exists && @is_file
|
||||
if @exist && @is_file
|
||||
@size = (rand**3 * 1000).to_i
|
||||
@size = 0 if rand < 0.2
|
||||
end
|
||||
|
@ -77,7 +77,7 @@ module Vulcano::Backends
|
|||
@content
|
||||
end
|
||||
|
||||
%w{ size content file? exists? }.each do |m|
|
||||
%w{ size content file? exist? }.each do |m|
|
||||
define_method m.to_sym do
|
||||
instance_variable_get(m.sub('?', '').to_sym)
|
||||
end
|
||||
|
|
|
@ -218,7 +218,7 @@ module Vulcano::Backends
|
|||
super(backend, path)
|
||||
end
|
||||
|
||||
def exists?
|
||||
def exist?
|
||||
Specinfra::Runner.check_file_exists(@path)
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ class Vulcano::Plugins::Backend
|
|||
# interface methods: these fields should be implemented by every
|
||||
# backend File
|
||||
%w{
|
||||
exists? mode owner group link_target content mtime size
|
||||
exist? mode owner group link_target content mtime size
|
||||
selinux_label product_version file_version path
|
||||
}.each do |m|
|
||||
define_method m.to_sym do
|
||||
|
|
|
@ -17,8 +17,8 @@ class Vulcano::Plugins::Backend
|
|||
"cat #{@spath} 2>/dev/null || echo -n").stdout
|
||||
end
|
||||
|
||||
def exists?
|
||||
@exists ||= (
|
||||
def exist?
|
||||
@exist ||= (
|
||||
@backend.
|
||||
run_command("test -e #{@spath}").
|
||||
exit_status == 0
|
||||
|
|
Loading…
Reference in a new issue