Module: ConfCtl::UserScripts

Defined in:
lib/confctl/user_scripts.rb

Class Method Summary collapse

Class Method Details

.each {|| ... } ⇒ Object

Yield Parameters:



37
38
39
# File 'lib/confctl/user_scripts.rb', line 37

def self.each(&)
  get.each(&)
end

.getArray<UserScript>

Returns:



32
33
34
# File 'lib/confctl/user_scripts.rb', line 32

def self.get
  @scripts || []
end

.load_scriptsObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/confctl/user_scripts.rb', line 3

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

.register(klass) ⇒ Object



20
21
22
23
# File 'lib/confctl/user_scripts.rb', line 20

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

.setup_allObject



25
26
27
28
29
# File 'lib/confctl/user_scripts.rb', line 25

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