Class: Adhearsion::PathString
- Defined in:
- lib/adhearsion/initializer.rb
Instance Attribute Summary collapse
-
#component_path ⇒ Object
Returns the value of attribute component_path.
-
#dialplan_path ⇒ Object
Returns the value of attribute dialplan_path.
-
#log_path ⇒ Object
Returns the value of attribute log_path.
Class Method Summary collapse
-
.from_application_subdirectory(folder) ⇒ nil, PathString
Will return a PathString for the application root folder to which the specified arbitrarily nested subfolder belongs.
Instance Method Summary collapse
- #base_path=(value) ⇒ Object
- #defaults ⇒ Object
-
#initialize(path) ⇒ PathString
constructor
A new instance of PathString.
- #using_base_path(temporary_base_path, &block) ⇒ Object
Methods inherited from String
===, #nameify, #nameify!, random, random_char, #unindent, #unindent!
Constructor Details
#initialize(path) ⇒ PathString
Returns a new instance of PathString.
55 56 57 58 |
# File 'lib/adhearsion/initializer.rb', line 55 def initialize(path) super defaults end |
Instance Attribute Details
#component_path ⇒ Object
Returns the value of attribute component_path.
53 54 55 |
# File 'lib/adhearsion/initializer.rb', line 53 def component_path @component_path end |
#dialplan_path ⇒ Object
Returns the value of attribute dialplan_path.
53 54 55 |
# File 'lib/adhearsion/initializer.rb', line 53 def dialplan_path @dialplan_path end |
#log_path ⇒ Object
Returns the value of attribute log_path.
53 54 55 |
# File 'lib/adhearsion/initializer.rb', line 53 def log_path @log_path end |
Class Method Details
.from_application_subdirectory(folder) ⇒ nil, PathString
Will return a PathString for the application root folder to which the specified arbitrarily nested subfolder belongs. It works by traversing parent directories looking for the .ahnrc file. If no .ahnrc is found, nil is returned.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/adhearsion/initializer.rb', line 37 def from_application_subdirectory(folder) folder = File. folder ahn_rc = nil until ahn_rc || folder == "/" possible_ahn_rc = File.join(folder, ".ahnrc") if File.exists?(possible_ahn_rc) ahn_rc = possible_ahn_rc else folder = File.(folder + "/..") end end ahn_rc ? new(folder) : nil end |
Instance Method Details
#base_path=(value) ⇒ Object
66 67 68 69 |
# File 'lib/adhearsion/initializer.rb', line 66 def base_path=(value) replace(value) defaults end |
#defaults ⇒ Object
60 61 62 63 64 |
# File 'lib/adhearsion/initializer.rb', line 60 def defaults @component_path = build_path_for "components" @dialplan_path = dup @log_path = build_path_for "logs" end |
#using_base_path(temporary_base_path, &block) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/adhearsion/initializer.rb', line 71 def using_base_path(temporary_base_path, &block) original_path = dup self.base_path = temporary_base_path block.call ensure self.base_path = original_path end |