Module: ConfCtl::UserScripts
- Defined in:
- lib/confctl/user_scripts.rb
Class Method Summary collapse
- .each {|| ... } ⇒ Object
- .get ⇒ Array<UserScript>
- .load_scripts ⇒ Object
- .register(klass) ⇒ Object
- .setup_all ⇒ Object
Class Method Details
.each {|| ... } ⇒ Object
37 38 39 |
# File 'lib/confctl/user_scripts.rb', line 37 def self.each(&) get.each(&) end |
.get ⇒ Array<UserScript>
32 33 34 |
# File 'lib/confctl/user_scripts.rb', line 32 def self.get @scripts || [] end |
.load_scripts ⇒ Object
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_all ⇒ Object
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 |