Class: Rdm::SourceLocator
- Inherits:
-
Object
- Object
- Rdm::SourceLocator
- Defined in:
- lib/rdm/source_locator.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #find_source_path_in_hierarchy(some_path) ⇒ Object
-
#initialize(path) ⇒ SourceLocator
constructor
A new instance of SourceLocator.
- #locate ⇒ Object
- #potential_file(some_path) ⇒ Object
- #present?(some_path) ⇒ Boolean
Constructor Details
#initialize(path) ⇒ SourceLocator
Returns a new instance of SourceLocator.
8 9 10 |
# File 'lib/rdm/source_locator.rb', line 8 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
7 8 9 |
# File 'lib/rdm/source_locator.rb', line 7 def path @path end |
Class Method Details
.locate(path) ⇒ Object
3 4 5 |
# File 'lib/rdm/source_locator.rb', line 3 def self.locate(path) Rdm::SourceLocator.new(path).locate end |
Instance Method Details
#find_source_path_in_hierarchy(some_path) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/rdm/source_locator.rb', line 16 def find_source_path_in_hierarchy(some_path) some_path = File.(some_path) raise Rdm::Errors::SourceFileDoesNotExist, path if some_path == '/' return potential_file(some_path) if present?(some_path) find_source_path_in_hierarchy(File.dirname(some_path)) end |
#locate ⇒ Object
12 13 14 |
# File 'lib/rdm/source_locator.rb', line 12 def locate find_source_path_in_hierarchy(path) end |
#potential_file(some_path) ⇒ Object
27 28 29 |
# File 'lib/rdm/source_locator.rb', line 27 def potential_file(some_path) File.join(some_path, Rdm::SOURCE_FILENAME) end |
#present?(some_path) ⇒ Boolean
23 24 25 |
# File 'lib/rdm/source_locator.rb', line 23 def present?(some_path) File.exist?(potential_file(some_path)) end |