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
Constructor Details
#initialize(path) ⇒ PathString
Returns a new instance of PathString.
45 46 47 48 |
# File 'lib/adhearsion/initializer.rb', line 45 def initialize(path) super defaults end |
Instance Attribute Details
#component_path ⇒ Object
Returns the value of attribute component_path.
43 44 45 |
# File 'lib/adhearsion/initializer.rb', line 43 def component_path @component_path end |
#dialplan_path ⇒ Object
Returns the value of attribute dialplan_path.
43 44 45 |
# File 'lib/adhearsion/initializer.rb', line 43 def dialplan_path @dialplan_path end |
#log_path ⇒ Object
Returns the value of attribute log_path.
43 44 45 |
# File 'lib/adhearsion/initializer.rb', line 43 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.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/adhearsion/initializer.rb', line 27 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
56 57 58 59 |
# File 'lib/adhearsion/initializer.rb', line 56 def base_path=(value) replace(value) defaults end |
#defaults ⇒ Object
50 51 52 53 54 |
# File 'lib/adhearsion/initializer.rb', line 50 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
61 62 63 64 65 66 67 |
# File 'lib/adhearsion/initializer.rb', line 61 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 |