Class: Rsense::Server::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/rsense/server/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



13
14
15
16
17
# File 'lib/rsense/server/config.rb', line 13

def initialize
  @searched = []
  @ignores = []
  @errors = []
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



11
12
13
# File 'lib/rsense/server/config.rb', line 11

def errors
  @errors
end

#ignoresObject

Returns the value of attribute ignores.



11
12
13
# File 'lib/rsense/server/config.rb', line 11

def ignores
  @ignores
end

#options(config_path) ⇒ Object

Returns the value of attribute options.



11
12
13
# File 'lib/rsense/server/config.rb', line 11

def options
  @options
end

#portObject

Returns the value of attribute port.



11
12
13
# File 'lib/rsense/server/config.rb', line 11

def port
  @port
end

#searchedObject

Returns the value of attribute searched.



11
12
13
# File 'lib/rsense/server/config.rb', line 11

def searched
  @searched
end

Instance Method Details

#check_options(name) ⇒ Object



64
65
66
# File 'lib/rsense/server/config.rb', line 64

def check_options(name)
  @options.rest[name] if @options.rest.key?(name)
end

#search(path_str = "~", level = 0) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rsense/server/config.rb', line 19

def search(path_str="~", level=0)
  level = level + 1
  path = FileTree.new(path_str)
  return if @searched.include?(path)
  @searched << path
  conf = path.join(".rsense").expand_path
  unless conf.exist?
    if path.parent == path || level == 3
      contender = Pathname.new("~").join(".rsense").expand_path
      conf = contender if contender.exist?
    else
      conf = search(path.parent, level)
    end
  end
  conf
end

#set_up(path) ⇒ Object



68
69
70
71
72
73
# File 'lib/rsense/server/config.rb', line 68

def set_up(path)
  conf = search(path)
  if conf
    options(conf)
  end
end