Module: PoiseService::Utils
Overview
Utility methods for PoiseService.
Constant Summary collapse
- COMMON_SEGMENTS =
Common segments to ignore
%w{var www current etc}.inject({}) {|memo, seg| memo[seg] = true; memo }
Class Method Summary collapse
-
.parse_service_name(path) ⇒ String
Parse the service name from a path.
Instance Method Summary collapse
-
#parse_service_name(path) ⇒ String
Parse the service name from a path.
Class Method Details
.parse_service_name(path) ⇒ String
Parse the service name from a path. Look at the last component of the path, ignoring some common names.
39 40 41 42 43 |
# File 'lib/poise_service/utils.rb', line 39 def parse_service_name(path) parts = Pathname.new(path).each_filename.to_a.reverse! # Find the last segment not in common segments, fall back to the last segment. parts.find {|seg| !COMMON_SEGMENTS[seg] } || parts.first end |
Instance Method Details
#parse_service_name(path) ⇒ String
Parse the service name from a path. Look at the last component of the path, ignoring some common names.
39 40 41 42 43 |
# File 'lib/poise_service/utils.rb', line 39 def parse_service_name(path) parts = Pathname.new(path).each_filename.to_a.reverse! # Find the last segment not in common segments, fall back to the last segment. parts.find {|seg| !COMMON_SEGMENTS[seg] } || parts.first end |