Class: RubyConf::Loader
- Inherits:
- BasicObject
- Defined in:
- lib/ruby-conf.rb
Constant Summary collapse
- EXTENTIONS =
%w{rc rb config conf rbcnf rbconf rbconfig rubyconf rubyconfig ruby-conf ruby-config}
- @@conf =
@@path = @@mtime = @@md5 = nil
Class Method Summary collapse
- .__rc_autoload ⇒ Object
- .__rc_conf ⇒ Object
- .__rc_load(path) ⇒ Object
- .__rc_loaded_conf ⇒ Object
- .__rc_reload ⇒ Object
- .__rc_set_conf(conf = nil) ⇒ Object
- .inspect ⇒ Object
- .method_missing(name, *args, &block) ⇒ Object
- .nil? ⇒ Boolean
- .to_s ⇒ Object
- .to_str ⇒ Object
Class Method Details
.__rc_autoload ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ruby-conf.rb', line 36 def __rc_autoload Find.find('.') do |path| next unless @@conf.nil? && path =~ /(?:^|\.)(?:#{EXTENTIONS.join('|')})$/ if (path =~ /(?:^|\.)(?:#{EXTENTIONS.join('|')})$/) && (File.read(path) =~ /^\s*\#\s*[%:=>&!;-]\s*ruby-conf\s*(?::(.*))?$/mi) = $1 RubyConf.err "Don't know what to do with options yet, you can have these back: #{}" if break if __rc_load(path) end end end |
.__rc_conf ⇒ Object
21 |
# File 'lib/ruby-conf.rb', line 21 def __rc_conf() @@conf end |
.__rc_load(path) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/ruby-conf.rb', line 23 def __rc_load(path) __rc_set_conf if load(path) && @@conf @@path, @@mtime, @@md5 = path, File.mtime(path).to_i, Digest::MD5.hexdigest(File.read(path)) RubyConf.out "[ruby-conf] Auto-Loaded config at path: #{path}" end end |
.__rc_loaded_conf ⇒ Object
20 |
# File 'lib/ruby-conf.rb', line 20 def __rc_loaded_conf() { path:@@path, mtime:@@mtime, md5:@@md5 } end |
.__rc_reload ⇒ Object
30 31 32 33 34 35 |
# File 'lib/ruby-conf.rb', line 30 def __rc_reload if @@mtime && @@mtime != File.mtime(@@path).to_i && @@md5 != Digest::MD5.hexdigest(File.read(@@path)) RubyConf.err "[ruby-conf] Detected change in config file, reloading..." __rc_load(@@path) end end |
.__rc_set_conf(conf = nil) ⇒ Object
22 |
# File 'lib/ruby-conf.rb', line 22 def __rc_set_conf(conf = nil) @@conf, @@path, @@mtime, @@md5 = conf, nil, nil, nil end |
.inspect ⇒ Object
59 60 61 62 |
# File 'lib/ruby-conf.rb', line 59 def inspect() __rc_reload @@conf.inspect end |
.method_missing(name, *args, &block) ⇒ Object
46 47 48 49 50 |
# File 'lib/ruby-conf.rb', line 46 def method_missing(name, *args, &block) __rc_reload __rc_autoload if @@conf.nil? @@conf.__send__(name, *args, &block) end |
.nil? ⇒ Boolean
63 64 65 66 |
# File 'lib/ruby-conf.rb', line 63 def nil?() __rc_reload @@conf.nil? end |
.to_s ⇒ Object
51 52 53 54 |
# File 'lib/ruby-conf.rb', line 51 def to_s() __rc_reload @@conf.to_s end |
.to_str ⇒ Object
55 56 57 58 |
# File 'lib/ruby-conf.rb', line 55 def to_str() __rc_reload @@conf.to_str end |