Module: Hadupils::Search
- Defined in:
- lib/hadupils/search.rb
Class Method Summary collapse
-
.find_from_dir(name, start) ⇒ Object
Searches for directory containing a subdirectory ‘name`, starting at the specified `start` directory and walking upwards until it can go no farther.
-
.find_from_pwd(name) ⇒ Object
Performs a ‘find_from_dir` starting at the present working directory.
-
.hadoop_assets ⇒ Object
A search for #hadoop_assets_name from the pwd.
-
.hadoop_assets_name ⇒ Object
The basename to use when looking for hadoop assets from pwd.
-
.hadoop_assets_name=(basename) ⇒ Object
Set the basename to use when looking for hadoop assets from pwd.
-
.hive_extensions ⇒ Object
A search for #hive_extensions_name from the pwd.
-
.hive_extensions_name ⇒ Object
The basename to use when looking for hive extensions from pwd.
-
.hive_extensions_name=(basename) ⇒ Object
Set the basename to use when looking for hive assets from pwd.
-
.user_config ⇒ Object
The directory for user-specific configuration files.
- .user_config=(path) ⇒ Object
Class Method Details
.find_from_dir(name, start) ⇒ Object
Searches for directory containing a subdirectory ‘name`, starting at the specified `start` directory and walking upwards until it can go no farther. On first match, the absolute path to that subdirectory is returned. If not found, returns nil.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/hadupils/search.rb', line 6 def self.find_from_dir(name, start) curr = ::File.(start) last = nil while curr != last p = ::File.join(curr, name) return p if ::File.directory? p last = curr curr = ::File.dirname(curr) end nil end |
.find_from_pwd(name) ⇒ Object
Performs a ‘find_from_dir` starting at the present working directory.
19 20 21 |
# File 'lib/hadupils/search.rb', line 19 def self.find_from_pwd(name) find_from_dir(name, ::Dir.pwd) end |
.hadoop_assets ⇒ Object
A search for #hadoop_assets_name from the pwd. The default behavior is to look for a subdir named “hadoop-ext”, starting from the current working directory and walking upwards until a match is found or the file system root is encountered.
46 47 48 |
# File 'lib/hadupils/search.rb', line 46 def self.hadoop_assets find_from_pwd(hadoop_assets_name) end |
.hadoop_assets_name ⇒ Object
The basename to use when looking for hadoop assets from pwd.
33 34 35 |
# File 'lib/hadupils/search.rb', line 33 def self.hadoop_assets_name @hadoop_assets_name || 'hadoop-ext' end |
.hadoop_assets_name=(basename) ⇒ Object
Set the basename to use when looking for hadoop assets from pwd.
38 39 40 |
# File 'lib/hadupils/search.rb', line 38 def self.hadoop_assets_name=(basename) @hadoop_assets_name = basename end |
.hive_extensions ⇒ Object
A search for #hive_extensions_name from the pwd. The default behavior is to look for a subdir named hive-ext
, starting from the current working directory and walking upwards until a match is found or the file system root is encountered.
64 65 66 |
# File 'lib/hadupils/search.rb', line 64 def self.hive_extensions find_from_pwd(hive_extensions_name) end |
.hive_extensions_name ⇒ Object
The basename to use when looking for hive extensions from pwd.
51 52 53 |
# File 'lib/hadupils/search.rb', line 51 def self.hive_extensions_name @hive_extensions_name || 'hive-ext' end |
.hive_extensions_name=(basename) ⇒ Object
Set the basename to use when looking for hive assets from pwd.
56 57 58 |
# File 'lib/hadupils/search.rb', line 56 def self.hive_extensions_name=(basename) @hive_extensions_name = basename end |
.user_config ⇒ Object
The directory for user-specific configuration files.
24 25 26 |
# File 'lib/hadupils/search.rb', line 24 def self.user_config @user_config || ::File.(::File.join('~', 'conf')) end |
.user_config=(path) ⇒ Object
28 29 30 |
# File 'lib/hadupils/search.rb', line 28 def self.user_config=(path) @user_config = path end |