diff --git a/lib/resources/bond.rb b/lib/resources/bond.rb index 3dfb7d9bd..39a5e1ed0 100644 --- a/lib/resources/bond.rb +++ b/lib/resources/bond.rb @@ -21,7 +21,7 @@ module Vulcano::Resources @file.content, assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/, multiple_values: true, - ).params if @file.exists? + ).params if @file.exist? @loaded = true @content end @@ -37,8 +37,8 @@ module Vulcano::Resources @content end - def exists? - @file.exists? + def exist? + @file.exist? end def has_interface?(interface) diff --git a/lib/resources/command.rb b/lib/resources/command.rb index 107b50a02..8f72775e3 100644 --- a/lib/resources/command.rb +++ b/lib/resources/command.rb @@ -24,7 +24,7 @@ class Cmd < Vulcano.resource(1) result.exit_status.to_i end - def exists? + def exist? res = vulcano.run_command("type \"#{@command}\" > /dev/null") res.exit_status.to_i == 0 end diff --git a/lib/resources/file.rb b/lib/resources/file.rb index d0ce82bd8..e399a5d09 100644 --- a/lib/resources/file.rb +++ b/lib/resources/file.rb @@ -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 diff --git a/lib/resources/service.rb b/lib/resources/service.rb index fa90d5853..04c1faed3 100644 --- a/lib/resources/service.rb +++ b/lib/resources/service.rb @@ -173,7 +173,7 @@ class SysV < ServiceManager service = @vulcano.file(filename) # check if service is installed - return nil if !service.exists? + return nil if !service.exist? # check if service is enabled configfile = "/etc/init/#{service_name}.conf" diff --git a/lib/resources/yum.rb b/lib/resources/yum.rb index 5f62a0967..85e49e783 100644 --- a/lib/resources/yum.rb +++ b/lib/resources/yum.rb @@ -117,7 +117,7 @@ class YumRepo @cache end - def exists? + def exist? !info.nil? end @@ -141,7 +141,7 @@ module Vulcano::Resources def exists? deprecated - @repository.exists? + @repository.exist? end def enabled? diff --git a/lib/vulcano/backend/local.rb b/lib/vulcano/backend/local.rb index 9ea63efab..fe165257b 100644 --- a/lib/vulcano/backend/local.rb +++ b/lib/vulcano/backend/local.rb @@ -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) diff --git a/lib/vulcano/backend/mock.rb b/lib/vulcano/backend/mock.rb index f6d442a11..4e542432d 100644 --- a/lib/vulcano/backend/mock.rb +++ b/lib/vulcano/backend/mock.rb @@ -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 diff --git a/lib/vulcano/backend/specinfra.rb b/lib/vulcano/backend/specinfra.rb index a2642d908..1ef65b943 100644 --- a/lib/vulcano/backend/specinfra.rb +++ b/lib/vulcano/backend/specinfra.rb @@ -218,7 +218,7 @@ module Vulcano::Backends super(backend, path) end - def exists? + def exist? Specinfra::Runner.check_file_exists(@path) end diff --git a/lib/vulcano/plugins/backend_file_common.rb b/lib/vulcano/plugins/backend_file_common.rb index 97898c8f5..182451e3b 100644 --- a/lib/vulcano/plugins/backend_file_common.rb +++ b/lib/vulcano/plugins/backend_file_common.rb @@ -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 diff --git a/lib/vulcano/plugins/backend_linux_file.rb b/lib/vulcano/plugins/backend_linux_file.rb index 9d16be4a4..7347c0e6a 100644 --- a/lib/vulcano/plugins/backend_linux_file.rb +++ b/lib/vulcano/plugins/backend_linux_file.rb @@ -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 diff --git a/test/resource/command.rb b/test/resource/command.rb index 5f719f458..9054df841 100644 --- a/test/resource/command.rb +++ b/test/resource/command.rb @@ -17,14 +17,14 @@ describe command('exit 123') do its(:exit_status) { should eq 123 } end -describe command('/bin/sh').exists? do +describe command('/bin/sh').exist? do it { should eq true } end -describe command('sh').exists? do +describe command('sh').exist? do it { should eq true } end -describe command('this is not existing').exists? do +describe command('this is not existing').exist? do it { should eq false } end diff --git a/test/resource/ssh_config.rb b/test/resource/ssh_config.rb index 7caa24d4b..5212a4ef1 100644 --- a/test/resource/ssh_config.rb +++ b/test/resource/ssh_config.rb @@ -1,5 +1,5 @@ -return unless command('ssh').exists? +return unless command('ssh').exist? describe ssh_config do its('SendEnv') { should include('GORDON_CLIENT')} diff --git a/test/resource/sshd_config.rb b/test/resource/sshd_config.rb index 2304f3466..1ddbc6268 100644 --- a/test/resource/sshd_config.rb +++ b/test/resource/sshd_config.rb @@ -1,5 +1,5 @@ -return unless command('sshd').exists? +return unless command('sshd').exist? describe sshd_config do its('AcceptEnv') { should include('GORDON_SERVER')} diff --git a/test/runner/tests/path_block_device_test.rb b/test/runner/tests/path_block_device_test.rb index 2746bfbcb..18baceacd 100644 --- a/test/runner/tests/path_block_device_test.rb +++ b/test/runner/tests/path_block_device_test.rb @@ -7,7 +7,7 @@ describe 'file interface' do let(:file) { backend.file('/tmp/block_device') } it 'exists' do - file.exists?.must_equal(true) + file.exist?.must_equal(true) end it 'is a block device' do diff --git a/test/runner/tests/path_character_device_test.rb b/test/runner/tests/path_character_device_test.rb index ac33d849b..decb4947e 100644 --- a/test/runner/tests/path_character_device_test.rb +++ b/test/runner/tests/path_character_device_test.rb @@ -7,7 +7,7 @@ describe 'file interface' do let(:file) { backend.file('/dev/null') } it 'exists' do - file.exists?.must_equal(true) + file.exist?.must_equal(true) end it 'is a character device' do diff --git a/test/runner/tests/path_file_test.rb b/test/runner/tests/path_file_test.rb index 8fdedd8b1..ee3ac92d1 100644 --- a/test/runner/tests/path_file_test.rb +++ b/test/runner/tests/path_file_test.rb @@ -7,7 +7,7 @@ describe 'file interface' do let(:file) { backend.file('/tmp/file') } it 'exists' do - file.exists?.must_equal(true) + file.exist?.must_equal(true) end it 'is a file' do diff --git a/test/runner/tests/path_folder_test.rb b/test/runner/tests/path_folder_test.rb index 203ee311e..c3bf4215d 100644 --- a/test/runner/tests/path_folder_test.rb +++ b/test/runner/tests/path_folder_test.rb @@ -7,7 +7,7 @@ describe 'file interface' do let(:file) { backend.file('/tmp/folder') } it 'exists' do - file.exists?.must_equal(true) + file.exist?.must_equal(true) end it 'is a directory' do diff --git a/test/runner/tests/path_missing_test.rb b/test/runner/tests/path_missing_test.rb index bd75cf74e..7bfe7c66e 100644 --- a/test/runner/tests/path_missing_test.rb +++ b/test/runner/tests/path_missing_test.rb @@ -9,7 +9,7 @@ describe 'file interface' do } it 'does not exist' do - file.exists?.must_equal(false) + file.exist?.must_equal(false) end it 'is not a file' do diff --git a/test/runner/tests/path_pipe_test.rb b/test/runner/tests/path_pipe_test.rb index 910f94d51..044999651 100644 --- a/test/runner/tests/path_pipe_test.rb +++ b/test/runner/tests/path_pipe_test.rb @@ -7,7 +7,7 @@ describe 'file interface' do let(:file) { backend.file('/tmp/pipe') } it 'exists' do - file.exists?.must_equal(true) + file.exist?.must_equal(true) end it 'is a pipe' do diff --git a/test/runner/tests/path_symlink_test.rb b/test/runner/tests/path_symlink_test.rb index bdaf04536..3ce9a37da 100644 --- a/test/runner/tests/path_symlink_test.rb +++ b/test/runner/tests/path_symlink_test.rb @@ -7,7 +7,7 @@ describe 'file interface' do let(:file) { backend.file('/tmp/symlink') } it 'exists' do - file.exists?.must_equal(true) + file.exist?.must_equal(true) end it 'is a symlink' do diff --git a/test/unit/resource_bond_test.rb b/test/unit/resource_bond_test.rb index 4059fc480..043a6a494 100644 --- a/test/unit/resource_bond_test.rb +++ b/test/unit/resource_bond_test.rb @@ -10,7 +10,7 @@ describe 'Vulcano::Resources::Bond' do let(:resource) { loadResource('bond', 'bond0') } it 'bond must be available' do - resource.exists?.must_equal true + resource.exist?.must_equal true end it 'eth0 is part of bond' do diff --git a/test/unit/resource_yum_test.rb b/test/unit/resource_yum_test.rb index d278024bd..a5adfb9e1 100644 --- a/test/unit/resource_yum_test.rb +++ b/test/unit/resource_yum_test.rb @@ -50,31 +50,31 @@ describe 'Vulcano::Resources::YumRepo' do # its('epel') { should exist } # its('epel') { should be_enabled } it 'test its syntax repo' do - _(resource.extras.exists?).must_equal true + _(resource.extras.exist?).must_equal true _(resource.extras.enabled?).must_equal true end it 'test enabled extra repo' do extras = resource.repo('extras/7/x86_64') - _(extras.exists?).must_equal true + _(extras.exist?).must_equal true _(extras.enabled?).must_equal true end it 'test enabled extra repo with short name' do extras = resource.repo('extras') - _(extras.exists?).must_equal true + _(extras.exist?).must_equal true _(extras.enabled?).must_equal true end it 'test disabled extra-source repo' do extras = resource.repo('base-debuginfo/x86_64') - _(extras.exists?).must_equal true + _(extras.exist?).must_equal true _(extras.enabled?).must_equal false end # test serverspec syntax let(:serverspec) { loadResource('yumrepo', 'extras') } - it 'test enabled extra repo' do + it 'test enabled extra repo (serverspec backwards comptability)' do _(serverspec.exists?).must_equal true _(serverspec.enabled?).must_equal true end