Sha256: 90f4c979b632df00903b393ce9663693207dcac3dad040f17fddceb16c136dd9

Contents?: true

Size: 1.17 KB

Versions: 30

Compression:

Stored size: 1.17 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, project)
      mods = {}

      if project.load_as_module?
        mods[project.name] = Bolt::Module.new(project.name, project.path.to_s)
      end

      modulepath.each do |path|
        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

      mods
    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

30 entries across 30 versions & 1 rubygems

Version Path
bolt-3.21.0 lib/bolt/module.rb
bolt-3.20.0 lib/bolt/module.rb
bolt-3.19.0 lib/bolt/module.rb
bolt-3.18.0 lib/bolt/module.rb
bolt-3.17.0 lib/bolt/module.rb
bolt-3.16.1 lib/bolt/module.rb
bolt-3.16.0 lib/bolt/module.rb
bolt-3.15.0 lib/bolt/module.rb
bolt-3.14.1 lib/bolt/module.rb
bolt-3.13.0 lib/bolt/module.rb
bolt-3.12.0 lib/bolt/module.rb
bolt-3.11.0 lib/bolt/module.rb
bolt-3.10.0 lib/bolt/module.rb
bolt-3.9.2 lib/bolt/module.rb
bolt-3.9.1 lib/bolt/module.rb
bolt-3.9.0 lib/bolt/module.rb
bolt-3.8.1 lib/bolt/module.rb
bolt-3.8.0 lib/bolt/module.rb
bolt-3.7.1 lib/bolt/module.rb
bolt-3.7.0 lib/bolt/module.rb