mirror of
https://github.com/inspec/inspec
synced 2024-11-30 08:30:39 +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
|
end
|
||||||
|
|
||||||
%w{
|
%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
|
symlink? pipe? mode mode? owner owned_by? group grouped_into? link_target
|
||||||
linked_to? content mtime size selinux_label mounted? immutable?
|
linked_to? content mtime size selinux_label mounted? immutable?
|
||||||
product_version file_version version? md5sum sha256sum
|
product_version file_version version? md5sum sha256sum
|
||||||
|
|
|
@ -96,7 +96,7 @@ module Vulcano::Backends
|
||||||
end
|
end
|
||||||
|
|
||||||
%w{
|
%w{
|
||||||
exists? file? socket? directory? symlink? pipe?
|
exist? file? socket? directory? symlink? pipe?
|
||||||
}.each do |m|
|
}.each do |m|
|
||||||
define_method m.to_sym do
|
define_method m.to_sym do
|
||||||
::File.method(m.to_sym).call(@path)
|
::File.method(m.to_sym).call(@path)
|
||||||
|
|
|
@ -63,11 +63,11 @@ module Vulcano::Backends
|
||||||
def initialize(_runtime, path)
|
def initialize(_runtime, path)
|
||||||
@path = path
|
@path = path
|
||||||
# mock dataset
|
# mock dataset
|
||||||
@exists = (rand < 0.8) ? true : false
|
@exist = (rand < 0.8) ? true : false
|
||||||
@is_file = (@exists && rand < 0.7) ? true : false
|
@is_file = (@exist && rand < 0.7) ? true : false
|
||||||
@size = 0
|
@size = 0
|
||||||
@content = ''
|
@content = ''
|
||||||
if @exists && @is_file
|
if @exist && @is_file
|
||||||
@size = (rand**3 * 1000).to_i
|
@size = (rand**3 * 1000).to_i
|
||||||
@size = 0 if rand < 0.2
|
@size = 0 if rand < 0.2
|
||||||
end
|
end
|
||||||
|
@ -77,7 +77,7 @@ module Vulcano::Backends
|
||||||
@content
|
@content
|
||||||
end
|
end
|
||||||
|
|
||||||
%w{ size content file? exists? }.each do |m|
|
%w{ size content file? exist? }.each do |m|
|
||||||
define_method m.to_sym do
|
define_method m.to_sym do
|
||||||
instance_variable_get(m.sub('?', '').to_sym)
|
instance_variable_get(m.sub('?', '').to_sym)
|
||||||
end
|
end
|
||||||
|
|
|
@ -218,7 +218,7 @@ module Vulcano::Backends
|
||||||
super(backend, path)
|
super(backend, path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def exists?
|
def exist?
|
||||||
Specinfra::Runner.check_file_exists(@path)
|
Specinfra::Runner.check_file_exists(@path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ class Vulcano::Plugins::Backend
|
||||||
# interface methods: these fields should be implemented by every
|
# interface methods: these fields should be implemented by every
|
||||||
# backend File
|
# backend File
|
||||||
%w{
|
%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
|
selinux_label product_version file_version path
|
||||||
}.each do |m|
|
}.each do |m|
|
||||||
define_method m.to_sym do
|
define_method m.to_sym do
|
||||||
|
|
|
@ -17,8 +17,8 @@ class Vulcano::Plugins::Backend
|
||||||
"cat #{@spath} 2>/dev/null || echo -n").stdout
|
"cat #{@spath} 2>/dev/null || echo -n").stdout
|
||||||
end
|
end
|
||||||
|
|
||||||
def exists?
|
def exist?
|
||||||
@exists ||= (
|
@exist ||= (
|
||||||
@backend.
|
@backend.
|
||||||
run_command("test -e #{@spath}").
|
run_command("test -e #{@spath}").
|
||||||
exit_status == 0
|
exit_status == 0
|
||||||
|
|
Loading…
Reference in a new issue