Class: Masquito::Settings
- Inherits:
-
Object
- Object
- Masquito::Settings
- Defined in:
- lib/masquito/settings.rb
Instance Method Summary collapse
- #domains ⇒ Object
- #files ⇒ Object
- #include?(name) ⇒ Boolean
-
#initialize(config_path) ⇒ Settings
constructor
A new instance of Settings.
Constructor Details
#initialize(config_path) ⇒ Settings
Returns a new instance of Settings.
6 7 8 |
# File 'lib/masquito/settings.rb', line 6 def initialize(config_path) @pattern = File.join(config_path, '*') end |
Instance Method Details
#domains ⇒ Object
17 18 19 20 21 22 |
# File 'lib/masquito/settings.rb', line 17 def domains files.map do |symlink| name = File.basename(symlink) Resolv::DNS::Name.create(has_domain?(name) ? "#{name}." : "#{name}.dev.") end end |
#files ⇒ Object
10 11 12 13 14 15 |
# File 'lib/masquito/settings.rb', line 10 def files Dir.glob(@pattern).select do |file| is_symlink = File.lstat(file).symlink? !is_symlink || (is_symlink && Pathname.new(file).exist?) end end |
#include?(name) ⇒ Boolean
24 25 26 27 |
# File 'lib/masquito/settings.rb', line 24 def include?(name) name = Resolv::DNS::Name.create(name) if name.kind_of?(String) domains.any? { |n| name.eql?(n) || name.subdomain_of?(n) } end |