Sha256: f335cff3222335297c853e08b6682584b1b2a0a79b19ae9af44ba11623f1c932

Contents?: true

Size: 994 Bytes

Versions: 15

Compression:

Stored size: 994 Bytes

Contents

class Dir
  class << self
    # Check if the given directory contains a cookbook with a motherbrain plugin
    #
    # @param [#to_s] path
    #   the directory path
    #
    # @return [Boolean]
    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

    # Check if the given directory contains a motherbrain plugin file
    #
    # @param [#to_s] path
    #   the directory path
    #
    # @return [Boolean]
    def has_mb_file?(path)
      File.exist?(File.join(path, MB::Plugin::PLUGIN_FILENAME))
    end

    # Check if the given directory contains a Chef metadata file
    #
    # @param [#to_s] path
    #   the directory path
    #
    # @return [Boolean]
    def has_chef_metadata?(path)
      File.exist?(File.join(path, MB::CookbookMetadata::RUBY_FILENAME)) ||
        File.exist?(File.join(path, MB::CookbookMetadata::JSON_FILENAME))
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
motherbrain-1.5.0 lib/mb/core_ext/dir.rb
motherbrain-1.4.0 lib/mb/core_ext/dir.rb
motherbrain-1.3.0 lib/mb/core_ext/dir.rb
motherbrain-1.2.1 lib/mb/core_ext/dir.rb
motherbrain-1.2.0 lib/mb/core_ext/dir.rb
motherbrain-1.1.3 lib/mb/core_ext/dir.rb
motherbrain-1.1.2 lib/mb/core_ext/dir.rb
motherbrain-1.1.1 lib/mb/core_ext/dir.rb
motherbrain-1.1.0 lib/mb/core_ext/dir.rb
motherbrain-1.0.0 lib/mb/core_ext/dir.rb
motherbrain-0.14.5 lib/mb/core_ext/dir.rb
motherbrain-0.14.4 lib/mb/core_ext/dir.rb
motherbrain-0.14.3 lib/mb/core_ext/dir.rb
motherbrain-0.14.2 lib/mb/core_ext/dir.rb
motherbrain-0.13.1 lib/mb/core_ext/dir.rb