Sha256: 582f1e7c6b39d8ed5004696693108ca756b7bc0472c322d4fd49f6343a58baa9

Contents?: true

Size: 1.03 KB

Versions: 21

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

# Is this Bolt::Pobs::Module?
module Bolt
  class Module
    CONTENT_NAME_REGEX = /\A[a-z][a-z0-9_]*(::[a-z][a-z0-9_]*)*\z/.freeze
    MODULE_NAME_REGEX  = /\A[a-z][a-z0-9_]*\z/.freeze

    def self.discover(modulepath)
      modulepath.each_with_object({}) do |path, mods|
        next unless File.exist?(path) && File.directory?(path)
        Dir.children(path)
           .map { |dir| File.join(path, dir) }
           .select { |dir| File.directory?(dir) }
           .each do |dir|
          module_name = File.basename(dir)
          if module_name =~ MODULE_NAME_REGEX
            # Puppet will load some objects from shadowed modules but this won't
            mods[module_name] ||= Bolt::Module.new(module_name, dir)
          end
        end
      end
    end

    attr_reader :name, :path

    def initialize(name, path)
      @name = name
      @path = path
    end

    def plugin_data_file
      File.join(path, 'bolt_plugin.json')
    end

    def plugin?
      File.exist?(plugin_data_file)
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
bolt-2.40.2 lib/bolt/module.rb
bolt-2.40.1 lib/bolt/module.rb
bolt-2.38.0 lib/bolt/module.rb
bolt-2.37.0 lib/bolt/module.rb
bolt-2.36.0 lib/bolt/module.rb
bolt-2.35.0 lib/bolt/module.rb
bolt-2.34.0 lib/bolt/module.rb
bolt-2.33.2 lib/bolt/module.rb
bolt-2.33.1 lib/bolt/module.rb
bolt-2.32.0 lib/bolt/module.rb
bolt-2.31.0 lib/bolt/module.rb
bolt-2.30.0 lib/bolt/module.rb
bolt-2.29.0 lib/bolt/module.rb
bolt-2.28.0 lib/bolt/module.rb
bolt-2.27.0 lib/bolt/module.rb
bolt-2.26.0 lib/bolt/module.rb
bolt-2.25.0 lib/bolt/module.rb
bolt-2.24.1 lib/bolt/module.rb
bolt-2.24.0 lib/bolt/module.rb
bolt-2.23.0 lib/bolt/module.rb