Class: Dir

Inherits:
Object
  • Object
show all
Defined in:
lib/mb/core_ext/dir.rb

Class Method Summary collapse

Class Method Details

.has_chef_metadata?(path) ⇒ Boolean

Check if the given directory contains a Chef metadata file

Parameters:

  • path (#to_s)

    the directory path

Returns:

  • (Boolean)


32
33
34
35
# File 'lib/mb/core_ext/dir.rb', line 32

def has_chef_metadata?(path)
  File.exist?(File.join(path, MB::CookbookMetadata::RUBY_FILENAME)) ||
    File.exist?(File.join(path, MB::CookbookMetadata::JSON_FILENAME))
end

.has_mb_file?(path) ⇒ Boolean

Check if the given directory contains a motherbrain plugin file

Parameters:

  • path (#to_s)

    the directory path

Returns:

  • (Boolean)


22
23
24
# File 'lib/mb/core_ext/dir.rb', line 22

def has_mb_file?(path)
  File.exist?(File.join(path, MB::Plugin::PLUGIN_FILENAME))
end

.has_mb_plugin?(path) ⇒ Boolean

Check if the given directory contains a cookbook with a motherbrain plugin

Parameters:

  • path (#to_s)

    the directory path

Returns:

  • (Boolean)


9
10
11
12
13
14
# File 'lib/mb/core_ext/dir.rb', line 9

def has_mb_plugin?(path)
  return false unless exists?(path)
  return false unless has_mb_file?(path)
  return false unless has_chef_metadata?(path)
  true
end