Sha256: ffe375b79fa8c65266c983b54fe3cac6d5c326412d1989e942b32412fc7e9c1f

Contents?: true

Size: 697 Bytes

Versions: 2

Compression:

Stored size: 697 Bytes

Contents

module ConfCtl
  module UserScripts
    def self.load_scripts
      dir = ConfDir.user_script_dir

      begin
        files = Dir.entries(dir)
      rescue Errno::ENOENT
        return
      end

      files.each do |f|
        abs_path = File.join(dir, f)
        next unless File.file?(abs_path)

        load(abs_path)
      end
    end

    def self.register(klass)
      @scripts ||= []
      @scripts << klass.new
    end

    def self.setup_all
      each do |script|
        script.setup_hooks(Hook)
      end
    end

    # @return [Array<UserScript>]
    def self.get
      @scripts || []
    end

    # @yieldparam [UserScript]
    def self.each(&)
      get.each(&)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
confctl-2.0.0 lib/confctl/user_scripts.rb
confctl-1.0.0 lib/confctl/user_scripts.rb